public GameStatusStateMachine(GameStatusEnum gameStatus) { GameStatusStatesFactory.SetGameStateMachine(this); // Set GameStatusStateMachine in Factory currentGameStatusState = GameStatusStatesFactory.GetGameState(gameStatus); ChangeGameStatus(gameStatus); // To enter the currentGameStatusState currentGameStatusEnum = gameStatus; // To be set after currentGameStatusState has been entered }
IEnumerator StartServiceCounterCoroutine() { yield return(delayServiceWaitForSeconds); currentBall = Instantiate(ballPrefab); ballIsServed = true; GameStatusStatesFactory.GetGameStateMachine().ChangeGameStatus(GameStatusEnum.GameRunning); }
void PauseUnpause() { isGamePaused = !isGamePaused; if (isGamePaused == true) { GameStatusStatesFactory.GetGameStateMachine().ChangeGameStatus(GameStatusEnum.GamePaused); } else { GameStatusStatesFactory.GetGameStateMachine().BackToPreviousState(); } }
public void ChangeGameStatus(GameStatusEnum gameStatus) { if (currentGameStatusEnum == gameStatus) { Debug.LogWarning($"GameStatusStateMachine : Trying to set an already active {currentGameStatusEnum} GameStatusState!!"); return; } if (currentGameStatusState != null) { PreviousGameStatusEnum = currentGameStatusEnum; currentGameStatusEnum = gameStatus; currentGameStatusState.Exit(); } Debug.Log($"Game Current State : {currentGameStatusEnum}"); currentGameStatusState = GameStatusStatesFactory.GetGameState(gameStatus); currentGameStatusState.Enter(); }
private void GoHome() { Debug.Log("Back to Home"); GameStatusStatesFactory.GetGameStateMachine().ChangeGameStatus(GameStatusEnum.ReadyToStart); }