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