2023-03-24 07:41:05 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
2023-03-24 13:26:18 +08:00
|
|
|
|
public class IdleState: AIBaseState
|
2023-03-24 07:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
2023-03-24 13:26:18 +08:00
|
|
|
|
float timer = 0.0f;
|
2023-03-24 07:41:05 +08:00
|
|
|
|
|
2023-03-24 13:26:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IdleState(StateMachine machine): base(machine)
|
|
|
|
|
{
|
|
|
|
|
stateName = "Idle";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnEnter()
|
2023-03-24 07:41:05 +08:00
|
|
|
|
{
|
2023-03-24 13:26:18 +08:00
|
|
|
|
timer = 0.0f;
|
2023-03-25 14:51:28 +08:00
|
|
|
|
animator.Play(ai.idleAnim);
|
|
|
|
|
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;
|
|
|
|
|
}
|
2023-03-24 07:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-24 13:26:18 +08:00
|
|
|
|
public override void update()
|
|
|
|
|
{
|
|
|
|
|
timer += Time.DeltaTimeF;
|
|
|
|
|
if(timer >= ai.idleDuration)
|
|
|
|
|
{
|
|
|
|
|
machine.SetState(typeof(PatrolState));
|
|
|
|
|
}
|
|
|
|
|
if(ai.ShouldTransitAlert())
|
|
|
|
|
{
|
|
|
|
|
machine.SetState(typeof(AlertState));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-24 07:41:05 +08:00
|
|
|
|
|
2023-03-24 13:26:18 +08:00
|
|
|
|
public override void fixedUpdate()
|
2023-03-24 07:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|