using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class EquipPlaceCell : MonoBehaviour { [SerializeField] Button m_AddEquip; [SerializeField] ItemCell m_ItemCell; PackModel packModel { get { return ModelCenter.Instance.GetModel(); } } RoleEquipType equipType; public void Display(RoleEquipType equipType) { this.equipType = equipType; var packIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)equipType)); var item = packModel.GetItemByIndex(PackType.Equip, packIndex); if (item == null) { m_ItemCell.SetActive(false); m_AddEquip.SetActive(true); m_AddEquip.SetListener(AddEqup); } else { m_AddEquip.SetActive(false); m_ItemCell.SetActive(true); m_ItemCell.Init(item); m_ItemCell.button.SetListener(ShowEquipTip); } } private void AddEqup() { var packIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)equipType)); var item = packModel.GetItemByIndex(PackType.Equip, packIndex); if (item != null) { return; } var guid = ItemLogicUtility.Instance.GetHighestScoreEquipByPlace((int)equipType); if (string.IsNullOrEmpty(guid)) { int pathId = packModel.GetRoleEquipPathId((int)equipType); if (pathId != 0) { ItemTipUtility.Show(pathId); } } else { ItemTipUtility.Show(guid); } } private void ShowEquipTip() { var packIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)equipType)); var item = packModel.GetItemByIndex(PackType.Equip, packIndex); if (item == null) { return; } ItemTipUtility.Show(item.guid); } } }