2025-08-27 21:08:17 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class ScoreSynchronizer : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private bool IsPlayer = true;
|
|
|
|
|
|
|
|
|
|
private TMPro.TextMeshProUGUI tmp;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
tmp = this.GetComponent<TMPro.TextMeshProUGUI>();
|
|
|
|
|
|
|
|
|
|
if (GameManager.Instance != null)
|
|
|
|
|
{
|
|
|
|
|
GameManager.Event.RegistEvent(EEventType.OnInitializeGame, this.OnInitializeGame);
|
|
|
|
|
GameManager.Event.RegistEvent(EEventType.OnSynchronizeScore, this.OnSynchronizeScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
if (GameManager.Instance != null)
|
|
|
|
|
{
|
|
|
|
|
GameManager.Event.RemoveEvent(EEventType.OnInitializeGame, this.OnInitializeGame);
|
|
|
|
|
GameManager.Event.RemoveEvent(EEventType.OnSynchronizeScore, this.OnSynchronizeScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnInitializeGame()
|
|
|
|
|
{
|
2025-09-01 03:29:18 +00:00
|
|
|
tmp.text = "<color=#DC3D40>00</color>점";
|
2025-08-27 21:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSynchronizeScore()
|
|
|
|
|
{
|
2025-09-01 03:29:18 +00:00
|
|
|
tmp.text = $"<color=#DC3D40>{GamePanel.Instance.GetTotalScore(IsPlayer, false)}</color> 점";
|
2025-08-27 21:08:17 +00:00
|
|
|
}
|
|
|
|
|
}
|