public void AddState(Enum p_enum, Script_IState p_state) { int key = Convert.ToInt32(p_enum); if (!_states.ContainsKey(key)) { _states.Add(key, p_state); } }
public void SetState(Enum p_enum) { int key = Convert.ToInt32(p_enum); if (_states [key] != _currentState) { if (_states.ContainsKey(key)) { if (_currentState != null) { _currentState.Exit(); } _currentState = _states [key]; _currentState.Enter(); } } }
public Script_Statemachine() { _currentState = null; _states = new Dictionary <int, Script_IState> (); }