//Coroutines private IEnumerator CheckState() { do { if (previousState != currentState) { previousState = currentState; stageManagement.SetCurrentState(currentState); scoreManagement.SetCurrentState(currentState); playerManagement.SetCurrentState(currentState); enemyManagement.SetCurrentState(currentState); uiManagment.SetCurrentState(currentState); itemManagement.SetCurrentState(currentState); soundManagement.SetCurrentState(currentState); switch (currentState) { case GameState.INIT: OnInit(); break; case GameState.TITLE: OnTitle(); break; case GameState.OPTION_TITLE: OnOptionTitle(); break; case GameState.EXIT_TITLE: OnExitTitle(); break; case GameState.INIT_PLAY: OnInitPlay(); break; case GameState.PLAY: OnPlay(); break; case GameState.PAUSE: OnPause(); break; case GameState.OPTION_PAUSE: OnOptionPause(); break; case GameState.RESUME: OnResume(); break; case GameState.GAMEOVER: OnGameOver(); break; case GameState.BACK_TO_TITLE: OnBackToTitle(); break; case GameState.FINALIZE: OnFinalize(); break; default: break; } } yield return(null); } while (true); }