보스 몬스터 Ai 관련 코드 틀 추가
This commit is contained in:
24
Assets/Scripts/AI/EnemyStateManager.cs
Normal file
24
Assets/Scripts/AI/EnemyStateManager.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user