void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { // If user presses ESC, show the pause menu if (pause == false) { pauseMenu.ShowPause(); pause = true; } else { pauseMenu.Hide(); pause = false; } } if (player == null) { SceneManager.LoadScene(sceneName); } // If the player presses the p key, restart the level if (Input.GetButtonDown("Restart")) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }
// Update is called once per frame void Update() { /* if(gameOver) * { * pauseMenu.ShowGameover(); * } */ /* else */ if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.P)) { pauseMenu.ShowPause(); } }
public void OpenPauseMenu() { pauseMenu.ShowPause(); }
void Update() { if (playerScript.slot[0] != null) { Slot1Text.text = playerScript.slot[0].name.Substring(0, playerScript.slot[0].name.Length - 7).ToUpper(); Slot1Image.sprite = WeaponSprites[(int)playerScript.slot1type]; Slot1Ammo.text = playerScript.slot[0].GetComponent <Weapon>().ammo + "/" + playerScript.slot[0].GetComponent <Weapon>().maxAmmo; for (int i = 0; i < playerScript.slot[0].GetComponent <Weapon>().stars; i++) { Slot1Stars[i].enabled = true; } } if (playerScript.slot[1] != null) { Slot2Text.text = playerScript.slot[1].name.Substring(0, playerScript.slot[1].name.Length - 7).ToUpper(); Slot2Image.sprite = WeaponSprites[(int)playerScript.slot2type]; Slot2Ammo.text = playerScript.slot[1].GetComponent <Weapon>().ammo + "/" + playerScript.slot[1].GetComponent <Weapon>().maxAmmo; for (int i = 0; i < playerScript.slot[1].GetComponent <Weapon>().stars; i++) { Slot2Stars[i].enabled = true; } } PistolImage.sprite = WeaponSprites[(int)playerScript.slot3type]; if (player != null) { PistolName.text = playerScript.slot[2].name.Substring(0, playerScript.slot[2].name.Length - 7).ToUpper(); } GrenadeCount.text = playerScript.grenadeCount.ToString(); if (playerScript.slotActive == 0) { Slot1Active.enabled = true; Slot2Active.enabled = false; Slot3Active.enabled = false; } else if (playerScript.slotActive == 1) { Slot2Active.enabled = true; Slot1Active.enabled = false; Slot3Active.enabled = false; } else { Slot3Active.enabled = true; Slot1Active.enabled = false; Slot2Active.enabled = false; } if (inBossFight) { bossScript = levelBoss.GetComponent <Enemy>(); bossHealth = bossScript.health; bossHealth = Mathf.MoveTowards(bossHealth, bossScript.health, 60 * Time.deltaTime); HUDBossHealth.value = bossHealth; } if (arenaMode) { waveNumberText.text = "WAVE: " + waveMaster.currentWave; if (waveMaster.betweenWaves) { float timeLeft = waveMaster.timeToNewWave - waveMaster.timer; betweenWaveText.enabled = true; betweenWaveText.text = "NEXT WAVE IN: " + timeLeft.ToString("0.0"); } else { betweenWaveText.enabled = false; } if (arenaTrikeAlive) { arenaTrikeHealthObject.SetActive(true); arenaTrikeHealth.value = arenaTrikeInstance.GetComponent <Enemy>().health; } else { arenaTrikeHealthObject.SetActive(false); } if (arenaTrexAlive) { arenaTrexHealthObject.SetActive(true); arenaTrexHealth.value = arenaTrexInstance.GetComponent <Enemy>().health; } else { arenaTrexHealthObject.SetActive(false); } } // Display health - but rather than doing it in one go, change the value // gradually (over certain period of time) health = Mathf.MoveTowards(health, playerScript.health, 60 * Time.deltaTime); HUDHealth.value = health; if (playerScript.gameOver) { // If gameover state detected, show the pause menu in gameover mode gameOver.GameOver(); } else if (Input.GetKeyDown(KeyCode.Escape)) { // If user presses ESC, show the pause menu in pause mode if (pauseMenu.isPaused) { pauseMenu.Resume(); } else { pauseMenu.ShowPause(); } } }