Files
2026-03-25 10:31:24 +07:00

69 lines
1.5 KiB
C#

using UnityEngine;
using UnityEngine.UI;
namespace BrewMonster
{
public class PopupManager : MonoBehaviour
{
public static PopupManager Instance { get; private set; }
private static bool s_shouldShowRevivePopup;
[SerializeField] private GameObject ReviveOptionPopup;
private void Awake()
{
if (Instance == null)
{
Instance = this;
ApplyRevivePopupState();
}
else
{
Destroy(gameObject);
}
}
private void OnDestroy()
{
if (Instance == this)
{
Instance = null;
}
}
public void OnPlayerDied()
{
s_shouldShowRevivePopup = true;
ApplyRevivePopupState();
}
public void OnPlayerRevived()
{
s_shouldShowRevivePopup = false;
ApplyRevivePopupState();
}
private void ApplyRevivePopupState()
{
if (ReviveOptionPopup == null)
{
return;
}
ReviveOptionPopup.SetActive(s_shouldShowRevivePopup);
}
public static void NotifyPlayerDied()
{
s_shouldShowRevivePopup = true;
Instance?.ApplyRevivePopupState();
}
public static void NotifyPlayerRevived()
{
s_shouldShowRevivePopup = false;
Instance?.ApplyRevivePopupState();
}
}
}