// Control paddle movement private void controlPaddleMovement() { // If the UsePaddle button is pressed, the player can use the paddle, and the game is not paused set the destination location to the nav point location if (Input.GetButtonDown("UsePaddle") && canPlayerUsePaddle == true && gameManager.isGamePaused == false) { destinationLocation = navPointLocation; } // If the UsePaddle button was let go, the player can use the paddle, and the game is not paused set the destination location to the default location else if (Input.GetButtonUp("UsePaddle") && canPlayerUsePaddle == true && gameManager.isGamePaused == false) { destinationLocation = defaultLocation; } // If the UsePaddle button was pressed, the game is not over, the game is not paused and the player cannot use the paddle then start the game if (Input.GetButtonDown("UsePaddle") && gameManager.isGameOver == false && gameManager.isGamePaused == false && canPlayerUsePaddle == false) { gameManager.didGameStart = true; // Show the main game HUD mainHUDManager.setHUDGroupVisibility(mainHUDManager.introHUDGroup, false); mainHUDManager.setHUDGroupVisibility(mainHUDManager.mainHUDGroup, true); // Enable the ball ballRef.setBallStatus(true, false, true, true); // Allow the player to use the paddle canPlayerUsePaddle = true; // Start the game timer gameManager.startGameTimer(); } }
// Pause game public void pauseGame() { isGamePaused = true; // Set the time scale to 0 Time.timeScale = 0; // If the intro HUD is open hide it if (mainHUDManager.introHUDGroup.activeSelf == true) { mainHUDManager.setHUDGroupVisibility(mainHUDManager.introHUDGroup, false); } // If the main HUD is open hide it if (mainHUDManager.mainHUDGroup.activeSelf == false) { mainHUDManager.setHUDGroupVisibility(mainHUDManager.mainHUDGroup, false); } // Show the pause menu mainHUDManager.slidePausePanelIn(); mainHUDManager.setCurrentScorePauseTextContent(playerScore.ToString()); }