void Update() { // State machine shenanigans if (!m_initialised) { return; } if (m_currentGameState != null) { m_currentGameState.UpdateState(); } if (m_nextGameStateIndex != Enums.GameStateNames.GS_00_NULL) { if (m_currentGameState != null) { m_currentGameState.ExitState(m_nextGameStateIndex); } m_currentGameState = m_gameStateDictionary[m_nextGameStateIndex]; m_currentGameState.EnterState(m_currentGameStateIndex); m_currentGameStateIndex = m_nextGameStateIndex; m_nextGameStateIndex = Enums.GameStateNames.GS_00_NULL; } }
public void SwitchState(EGameStateType stateType) { if (m_curState != null) { m_curState.PreExitState(); m_curState.ExitState(); } m_stateDic.TryGetValue((int)stateType, out m_curState); if (m_curState != null && m_curState.StateType == stateType) { m_curState.PreEnterState(); m_curState.EnterState(); } }
/// <summary> /// Exits current state. /// </summary> public void ExitCurrentState() { currentGameState.ExitState(); }
/// <summary> /// Exits current state. /// </summary> public void ExitCurrentState() { currentGameState.ExitState(); // Debug.Log("Saiu do state"); }