sea-battle/Assets/Scripts/UI/Panels/BattlePausePanel.cs

37 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Панель бездействия во время боя.
/// Появляется через 45 секунд без активности игрока.
/// UIPanelId.id на объекте в сцене должен быть "BattlePause".
/// Навигация по кнопкам — через PlayerCursorUI (InputMode.UI).
/// </summary>
public class BattlePausePanel : MonoBehaviour
{
[SerializeField] private GameManager gameManager;
[SerializeField] private Button resumeButton;
[SerializeField] private Button exitButton;
private void Awake()
{
if (resumeButton != null) resumeButton.onClick.AddListener(OnResume);
if (exitButton != null) exitButton.onClick.AddListener(OnExit);
}
private void OnResume()
{
if (gameManager == null) return;
gameManager.HideBattlePause();
}
private void OnExit()
{
if (gameManager == null) return;
gameManager.HideBattlePause();
// endGame = true — кредиты НЕ возвращаются:
// игрок уже находился в бою, пауза сработала по бездействию
gameManager.MenuGame(true);
}
}