SHADE_Y3/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/IdleState.cs

65 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHADE;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{
public class IdleState: AIBaseState
{
float timer = 0.0f;
public IdleState(StateMachine machine): base(machine)
{
stateName = "Idle";
}
public override void OnEnter()
{
timer = 0.0f;
animator.Play(ai.idleAnim);
SHADE.Audio.SetParameterWithLabel("PlayerDetection", "Undetected");
RotateToVelocity rotate = ai.GetScript<RotateToVelocity>();
if (rotate)
{
rotate.lookAround = true;
}
}
public override void OnExit()
{
animator.Stop();
RotateToVelocity rotate = ai.GetScript<RotateToVelocity>();
if (rotate)
{
rotate.lookAround = false;
}
}
public override void update()
{
timer += Time.DeltaTimeF;
if(timer >= ai.idleDuration)
{
machine.SetState(typeof(PatrolState));
}
if(ai.ShouldTransitAlert())
{
machine.SetState(typeof(AlertState));
}
}
public override void fixedUpdate()
{
}
}
}