using System; using SHADE; using SHADE_Scripting.Audio; public class PauseMenu : Script { public GameObject resumeBtn; public GameObject retryBtn; public GameObject quitBtn; public GameObject gamePauseText; public GameObject canvas; protected override void awake() { GameManager.Instance.GamePause = false; if (gamePauseText) gamePauseText.GetComponent().Enabled = false; if (canvas) canvas.SetActive(false); if (!resumeBtn) Debug.LogError("Resume Btn missing"); if (!retryBtn) Debug.LogError("Retry Btn missing"); if (!quitBtn) Debug.LogError("Quit Btn missing"); } protected override void start() { //resume UIElement resume = resumeBtn.GetComponent(); if (resume != null) { resume.OnClick.RegisterAction(() => { if (GameManager.Instance.GamePause) { GameManager.Instance.GamePause = false; AudioHandler.pauseAllSounds(false); if (gamePauseText) gamePauseText.GetComponent().Enabled = false; if (canvas) canvas.SetActive(false); } }); } else { Debug.LogError("Failed to register resume button."); } //retry UIElement retry = retryBtn.GetComponent(); if (retry != null) { retry.OnClick.RegisterAction(() => { Audio.StopAllSounds(); //get curr scene //SceneManager.ChangeScene(); }); } else { Debug.LogError("Failed to register retry button."); } UIElement quit = quitBtn.GetComponent(); if (quit != null) { quit.OnClick.RegisterAction(() => { Audio.StopAllSounds(); //go to main menu SceneManager.ChangeScene(97158628); }); } else { Debug.LogError("Failed to register quit button."); } } protected override void update() { if (GameManager.Instance.GamePause) { return; } if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause) { GameManager.Instance.GamePause = true; AudioHandler.pauseAllSounds(true); if (gamePauseText) gamePauseText.GetComponent().Enabled = true; if (canvas) canvas.SetActive(true); } } }