65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
/*
|
|
* author: mark joshwel
|
|
* date: 28/6/2024
|
|
* description: script for handling pause menu button functions
|
|
*/
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
/// <summary>
|
|
/// class managing the credits menu and button function invocations
|
|
/// </summary>
|
|
public class PauseMenu : CommonMenu
|
|
{
|
|
/// <summary>
|
|
/// button to exit the game
|
|
/// </summary>
|
|
public Button ButtonExit;
|
|
|
|
/// <summary>
|
|
/// button to resume the game
|
|
/// </summary>
|
|
public Button ButtonResume;
|
|
|
|
/// <summary>
|
|
/// function to associate a display state with the menu,
|
|
/// and subscribe button events to their respective functions
|
|
/// </summary>
|
|
public override void OnEnable()
|
|
{
|
|
// set the associated state and call the base OnEnable
|
|
associatedState = GameManager.DisplayState.ScreenPauseMenu;
|
|
base.OnEnable();
|
|
|
|
// get the resume button from the ui root and subscribe appropriate functions
|
|
ButtonResume = UI.Q<Button>("ButtonResume");
|
|
ButtonResume.clicked += PlayClick;
|
|
ButtonResume.clicked += OptionResumeGame;
|
|
|
|
// get the exit button from the ui root and subscribe appropriate functions
|
|
ButtonExit = UI.Q<Button>("ButtonExit");
|
|
ButtonExit.clicked += PlayClick;
|
|
ButtonExit.clicked += OptionQuitGame;
|
|
}
|
|
|
|
/// <summary>
|
|
/// handles "resume game" button press,
|
|
/// signals the game manager appropriately
|
|
/// </summary>
|
|
private void OptionResumeGame()
|
|
{
|
|
Debug.Log("PauseMenu.OptionResumeGame: resuming");
|
|
Game.SetDisplayState(GameManager.DisplayState.Game);
|
|
}
|
|
|
|
/// <summary>
|
|
/// handles "exit game" button press,
|
|
/// signals the game manager appropriately
|
|
/// </summary>
|
|
private void OptionQuitGame()
|
|
{
|
|
Debug.Log("CaughtEscapedMenu.OptionQuitGame: exiting");
|
|
GameManager.Instance.Quit();
|
|
}
|
|
} |