25 lines
598 B
C#
25 lines
598 B
C#
using UnityEngine;
|
|
|
|
public class EnemyStateManager : MonoBehaviour
|
|
{
|
|
public IEnemyState CurrentState;
|
|
|
|
void Start()
|
|
{
|
|
TransitionToState(new EIdleState());
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
CurrentState?.UpdateState(this); // ? = CurrentState가 null이 아닐때만 실행되는 null 조건 연산자
|
|
}
|
|
|
|
public void TransitionToState(IEnemyState newState)
|
|
{
|
|
CurrentState?.ExitState(this);
|
|
CurrentState = newState;
|
|
CurrentState.EnterState(this);
|
|
print($"[TransitionToState]에서 상태 변경 -> {newState}");
|
|
}
|
|
}
|