using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; namespace BrewMonster { public enum IconTaskType { QI_NONE = -1, QI_OUT = 0, // task tu chan (nhan) QI_IN = 1, // task tu chan (hoan thanh) QI_OUT_N = 2, // chua du dieu kien nhan task QI_IN_N = 3, // task nhan nhung chua lam (chua xong) QI_OUT_K = 4, // chua biet QI_IN_K = 5, // chua biet QI_OUT_TYPE1 = 6, // task bang hoi (nhan) QI_IN_TYPE1 = 7, // task bang hoi (hoan thanh) QI_OUT_TYPE2 = 8, // chua biet QI_IN_TYPE2 = 9, // chua biet QI_OUT_TYPE3 = 10, // task daily (nhan) QI_IN_TYPE3 = 11, // task daily (hoan thanh) QI_OUT_TYPE4 = 12, // task chinh (nhan) QI_IN_TYPE4 = 13, // task chinh (hoan thanh) } public class UINPC : MonoBehaviour { [SerializeField] private TextMeshProUGUI _nameText; [SerializeField] private TextMeshProUGUI _healthText; [SerializeField] private Image _healthImage; [Header("List Icon Task")] [SerializeField] private GameObject _iconTaskMain; [SerializeField] private List _listIconTask; private Image _cachedIconImage; private void Awake() { if (_iconTaskMain != null) { _cachedIconImage = _iconTaskMain.GetComponent(); if (_cachedIconImage == null) { BMLogger.LogError($"[UINPC] _iconTaskMain doesn't have Image component!"); } } } // Start is called once before the first execution of Update after the MonoBehaviour is created public void SetName(string name) { _nameText.text = name; } public void SetHealthImage(float health) { if(_healthImage != null) _healthImage.fillAmount = health; } public void SetHealthText(string healthText) { if(_healthText != null) _healthText.text = healthText; } public void SetTaskIcon(IconTaskType iconType) { if (_iconTaskMain == null || _cachedIconImage == null) { return; } int iconIndex = (int)iconType; if (iconIndex >= 0 && _listIconTask != null && iconIndex < _listIconTask.Count) { _cachedIconImage.sprite = _listIconTask[iconIndex]; _iconTaskMain.SetActive(true); } else { _iconTaskMain.SetActive(false); } } public void SetTaskIconMain(bool isShow) { if (_iconTaskMain != null) _iconTaskMain.SetActive(isShow); } } }