using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class JadeDynastyEquipBeh : MonoBehaviour
|
{
|
[SerializeField] RoleEquipType equipType = RoleEquipType.retMax;
|
[SerializeField] GameObject lockObj;
|
[SerializeField] ItemCell itemCell;
|
[SerializeField] Text lockText;
|
[SerializeField] Text nameText;
|
[SerializeField] Button equipBtn;
|
|
ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
|
PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
|
private void OnEnable()
|
{
|
playerPack.ItemCntAddAct += PutOnEquip;
|
playerPack.ItemCntReduceAct += PutOffEquip;
|
SetDisplay();
|
}
|
|
private void OnDisable()
|
{
|
playerPack.ItemCntAddAct -= PutOnEquip;
|
playerPack.ItemCntReduceAct -= PutOffEquip;
|
}
|
|
public void SetDisplay()
|
{
|
bool islock = false;
|
int towerLayer = 1;
|
lockObj.SetActive(islock);
|
lockText.gameObject.SetActive(islock);
|
nameText.text = string.Empty;
|
nameText.gameObject.SetActive(false);
|
equipBtn.RemoveAllListeners();
|
itemCell.cellBtn.RemoveAllListeners();
|
if(islock)
|
{
|
itemCell.gameObject.SetActive(false);
|
lockText.text = StringUtility.Contact("诛仙塔/n",towerLayer,"层解锁");
|
}
|
else
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptJadeDynastyEquip,(int)equipType);
|
itemCell.gameObject.SetActive(itemModel != null);
|
if(itemModel != null)
|
{
|
itemCell.Init(itemModel);
|
itemCell.cellBtn.AddListener(() => { ClickItemCell(itemModel); });
|
}
|
}
|
}
|
|
private void PutOffEquip(PackType type, int index, int id)
|
{
|
if (type != PackType.rptJadeDynastyEquip || index != (int)equipType) return;
|
|
SetDisplay();
|
}
|
|
private void PutOnEquip(PackType type, int index, int id)
|
{
|
if (type != PackType.rptJadeDynastyEquip || index != (int)equipType) return;
|
|
SetDisplay();
|
}
|
|
|
private void ClickItemCell(ItemModel item)
|
{
|
if (item == null) return;
|
|
tipsModel.SetItemTipsModel(item.packType,item.itemInfo.ItemGUID);
|
}
|
}
|
}
|