35 lines
804 B
C#
35 lines
804 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace DefaultNamespace.FSM
|
|
{
|
|
public class ChaseSystem : MonoBehaviour, IFiniteStateMachine
|
|
{
|
|
[SerializeField] private PlayerController _playerController;
|
|
|
|
private IState _currentState = null;
|
|
|
|
private void OnEnable()
|
|
{
|
|
_currentState = new IdleState(gameObject, _playerController, 60.0f);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_currentState = null;
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (_currentState == null) return;
|
|
_currentState.Update(this);
|
|
}
|
|
|
|
public void SetState(IState state)
|
|
{
|
|
_currentState.Exit(this);
|
|
_currentState = state;
|
|
_currentState.Enter(this);
|
|
}
|
|
}
|
|
} |