public void OnGameStateChanged(StateChangeSignal state) { switch (state.newGameState) { case GameStatesType.PLAYERSTATE: if (currentUI != null) { previousUI = currentUI; } else { currentUI = new PlayUIController(playView); } if (currentUI.GetUIState() != GameStatesType.PLAYERSTATE) { currentUI = new PlayUIController(playView); if (previousUI != null && previousUI.GetUIState() != GameStatesType.PLAYERSTATE) { previousUI.DestroyUI(); } } break; case GameStatesType.GAMEOVERSTATE: previousUI = currentUI; previousUI.DestroyUI(); currentUI = new GameOverUIController(overView); break; case GameStatesType.LEVELFINISHEDSTATE: previousUI = currentUI; previousUI.DestroyUI(); currentUI = new LevelFinishedUIController(finishedUIView); break; case GameStatesType.LOBBYSTATE: previousUI = currentUI; if (previousUI != null) { previousUI.DestroyUI(); } currentUI = new LobbyUIController(lobbyUIView); break; } }