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(); } }
// Update is called once per frame 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; } }