using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.Assertions; using UnityEngine.UI; namespace TON { public class IngameUI : UIBase { public static IngameUI Instance => UIManager.Singleton.GetUI(UIList.IngameUI); public Image characterImage; public Image hpBar; public Image spBar; public TextMeshProUGUI stageText; public TextMeshProUGUI monsterHp; public Image monsterHpBar; public Image monsterImage; private float currentHP; private float maxHP; private float currentSP; private float maxSP; private string playerType; private void OnEnable() { // UI가 활성화될 때 저장된 값들로 업데이트 RefreshUI(); } public void SetHP(float current, float max) { currentHP = current; maxHP = max; if (gameObject.activeInHierarchy) { hpBar.fillAmount = current / max; } } public void SetSP(float current, float max) { currentSP = current; maxSP = max; if (gameObject.activeInHierarchy) { spBar.fillAmount = current / max; } } public void SetPlayerImage(string type) { playerType = type; if (gameObject.activeInHierarchy) { UpdatePlayerImage(); } } private void RefreshUI() { if (maxHP > 0) SetHP(currentHP, maxHP); if (maxSP > 0) SetSP(currentSP, maxSP); if (!string.IsNullOrEmpty(playerType)) UpdatePlayerImage(); } private void UpdatePlayerImage() { if (AssetManager.Singleton.LoadPlayerIcon(playerType, FaceStatue.Idle, out Sprite result)) { characterImage.sprite = result; } } } }