36 lines
945 B
C#
36 lines
945 B
C#
using UnityEngine;
|
|
|
|
namespace State.PawnStateMachine
|
|
{
|
|
public class PawnStateMachine : StateMachine
|
|
{
|
|
public Pawn controlledPawn;
|
|
private bool _forwardInput;
|
|
|
|
public void Issue(GameState.Command command)
|
|
{
|
|
if(_forwardInput) CurrentState?.Handle(command);
|
|
}
|
|
|
|
public void SetMove(Vector2 input)
|
|
{
|
|
if(_forwardInput) CurrentState?.Handle(input);
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
GameStateMachine.GameStateMachine.Instance.OnStateChange += HandleStateChange;
|
|
HandleStateChange(GameStateMachine.GameStateMachine.Instance.CurrentState);
|
|
ChangeState(new Idle());
|
|
}
|
|
|
|
private void HandleStateChange(GameState newState)
|
|
{
|
|
_forwardInput = newState switch
|
|
{
|
|
GameStateMachine.PlayLevel => true,
|
|
_ => false
|
|
};
|
|
}
|
|
}
|
|
} |