ai fix along wit new music
This commit is contained in:
parent
44bbdf5f82
commit
2da73f12d0
Binary file not shown.
|
@ -9354,7 +9354,7 @@
|
||||||
- Is Trigger: true
|
- Is Trigger: true
|
||||||
Collision Tag: 5
|
Collision Tag: 5
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 0.600000024, y: 1.79999995, z: 1.5}
|
Half Extents: {x: 1, y: 1.79999995, z: 1.5}
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
|
|
@ -17145,7 +17145,7 @@
|
||||||
- Is Trigger: true
|
- Is Trigger: true
|
||||||
Collision Tag: 5
|
Collision Tag: 5
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 0.600000024, y: 1.79999995, z: 1.5}
|
Half Extents: {x: 1, y: 1.79999995, z: 1.5}
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: -4.64838362, y: 2.94342947, z: 0.209690213}
|
Translate: {x: -4.64838362, y: 2.94342947, z: 0.209690213}
|
||||||
Rotate: {x: 0.5, y: 0.5, z: 6.5}
|
Rotate: {x: -1.48352981, y: 0.5, z: 6.5}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Light Component:
|
Light Component:
|
||||||
|
@ -8951,7 +8951,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0.806008875, y: 0, z: 1.30613756}
|
Translate: {x: 4.1322155, y: 0, z: 1.85982013}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -8962,7 +8962,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0.513795853, y: 0, z: 5.17213631}
|
Translate: {x: 3.66769528, y: 0, z: 5.17213631}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -8973,7 +8973,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: -0.497500449, y: 0, z: 7.26010561}
|
Translate: {x: 5.12931681, y: 0, z: 7.53852272}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -8984,7 +8984,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: -0.380023897, y: 0, z: 9.58513737}
|
Translate: {x: 5.37614918, y: 0, z: 9.58513737}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -8995,7 +8995,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 4.76827145, y: 0, z: 9.12785816}
|
Translate: {x: -0.473824114, y: 0, z: 9.12785816}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9006,7 +9006,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 5.0583787, y: 0, z: 4.71819115}
|
Translate: {x: -0.366229892, y: 0, z: 4.99889755}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9017,7 +9017,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 3.53010821, y: 0, z: 4.63929033}
|
Translate: {x: 0.666945934, y: 0, z: 4.45493603}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9028,7 +9028,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 3.64600039, y: 0, z: 2.86434269}
|
Translate: {x: 0.605797768, y: 0, z: 2.86434269}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9039,7 +9039,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 3.50184393, y: 0, z: 0.390250444}
|
Translate: {x: 0.566371024, y: 0, z: 1.71020806}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -15112,7 +15112,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0.667429447, y: 0, z: 1.10868871}
|
Translate: {x: 3.96016145, y: 0, z: 1.54417288}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -15217,7 +15217,7 @@
|
||||||
- Is Trigger: true
|
- Is Trigger: true
|
||||||
Collision Tag: 5
|
Collision Tag: 5
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 0.800000012, y: 1.79999995, z: 1.5}
|
Half Extents: {x: 1, y: 1.79999995, z: 1.5}
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
|
|
@ -6,145 +6,148 @@ using SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States;
|
||||||
|
|
||||||
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
||||||
{
|
{
|
||||||
public class HomeOwnerAI:Script
|
public class HomeOwnerAI : Script
|
||||||
|
{
|
||||||
|
public float idleDuration = 1.0f;
|
||||||
|
public float timeoutDuration = 2.0f;
|
||||||
|
public GameObject patrolPointParent;
|
||||||
|
|
||||||
|
public float patrolSpeed = 2.0f;
|
||||||
|
public float chaseSpeed = 3.0f;
|
||||||
|
|
||||||
|
public float alertCooldown = 0.0f;
|
||||||
|
|
||||||
|
public GameObject player;
|
||||||
|
public GameObject attackHitbox;
|
||||||
|
|
||||||
|
public AnimationClipAsset walkingAnim;
|
||||||
|
public AnimationClipAsset idleAnim;
|
||||||
|
public AnimationClipAsset alertAnim;
|
||||||
|
public AnimationClipAsset alertRunAnim;
|
||||||
|
public AnimationClipAsset alertIdleAnim;
|
||||||
|
public AnimationClipAsset timeoutAnim;
|
||||||
|
public AnimationClipAsset atkWindupAnim;
|
||||||
|
public AnimationClipAsset atkHoldAnim;
|
||||||
|
public AnimationClipAsset atkSeqAnim;
|
||||||
|
|
||||||
|
private Vector3 startPos;
|
||||||
|
public bool atk { get; set; }
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
public IEnumerable<Transform> patrolPointPool;
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
{
|
{
|
||||||
public float idleDuration = 1.0f;
|
Transform transform = GetComponent<Transform>();
|
||||||
public float timeoutDuration = 2.0f;
|
StateMachine machine = GetScript<StateMachine>();
|
||||||
public GameObject patrolPointParent;
|
if (transform && machine)
|
||||||
|
{
|
||||||
public float patrolSpeed = 2.0f;
|
transform.GlobalPosition = startPos;
|
||||||
public float chaseSpeed = 3.0f;
|
machine.SetState(typeof(IdleState));
|
||||||
|
}
|
||||||
public float alertCooldown = 0.0f;
|
}
|
||||||
|
|
||||||
public GameObject player;
|
|
||||||
public GameObject attackHitbox;
|
|
||||||
|
|
||||||
public AnimationClipAsset walkingAnim;
|
|
||||||
public AnimationClipAsset idleAnim;
|
|
||||||
public AnimationClipAsset alertAnim;
|
|
||||||
public AnimationClipAsset alertRunAnim;
|
|
||||||
public AnimationClipAsset alertIdleAnim;
|
|
||||||
public AnimationClipAsset timeoutAnim;
|
|
||||||
public AnimationClipAsset atkWindupAnim;
|
|
||||||
public AnimationClipAsset atkHoldAnim;
|
|
||||||
public AnimationClipAsset atkSeqAnim;
|
|
||||||
|
|
||||||
private Vector3 startPos;
|
|
||||||
|
|
||||||
[NonSerialized]
|
|
||||||
public IEnumerable<Transform> patrolPointPool;
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
Transform transform = GetComponent<Transform>();
|
|
||||||
StateMachine machine = GetScript<StateMachine>();
|
|
||||||
if (transform && machine)
|
|
||||||
{
|
|
||||||
transform.GlobalPosition = startPos;
|
|
||||||
machine.SetState(typeof(IdleState));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
StateMachine machine = GetScript<StateMachine>();
|
StateMachine machine = GetScript<StateMachine>();
|
||||||
if(machine)
|
if (machine)
|
||||||
{
|
{
|
||||||
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
|
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
|
||||||
dictionary.Add(typeof(IdleState), new IdleState(machine));
|
dictionary.Add(typeof(IdleState), new IdleState(machine));
|
||||||
dictionary.Add(typeof(PatrolState), new PatrolState(machine));
|
dictionary.Add(typeof(PatrolState), new PatrolState(machine));
|
||||||
dictionary.Add(typeof(TimeoutState), new TimeoutState(machine));
|
dictionary.Add(typeof(TimeoutState), new TimeoutState(machine));
|
||||||
dictionary.Add(typeof(ChaseState), new ChaseState(machine));
|
dictionary.Add(typeof(ChaseState), new ChaseState(machine));
|
||||||
dictionary.Add(typeof(AlertState), new AlertState(machine));
|
dictionary.Add(typeof(AlertState), new AlertState(machine));
|
||||||
dictionary.Add(typeof(AttackState), new AttackState(machine));
|
dictionary.Add(typeof(AttackState), new AttackState(machine));
|
||||||
|
|
||||||
machine.InitStateMachine(dictionary);
|
machine.InitStateMachine(dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioHandler.audioClipHandlers["HO_footsteps"] = SHADE.Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
|
AudioHandler.audioClipHandlers["HO_footsteps"] = SHADE.Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
|
||||||
|
|
||||||
patrolPointPool = patrolPointParent.GetComponentsInChildren<Transform>();
|
patrolPointPool = patrolPointParent.GetComponentsInChildren<Transform>();
|
||||||
Transform transform = GetComponent<Transform>();
|
Transform transform = GetComponent<Transform>();
|
||||||
if (transform)
|
if (transform)
|
||||||
{
|
{
|
||||||
startPos = transform.GlobalPosition;
|
startPos = transform.GlobalPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void start()
|
|
||||||
{
|
|
||||||
attackHitbox.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected override void update()
|
|
||||||
{
|
|
||||||
if(alertCooldown > 0.0f)
|
|
||||||
{
|
|
||||||
alertCooldown -= Time.DeltaTimeF;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
alertCooldown = 0.0f;
|
|
||||||
}
|
|
||||||
AICheat();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShouldTransitAlert()
|
|
||||||
{
|
|
||||||
AILineOfSight los = GetScript<AILineOfSight>();
|
|
||||||
if (los)
|
|
||||||
{
|
|
||||||
if (los.withinSight && alertCooldown <= 0.0f)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RotateToPlayer()
|
|
||||||
{
|
|
||||||
|
|
||||||
//Transform playerTransform = player.GetComponent<Transform>();
|
|
||||||
|
|
||||||
////Rotate to face player.
|
|
||||||
//Transform aiTransform = GetComponent<Transform>();
|
|
||||||
//if(playerTransform && aiTransform)
|
|
||||||
//{
|
|
||||||
// Vector3 direction = playerTransform.GlobalPosition - aiTransform.GlobalPosition;
|
|
||||||
// Quaternion currentRotation = aiTransform.LocalRotation;
|
|
||||||
// Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
|
|
||||||
// aiTransform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, 5.0f * (float)Time.FixedDeltaTime);
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AICheat()
|
|
||||||
{
|
|
||||||
StateMachine machine = GetScript<StateMachine>();
|
|
||||||
AILineOfSight los = GetScript<AILineOfSight>();
|
|
||||||
if(machine && los)
|
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(Input.KeyCode.K))
|
|
||||||
{
|
|
||||||
los.range = 5.0f;
|
|
||||||
machine.SetState(typeof(AlertState));
|
|
||||||
}
|
|
||||||
if(Input.GetKeyDown(Input.KeyCode.L))
|
|
||||||
{
|
|
||||||
los.range = 0.0f;
|
|
||||||
machine.SetState(typeof(IdleState));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
atk = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void start()
|
||||||
|
{
|
||||||
|
//attackHitbox.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
if (alertCooldown > 0.0f)
|
||||||
|
{
|
||||||
|
alertCooldown -= Time.DeltaTimeF;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alertCooldown = 0.0f;
|
||||||
|
}
|
||||||
|
AICheat();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShouldTransitAlert()
|
||||||
|
{
|
||||||
|
AILineOfSight los = GetScript<AILineOfSight>();
|
||||||
|
if (los)
|
||||||
|
{
|
||||||
|
if (los.withinSight && alertCooldown <= 0.0f)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RotateToPlayer()
|
||||||
|
{
|
||||||
|
|
||||||
|
//Transform playerTransform = player.GetComponent<Transform>();
|
||||||
|
|
||||||
|
////Rotate to face player.
|
||||||
|
//Transform aiTransform = GetComponent<Transform>();
|
||||||
|
//if(playerTransform && aiTransform)
|
||||||
|
//{
|
||||||
|
// Vector3 direction = playerTransform.GlobalPosition - aiTransform.GlobalPosition;
|
||||||
|
// Quaternion currentRotation = aiTransform.LocalRotation;
|
||||||
|
// Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
|
||||||
|
// aiTransform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, 5.0f * (float)Time.FixedDeltaTime);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AICheat()
|
||||||
|
{
|
||||||
|
StateMachine machine = GetScript<StateMachine>();
|
||||||
|
AILineOfSight los = GetScript<AILineOfSight>();
|
||||||
|
if (machine && los)
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.K))
|
||||||
|
{
|
||||||
|
los.range = 5.0f;
|
||||||
|
machine.SetState(typeof(AlertState));
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.L))
|
||||||
|
{
|
||||||
|
los.range = 0.0f;
|
||||||
|
machine.SetState(typeof(IdleState));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,18 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
||||||
{
|
{
|
||||||
public GameObject aiGO;
|
public GameObject aiGO;
|
||||||
|
|
||||||
Transform transform;
|
private bool raccoonFound = false;
|
||||||
Transform aiTransform;
|
Transform transform;
|
||||||
|
Transform aiTransform;
|
||||||
|
|
||||||
|
private PlayerController pc;
|
||||||
|
private HomeOwnerAI ai;
|
||||||
|
|
||||||
protected override void start()
|
protected override void start()
|
||||||
{
|
{
|
||||||
transform = GetComponent<Transform>();
|
transform = GetComponent<Transform>();
|
||||||
aiTransform = aiGO.GetComponent<Transform>();
|
aiTransform = aiGO.GetComponent<Transform>();
|
||||||
|
ai = aiGO.GetScript<HomeOwnerAI>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
|
@ -32,27 +36,26 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
||||||
transform.GlobalEulerAngles = aiTransform.GlobalEulerAngles;
|
transform.GlobalEulerAngles = aiTransform.GlobalEulerAngles;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (raccoonFound && pc && ai)
|
||||||
|
{
|
||||||
|
pc.currentState = RaccoonStates.CAUGHT;
|
||||||
|
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
|
||||||
|
pc.stateMachine.SetState(typeof(PlayerCaughtState));
|
||||||
|
|
||||||
|
pc.GotCaught();
|
||||||
|
ai.Reset();
|
||||||
|
raccoonFound = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void onTriggerStay(CollisionInfo info)
|
protected override void onTriggerStay(CollisionInfo info)
|
||||||
{
|
{
|
||||||
|
pc = info.GameObject.GetScript<PlayerController>();
|
||||||
PlayerController pc = info.GameObject.GetScript<PlayerController>();
|
if (ai && ai.atk && pc)
|
||||||
HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>();
|
|
||||||
if (pc)
|
|
||||||
{
|
{
|
||||||
pc.currentState = RaccoonStates.CAUGHT;
|
raccoonFound = true;
|
||||||
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
|
|
||||||
pc.stateMachine.SetState(typeof(PlayerCaughtState));
|
|
||||||
|
|
||||||
pc.GotCaught();
|
|
||||||
if (ai)
|
|
||||||
{
|
|
||||||
ai.Reset();
|
|
||||||
GameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,52 +4,55 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using SHADE_Scripting.Audio;
|
||||||
|
|
||||||
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
||||||
{
|
{
|
||||||
public class AlertState: AIBaseState
|
public class AlertState : AIBaseState
|
||||||
|
{
|
||||||
|
const float alertDuration = 16.0f / 30.0f + 1.0f;
|
||||||
|
float alertTimer = alertDuration;
|
||||||
|
|
||||||
|
public AlertState(StateMachine machine) : base(machine)
|
||||||
{
|
{
|
||||||
const float alertDuration = 16.0f/30.0f + 1.0f;
|
stateName = "Alert";
|
||||||
float alertTimer = alertDuration;
|
AudioHandler.audioClipHandlers["raccoondetected"] = SHADE.Audio.CreateAudioClip("event:/Raccoon/raccoon_detected");
|
||||||
|
|
||||||
|
|
||||||
public AlertState(StateMachine machine): base(machine)
|
|
||||||
{
|
|
||||||
stateName = "Alert";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnEnter()
|
|
||||||
{
|
|
||||||
alertTimer = alertDuration;
|
|
||||||
if(animator)
|
|
||||||
{
|
|
||||||
animator.PlayOneShot(ai.alertAnim);
|
|
||||||
|
|
||||||
}
|
|
||||||
SHADE.Audio.SetParameterWithLabel("PlayerDetection", "Detected");
|
|
||||||
}
|
|
||||||
public override void OnExit()
|
|
||||||
{
|
|
||||||
animator.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void update()
|
|
||||||
{
|
|
||||||
alertTimer -= Time.DeltaTimeF;
|
|
||||||
if (alertTimer <= 0.0f)
|
|
||||||
{
|
|
||||||
machine.SetState(typeof(ChaseState));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override void fixedUpdate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnEnter()
|
||||||
|
{
|
||||||
|
alertTimer = alertDuration;
|
||||||
|
if (animator)
|
||||||
|
{
|
||||||
|
animator.PlayOneShot(ai.alertAnim);
|
||||||
|
|
||||||
|
}
|
||||||
|
SHADE.Audio.SetParameterWithLabel("PlayerDetection", "Detected");
|
||||||
|
AudioHandler.audioClipHandlers["raccoondetected"].Play();
|
||||||
|
}
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
animator.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void update()
|
||||||
|
{
|
||||||
|
alertTimer -= Time.DeltaTimeF;
|
||||||
|
if (alertTimer <= 0.0f)
|
||||||
|
{
|
||||||
|
machine.SetState(typeof(ChaseState));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public override void fixedUpdate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,145 +7,149 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
||||||
{
|
{
|
||||||
public class AttackState: AIBaseState
|
public class AttackState : AIBaseState
|
||||||
|
{
|
||||||
|
|
||||||
|
float timer = 0.0f;
|
||||||
|
|
||||||
|
float windupTime = 8.0f / 30.0f;
|
||||||
|
float holdTime = 0.3f;
|
||||||
|
float seqTime = 8.0f / 30.0f;
|
||||||
|
float endTime = 0.5f;
|
||||||
|
|
||||||
|
|
||||||
|
bool windUp = false;
|
||||||
|
bool hold = false;
|
||||||
|
bool seq = false;
|
||||||
|
bool end = false;
|
||||||
|
|
||||||
|
|
||||||
|
public AttackState(StateMachine machine) : base(machine)
|
||||||
{
|
{
|
||||||
|
|
||||||
float timer = 0.0f;
|
}
|
||||||
|
|
||||||
float windupTime = 8.0f / 30.0f;
|
|
||||||
float holdTime = 0.3f;
|
|
||||||
float seqTime = 8.0f / 30.0f ;
|
|
||||||
float endTime = 0.5f;
|
|
||||||
|
|
||||||
|
|
||||||
bool windUp = false;
|
public override void OnEnter()
|
||||||
bool hold = false;
|
{
|
||||||
bool seq = false;
|
timer = 0.0f;
|
||||||
bool end = false;
|
animator.PlayOneShot(ai.atkWindupAnim);
|
||||||
|
windUp = true;
|
||||||
|
hold = false;
|
||||||
|
seq = false;
|
||||||
|
end = false;
|
||||||
|
timer = windupTime;
|
||||||
|
|
||||||
public AttackState(StateMachine machine): base(machine)
|
RotateToVelocity rotate = machine.GetScript<RotateToVelocity>();
|
||||||
{
|
if (rotate)
|
||||||
|
rotate.active = false;
|
||||||
|
|
||||||
}
|
RigidBody rigid = machine.GetComponent<RigidBody>();
|
||||||
|
if (rigid)
|
||||||
|
{
|
||||||
|
rigid.LinearVelocity = Vector3.Zero;
|
||||||
|
}
|
||||||
|
Transform transform = machine.GetComponent<Transform>();
|
||||||
|
AILineOfSight los = machine.GetScript<AILineOfSight>();
|
||||||
|
Transform playerTransform = ai.player.GetComponent<Transform>();
|
||||||
|
|
||||||
|
|
||||||
public override void OnEnter()
|
if (los && transform)
|
||||||
{
|
{
|
||||||
timer = 0.0f;
|
Vector3 direction = playerTransform.GlobalPosition - transform.GlobalPosition;
|
||||||
animator.PlayOneShot(ai.atkWindupAnim);
|
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
|
||||||
windUp = true;
|
transform.LocalRotation = targetRotation;
|
||||||
hold = false;
|
|
||||||
seq = false;
|
|
||||||
end = false;
|
|
||||||
timer = windupTime;
|
|
||||||
|
|
||||||
RotateToVelocity rotate = machine.GetScript<RotateToVelocity>();
|
}
|
||||||
if (rotate)
|
|
||||||
rotate.active = false;
|
|
||||||
|
|
||||||
RigidBody rigid = machine.GetComponent<RigidBody>();
|
//ai.attackHitbox.SetActive(false);
|
||||||
if(rigid)
|
|
||||||
{
|
|
||||||
rigid.LinearVelocity = Vector3.Zero;
|
|
||||||
}
|
|
||||||
Transform transform = machine.GetComponent<Transform>();
|
|
||||||
AILineOfSight los = machine.GetScript<AILineOfSight>();
|
|
||||||
Transform playerTransform = ai.player.GetComponent<Transform>();
|
|
||||||
|
|
||||||
|
|
||||||
if (los && transform)
|
|
||||||
{
|
|
||||||
Vector3 direction = playerTransform.GlobalPosition - transform.GlobalPosition;
|
|
||||||
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
|
|
||||||
transform.LocalRotation = targetRotation;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ai.attackHitbox.SetActive(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnExit()
|
|
||||||
{
|
|
||||||
animator.Stop();
|
|
||||||
RotateToVelocity rotate = ai.GetScript<RotateToVelocity>();
|
|
||||||
if (rotate)
|
|
||||||
{
|
|
||||||
rotate.active = true;
|
|
||||||
rotate.lookAround = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ai.attackHitbox.SetActive(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void update()
|
|
||||||
{
|
|
||||||
timer -= Time.DeltaTimeF;
|
|
||||||
if(windUp)
|
|
||||||
{
|
|
||||||
if(timer <= 0.0f)
|
|
||||||
{
|
|
||||||
windUp = false;
|
|
||||||
hold = true;
|
|
||||||
animator.Play(ai.atkHoldAnim);
|
|
||||||
timer = holdTime;
|
|
||||||
ai.attackHitbox.SetActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(hold)
|
|
||||||
{
|
|
||||||
if(timer <= 0.0f)
|
|
||||||
{
|
|
||||||
hold = false;
|
|
||||||
seq = true;
|
|
||||||
animator.PlayOneShot(ai.atkSeqAnim);
|
|
||||||
timer = seqTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(seq)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(timer <= 1.0f / 30.0f)
|
|
||||||
{
|
|
||||||
ai.attackHitbox.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(timer <= 0.0f)
|
|
||||||
{
|
|
||||||
seq = false;
|
|
||||||
end = true;
|
|
||||||
|
|
||||||
timer = endTime;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(end)
|
|
||||||
{
|
|
||||||
if(timer <= 0.0f)
|
|
||||||
{
|
|
||||||
end = false;
|
|
||||||
AILineOfSight los = ai.GetScript<AILineOfSight>();
|
|
||||||
if (los && los.withinSight)
|
|
||||||
{
|
|
||||||
machine.SetState(typeof(ChaseState));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
machine.SetState(typeof(TimeoutState));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void fixedUpdate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnExit()
|
||||||
|
{
|
||||||
|
animator.Stop();
|
||||||
|
RotateToVelocity rotate = ai.GetScript<RotateToVelocity>();
|
||||||
|
if (rotate)
|
||||||
|
{
|
||||||
|
rotate.active = true;
|
||||||
|
rotate.lookAround = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//ai.attackHitbox.SetActive(false);
|
||||||
|
machine.GetScript<HomeOwnerAI>().atk = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void update()
|
||||||
|
{
|
||||||
|
timer -= Time.DeltaTimeF;
|
||||||
|
if (windUp)
|
||||||
|
{
|
||||||
|
if (timer <= 0.0f)
|
||||||
|
{
|
||||||
|
windUp = false;
|
||||||
|
hold = true;
|
||||||
|
animator.Play(ai.atkHoldAnim);
|
||||||
|
timer = holdTime;
|
||||||
|
//ai.attackHitbox.SetActive(true);
|
||||||
|
//machine.GetScript<HomeOwnerAI>().atk = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (hold)
|
||||||
|
{
|
||||||
|
if (timer <= 0.0f)
|
||||||
|
{
|
||||||
|
hold = false;
|
||||||
|
seq = true;
|
||||||
|
animator.PlayOneShot(ai.atkSeqAnim);
|
||||||
|
timer = seqTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (seq)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (timer <= 1.0f / 30.0f)
|
||||||
|
{
|
||||||
|
//ai.attackHitbox.SetActive(true);
|
||||||
|
machine.GetScript<HomeOwnerAI>().atk = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timer <= 0.0f)
|
||||||
|
{
|
||||||
|
seq = false;
|
||||||
|
end = true;
|
||||||
|
|
||||||
|
timer = endTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (end)
|
||||||
|
{
|
||||||
|
if (timer <= 0.0f)
|
||||||
|
{
|
||||||
|
end = false;
|
||||||
|
AILineOfSight los = ai.GetScript<AILineOfSight>();
|
||||||
|
if (los && los.withinSight)
|
||||||
|
{
|
||||||
|
machine.SetState(typeof(ChaseState));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
machine.SetState(typeof(TimeoutState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void fixedUpdate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.Audio;
|
using SHADE_Scripting.Audio;
|
||||||
|
using SHADE_Scripting.Gameplay.AIBehaviour.AIRework;
|
||||||
using System;
|
using System;
|
||||||
public class Item : Script
|
public class Item : Script
|
||||||
{
|
{
|
||||||
|
@ -155,7 +156,7 @@ public class Item : Script
|
||||||
emitter.Emit();
|
emitter.Emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.GameObject.GetScript<Homeowner1>() && homeownerOnce)
|
if (info.GameObject.GetScript<HomeOwnerAI>() && homeownerOnce)
|
||||||
{
|
{
|
||||||
homeownerOnce = false;
|
homeownerOnce = false;
|
||||||
returnBack = true;
|
returnBack = true;
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class GameManager : Script
|
||||||
private bool goingToWin;
|
private bool goingToWin;
|
||||||
private bool goingToLose;
|
private bool goingToLose;
|
||||||
|
|
||||||
|
private bool playSpeedUp = false;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
if (Instance != null && Instance != this)
|
if (Instance != null && Instance != this)
|
||||||
|
@ -91,6 +93,7 @@ public class GameManager : Script
|
||||||
|
|
||||||
AudioHandler.audioClipHandlers["SFXItemScore"] = Audio.CreateAudioClip("event:/Music/stingers/item_scored");
|
AudioHandler.audioClipHandlers["SFXItemScore"] = Audio.CreateAudioClip("event:/Music/stingers/item_scored");
|
||||||
AudioHandler.audioClipHandlers["RaccoonScored"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_scored");
|
AudioHandler.audioClipHandlers["RaccoonScored"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_scored");
|
||||||
|
Audio.SetParameterWithLabel("PlaybackSpeed", "Normal");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void start()
|
protected override void start()
|
||||||
|
@ -123,6 +126,13 @@ public class GameManager : Script
|
||||||
if (currGameState == GameState.START)
|
if (currGameState == GameState.START)
|
||||||
{
|
{
|
||||||
timer -= Time.DeltaTimeF;
|
timer -= Time.DeltaTimeF;
|
||||||
|
|
||||||
|
if (timer < 30.0f && !playSpeedUp)
|
||||||
|
{
|
||||||
|
Audio.SetParameterWithLabel("PlaybackSpeed", "ToTransition");
|
||||||
|
playSpeedUp = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(scoreText)
|
if(scoreText)
|
||||||
scoreText.GetComponent<TextRenderable>().Text = $"{Score}";
|
scoreText.GetComponent<TextRenderable>().Text = $"{Score}";
|
||||||
if(timeText)
|
if(timeText)
|
||||||
|
|
Loading…
Reference in New Issue