//Called, when the playe clicks on the pause button public void PauseButton() { if (!canPause) { return; } canPause = false; pauseMenuAnimator.gameObject.SetActive(true); //If the game is paused if (pauseMenuAnimator.GetBool("Visible") == true) { pauseButton.SetActive(true); //Hide the pause menu, and activate the main UI overlayAnimator.SetBool("Visible", false); pauseMenuAnimator.SetBool("Visible", false); mainUI.gameObject.SetActive(true); //Show the available powerups int[] powerupCount = new int[] { SaveManager.extraSpeed, SaveManager.shield, SaveManager.sonicWave }; for (int i = 0; i < powerupCount.Length; i++) { if (powerupCount [i] > 0) { powerupButtons [i].SetBool("Visible", true); } } //Resume the game levelManager.ResumeLevel(); StartCoroutine(DisableMenu(pauseMenuAnimator, 1)); } //If the game is not paused, and can be paused else if (powerupManager.CanUsePowerup()) { pauseButton.SetActive(false); // Show the pause menu, and disable the main UI overlayAnimator.SetBool("Visible", true); pauseMenuAnimator.SetBool("Visible", true); mainUI.gameObject.SetActive(false); //Update pause menu mission texts string[] missionTexts = missionManager.GetMissionTexts(); string[] missionStats = missionManager.GetMissionStats(); for (int i = 3; i < 6; i++) { missionPanelElements [i].Find("Mission Text").GetComponent <Text> ().text = missionTexts [i - 3]; missionPanelElements [i].Find("Status Text").GetComponent <Text> ().text = missionStats [i - 3]; } //Pause the game levelManager.PauseLevel(); } StartCoroutine("EnablePause"); }
//Called, when the playe clicks on the pause button public void PauseButton() { pauseMenuAnimator.gameObject.SetActive(true); //If the game is paused if (pauseMenuAnimator.GetBool("Visible") == true) { //Hide the pause menu, and activate the main UI overlayAnimator.SetBool("Visible", false); pauseMenuAnimator.SetBool("Visible", false); mainUI.gameObject.SetActive(true); //Show the available powerups ShowAvailablePowerups(); //Resume the game levelManager.ResumeLevel(); StartCoroutine(DisableMenu(pauseMenuAnimator, 0.2f)); } //If the game is not paused, and can be paused else if (powerupManager.CanUsePowerup()) { // Show the pause menu, and disable the main UI overlayAnimator.SetBool("Visible", true); pauseMenuAnimator.SetBool("Visible", true); mainUI.gameObject.SetActive(false); //Update pause menu mission texts string[] missionTexts = missionManager.GetMissionTexts(); string[] missionStats = missionManager.GetMissionStats(); for (int i = 3; i < 6; i++) { missionPanelElements[i].Find("Mission Text").GetComponent <Text>().text = missionTexts[i - 3]; missionPanelElements[i].Find("Status Text").GetComponent <Text>().text = missionStats[i - 3]; } //Pause the game levelManager.PauseLevel(); } }