// Updates the game over and how to restart msg for each game state public void UpdateMessages(GameStates.States gameState) { switch (gameState) { case GameStates.States.MENU: UpdateScore(0); GameOverGUI.guiText.enabled = false; StartMsgGUI.guiText.enabled = true; StartMsgGUI.text = StartGUIText; break; case GameStates.States.PLAYING: GameOverGUI.guiText.enabled = false; StartMsgGUI.guiText.enabled = false; break; case GameStates.States.GAME_OVER: GameOverGUI.guiText.enabled = true; StartMsgGUI.guiText.enabled = true; StartMsgGUI.text = RestartGUIText; break; default: break; } }
public static void ChangeState(GameStates.States state) //Use of a Static Function (called in TitleScreen.cs) { GameStates.currentState = state; switch (GameStates.currentState) //Switch Statement #2 { case GameStates.States.OpenMenu: print("Opening Menu"); // player.SetActive (true); // widgets.SetActive (false); // title.SetActive (true); // coins.SetActive (true); // powerUps.SetActive (true); // movement.enabled = false; break; case GameStates.States.CloseMenu: print("Closing Menu"); // title.SetActive (false); break; case GameStates.States.StartGame: print("Starting Game"); // player.SetActive (true); // widgets.SetActive (true); // coins.SetActive (true); // powerUps.SetActive (true); // movement.enabled = true; break; } }
void GameOver() { // Update state CurrentState = GameStates.States.GAME_OVER; // Show the game over and restart message hud.UpdateMessages(CurrentState); // Play dying sound audio.Play(); }
// Execute when changing game states #region States void MainMenu() { // Update state CurrentState = GameStates.States.MENU; // Reset the score from the previous play session score = 0; // Remove blocks from previous play sessions blockController.RemoveAllBlocks(); // Show the start up message hud.UpdateMessages(CurrentState); }
void StartGame() { // Update state CurrentState = GameStates.States.PLAYING; // Spawn the player GameObject playerInstance = Instantiate(PlayerPrefab, Vector2.one, Quaternion.identity) as GameObject; playerController = playerInstance.GetComponent <PlayerController>(); playerController.SetHUD(hud); // Start counting the score StartCoroutine(BuildScore()); // Reset the wave spawner timer blockController.Restart(); // Remove the start message hud.UpdateMessages(CurrentState); // Play ok sound effect MenuConfirmSound.Play(); }
public void ChangeState(GameStates.States state) { GameState = state; }
public void SetState(GameStates.States newState) { gameState.CurrentState = newState; }