Project_WL/Assets/WL/UI/Scripts/CurrencyHud.cs

39 lines
1.4 KiB
C#

using UnityEngine;
using UnityEngine.UI;
namespace WL.UI
{
/// <summary>
/// 우상단 재화 표시 3종 — 골드 · 캐시 · 특수 재화 (PD #729 · 레퍼런스 XP Hero 탑바).
/// 아직 재화 시스템이 없어 값은 0 으로 시작하고, 나중에 지갑 시스템이 SetValues 로 갱신한다.
/// 표기 형식은 PlayerLevelHud.Format(1,000 이상 K · 1,000,000 이상 M)과 같다.
/// </summary>
public class CurrencyHud : MonoBehaviour
{
[Header("참조")]
[SerializeField] private Text goldText;
[SerializeField] private Text cashText;
[SerializeField] private Text specialText;
public long Gold { get; private set; }
public long Cash { get; private set; }
public long Special { get; private set; }
private void Start() { Refresh(); }
/// <summary>세 재화 값을 한 번에 갱신한다.</summary>
public void SetValues(long gold, long cash, long special)
{
Gold = gold; Cash = cash; Special = special;
Refresh();
}
public void Refresh()
{
if (goldText != null) goldText.text = PlayerLevelHud.Format(Gold);
if (cashText != null) cashText.text = PlayerLevelHud.Format(Cash);
if (specialText != null) specialText.text = PlayerLevelHud.Format(Special);
}
}
}