34 lines
770 B
C#
34 lines
770 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class HeartSynchronizer : MonoBehaviour
|
||
|
|
{
|
||
|
|
private TMPro.TextMeshProUGUI tmp;
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
tmp = this.GetComponent<TMPro.TextMeshProUGUI>();
|
||
|
|
|
||
|
|
if (GameManager.Instance != null)
|
||
|
|
{
|
||
|
|
GameManager.Event.RegistEvent(EEventType.OnSynchronizeHeart, this.OnSynchronizeHeart);
|
||
|
|
}
|
||
|
|
|
||
|
|
this.OnSynchronizeHeart();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnDestroy()
|
||
|
|
{
|
||
|
|
if (GameManager.Instance != null)
|
||
|
|
{
|
||
|
|
GameManager.Event.RemoveEvent(EEventType.OnSynchronizeHeart, this.OnSynchronizeHeart);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnSynchronizeHeart()
|
||
|
|
{
|
||
|
|
tmp.text = GameManager.DB.Heart.ToString();
|
||
|
|
}
|
||
|
|
}
|