using UnityEngine;
using TMPro;
using System.Collections;
namespace OnlyScove.Scripts.UI
{
public class MazeUI : MonoBehaviour
{
public static MazeUI Instance { get; private set; }
[Header("References")]
[SerializeField] private GameObject winPanel;
[SerializeField] private TextMeshProUGUI winMessageText;
[SerializeField] private TextMeshProUGUI timerText;
private void Awake()
{
if (Instance == null) Instance = this;
else Destroy(gameObject);
if (winPanel != null) winPanel.SetActive(false);
}
public void UpdateTimer(float time)
{
if (timerText != null)
timerText.text = $"Time: {time:F2}s";
}
public void ShowWinMessage(string playerName, float time)
{
if (winPanel == null) return;
winPanel.SetActive(true);
if (winMessageText != null)
{
winMessageText.text = $"{playerName}\nREACHED THE GOAL!\nIN {time:F2} SECONDS";
}
// Tự động ẩn sau 5 giây
StopAllCoroutines();
StartCoroutine(HideWinPanel());
}
private IEnumerator HideWinPanel()
{
yield return new WaitForSeconds(5f);
winPanel.SetActive(false);
}
}
}