using TMPro; using UnityEngine; using UnityEngine.UI; using BrewMonster.Network; using CSNetwork.GPDataType; namespace BrewMonster { public class HUDNPC : MonoBehaviour { [SerializeField] private Button _NPCIconBtn; [SerializeField] private TextMeshProUGUI _healthText; [SerializeField] private TextMeshProUGUI _nameText; [SerializeField] private TextMeshProUGUI _statText; [SerializeField] private Image healthImage; private void OnEnable() { if (_NPCIconBtn != null) { _NPCIconBtn.onClick.AddListener(OnNPCIconBtnClick); } } private void OnDisable() { if (_NPCIconBtn != null) { _NPCIconBtn.onClick.RemoveListener(OnNPCIconBtnClick); } } private void OnNPCIconBtnClick() { var host = EC_Game.GetGameRun()?.GetHostPlayer(); if (host == null) return; int id = host.GetSelectedTarget(); if (id == 0 || id == host.GetCharacterID() || !GPDataTypeHelper.ISPLAYERID(id)) return; CECUIManager.Instance?.ShowPlayerOptionsDialog(id, _NPCIconBtn.transform.position); } public void SetText(string healthText, string nameText, string statText) { _healthText.text = healthText; _nameText.text = nameText; _statText.text = statText; } public void SetHealthImage(float health) { healthImage.fillAmount = health; } } }