fix di chuyen update maze ui update map
This commit is contained in:
51
Assets/Scripts/UI/MazeUI.cs
Normal file
51
Assets/Scripts/UI/MazeUI.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
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 = $"<color=yellow>{playerName}</color>\nREACHED THE GOAL!\n<size=80%>IN {time:F2} SECONDS</size>";
|
||||
}
|
||||
|
||||
// Tự động ẩn sau 5 giây
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(HideWinPanel());
|
||||
}
|
||||
|
||||
private IEnumerator HideWinPanel()
|
||||
{
|
||||
yield return new WaitForSeconds(5f);
|
||||
winPanel.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user