|
|
|
@ -41,7 +41,6 @@ public partial class LeafSearch : BehaviourTreeNode
|
|
|
|
|
//Helper, find the nearest unobstructed waypoint to return to when chase is over
|
|
|
|
|
private void reevaluateWaypoint()
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("Reevaluating Waypoints");
|
|
|
|
|
List<GameObject> waypoints = (List<GameObject>)GetNodeData("waypoints");
|
|
|
|
|
|
|
|
|
|
if (waypoints == null)
|
|
|
|
@ -62,6 +61,17 @@ public partial class LeafSearch : BehaviourTreeNode
|
|
|
|
|
SetNodeData("currentWaypointIndex", nearestWaypointIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Helper for handling stopping of chases
|
|
|
|
|
private void handleChaseStop()
|
|
|
|
|
{
|
|
|
|
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
|
|
|
|
{
|
|
|
|
|
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
|
|
|
|
reevaluateWaypoint();
|
|
|
|
|
}
|
|
|
|
|
SetNodeData("isAlert", false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override BehaviourTreeNodeStatus Evaluate()
|
|
|
|
|
{
|
|
|
|
|
//Debug.LogWarning("LeafSearch");
|
|
|
|
@ -94,12 +104,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
|
|
|
|
if ((plrT.GlobalPosition - transform.GlobalPosition).GetMagnitude() > sightDistance)
|
|
|
|
|
{
|
|
|
|
|
//Debug.Log("Failure: Too far");
|
|
|
|
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("AI play unalert hmm");
|
|
|
|
|
reevaluateWaypoint();
|
|
|
|
|
}
|
|
|
|
|
SetNodeData("isAlert", false);
|
|
|
|
|
handleChaseStop();
|
|
|
|
|
status = BehaviourTreeNodeStatus.FAILURE;
|
|
|
|
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
|
|
|
|
return status;
|
|
|
|
@ -114,12 +119,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
|
|
|
|
if (Vector3.Dot(difference, lookDirection) < 0.0f)
|
|
|
|
|
{
|
|
|
|
|
//Debug.Log("Failure: Out of FOV");
|
|
|
|
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("AI play unalert hmm");
|
|
|
|
|
reevaluateWaypoint();
|
|
|
|
|
}
|
|
|
|
|
SetNodeData("isAlert", false);
|
|
|
|
|
handleChaseStop();
|
|
|
|
|
status = BehaviourTreeNodeStatus.FAILURE;
|
|
|
|
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
|
|
|
|
return status;
|
|
|
|
@ -140,12 +140,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
|
|
|
|
if (sightRayHit.Hit && sightRayHit.Other != player)
|
|
|
|
|
{
|
|
|
|
|
//Debug.Log("Failure: Ray hit obstacle named " + sightRayHit.Other.GetValueOrDefault().Name + " ID" + sightRayHit.Other.GetValueOrDefault().EntityId);
|
|
|
|
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("AI play unalert hmm");
|
|
|
|
|
reevaluateWaypoint();
|
|
|
|
|
}
|
|
|
|
|
SetNodeData("isAlert", false);
|
|
|
|
|
handleChaseStop();
|
|
|
|
|
status = BehaviourTreeNodeStatus.FAILURE;
|
|
|
|
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
|
|
|
|
return status;
|
|
|
|
@ -162,7 +157,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
|
|
|
|
|
|
|
|
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("AI Play Alerted Yell here");
|
|
|
|
|
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
|
|
|
|
|
}
|
|
|
|
|
SetNodeData("isAlert", true);
|
|
|
|
|
|
|
|
|
|