62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Intrepid.Structures;
|
|
using Intrepid.Utilities;
|
|
using UnityEngine;
|
|
|
|
namespace Intrepid.Gameplay.Entities.Sentinel.StateMachine.States
|
|
{
|
|
public class SentinelStateDashLanding : SentinelState
|
|
{
|
|
[GroupConfigurations, SerializeField] private AnimationClip dashLanding;
|
|
[GroupConfigurations, SerializeField, Range(0, 30)] private float speed = 15;
|
|
[GroupConfigurations, SerializeField, Range(0, 10)] private float targetTime = .25f;
|
|
|
|
private Timer Timer { get; } = new();
|
|
|
|
public override SentinelStateType GetStateKey()
|
|
{
|
|
return SentinelStateType.DashLanding;
|
|
}
|
|
|
|
protected override void Subscriptions()
|
|
{
|
|
}
|
|
|
|
protected override void RunOnEnter(ParameterStore parameterStore)
|
|
{
|
|
Brain.Entity.ModelAnimation.Play(dashLanding);
|
|
Timer.Start();
|
|
}
|
|
|
|
protected override void RunOnExit()
|
|
{
|
|
Timer.Stop();
|
|
}
|
|
|
|
public override void RunOnUpdate()
|
|
{
|
|
if (CheckDash()) return;
|
|
if (Timer.IsNotRunning)
|
|
{
|
|
Brain.ChangeState(SentinelStateType.DashBreaking);
|
|
return;
|
|
}
|
|
Timer.Update(Time.deltaTime);
|
|
if (Timer.Check(targetTime))
|
|
{
|
|
Timer.Stop();
|
|
return;
|
|
}
|
|
Brain.Entity.DesiredVelocity = Brain.Entity.Forward * speed;
|
|
}
|
|
|
|
private bool CheckDash()
|
|
{
|
|
if (Brain.Inputs.Dash())
|
|
{
|
|
Brain.ChangeState(SentinelStateType.Dash);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
} |