using BrewMonster; using CSNetwork.Protocols.RPCData; using System; using System.Text; using BrewMonster.Network; using TMPro; using UnityEngine; using UnityEngine.UI; public class CharacterItemUI : MonoBehaviour { [SerializeField] private Button btnClick; [SerializeField] private TextMeshProUGUI nameCharacter; [SerializeField] private TextMeshProUGUI _labelDetailInfo; [SerializeField] private GameObject _goFocusImage; RoleInfo dataItem; public RoleInfo RoleInfo => dataItem; Action onClick; private void OnEnable() { _goFocusImage.SetActive(false); } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { btnClick.onClick.AddListener(OnClickBtn); } public void InitItem(RoleInfo role, Action action) { dataItem = role; onClick = action; string roleName = "(Error decoding name)"; if (role.name != null && role.name.ByteArray != null) { // Be careful with encoding, assume UTF8 is correct roleName = Encoding.Unicode.GetString( role.name.RawBuffer, 0, role.name.Length ); } nameCharacter.text = roleName; if (EC_Game.GetGameRun() != null) { _labelDetailInfo.text =$"{EC_Game.GetGameRun().GetProfName(role.occupation)} Cấp {role.level.ToString()}"; } else { BMLogger.LogError("No game run found"); } } public void OnClickBtn() { onClick?.Invoke(this); } public void SetFocus(bool focus) { _goFocusImage.SetActive(focus); } }