Added SFX to AI
- Footsteps, alert yell and unalert humming
This commit is contained in:
parent
d6fab4439f
commit
4daaa8e897
|
@ -103,7 +103,7 @@ public partial class Homeowner1 : BehaviourTree
|
||||||
footstepTimeRemaining -= velocity * Time.DeltaTimeF;
|
footstepTimeRemaining -= velocity * Time.DeltaTimeF;
|
||||||
if (footstepTimeRemaining < 0.0f)
|
if (footstepTimeRemaining < 0.0f)
|
||||||
{
|
{
|
||||||
Debug.Log("AI Play Footstep SFX");
|
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_footsteps");
|
||||||
footstepTimeRemaining = footstepSFXIntervalMultiplier;
|
footstepTimeRemaining = footstepSFXIntervalMultiplier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public partial class LeafChase : BehaviourTreeNode
|
||||||
|
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
{
|
{
|
||||||
Debug.Log("AI play unalert hmm");
|
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", false);
|
SetNodeData("isAlert", false);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue