27 lines
544 B
C#
27 lines
544 B
C#
using UnityEngine;
|
|
|
|
namespace State
|
|
{
|
|
public class Machine : MonoBehaviour
|
|
{
|
|
private GameState _currentState;
|
|
|
|
public void Update()
|
|
{
|
|
_currentState?.OnUpdate(Time.deltaTime);
|
|
}
|
|
|
|
public void FixedUpdate()
|
|
{
|
|
_currentState?.OnFixedUpdate(Time.fixedDeltaTime);
|
|
}
|
|
|
|
public void ChangeState(GameState newState)
|
|
{
|
|
_currentState?.OnExit();
|
|
_currentState = newState;
|
|
_currentState.OnEnter(this);
|
|
}
|
|
}
|
|
}
|