60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Ashwild.Settings;
|
|
|
|
namespace Ashwild.UI
|
|
{
|
|
/// <summary>
|
|
/// The in-game pause menu, now a regular panel driven by <see cref="GameUIManager"/>. Wires its
|
|
/// buttons to the game manager (resume / invite / quit) and to the shared settings panel. Every
|
|
/// button is optional — leave a reference empty to omit it.
|
|
/// </summary>
|
|
public class PausePanel : UIPanel
|
|
{
|
|
#region Panel Kind
|
|
|
|
/// <summary>
|
|
/// The pause menu freezes the game while open.
|
|
/// </summary>
|
|
public override PanelKind Kind => PanelKind.Pause;
|
|
|
|
#endregion
|
|
|
|
#region Serialized Fields
|
|
|
|
[Header("Buttons")]
|
|
[SerializeField] private Button resumeButton;
|
|
[SerializeField] private Button settingsButton;
|
|
[SerializeField] private Button inviteButton;
|
|
[SerializeField] private Button quitButton;
|
|
|
|
#endregion
|
|
|
|
#region State
|
|
|
|
/// <summary>
|
|
/// The active game manager (the shared Instance is always a GameUIManager in gameplay).
|
|
/// </summary>
|
|
private GameUIManager Game => UIManager.Instance as GameUIManager;
|
|
|
|
#endregion
|
|
|
|
#region Unity Lifecycle
|
|
|
|
/// <summary>
|
|
/// Wires the buttons; runs once.
|
|
/// </summary>
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
if (resumeButton != null) resumeButton.onClick.AddListener(() => Game?.Resume());
|
|
if (inviteButton != null) inviteButton.onClick.AddListener(() => Game?.InviteFriend());
|
|
if (quitButton != null) quitButton.onClick.AddListener(() => Game?.QuitToMenu());
|
|
if (settingsButton != null) settingsButton.onClick.AddListener(() => UIManager.Instance.OpenPanel<SettingsPanel>());
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|