using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class JadeDynastyItemBeh : MonoBehaviour
|
{
|
[SerializeField] ItemCell itemCell;
|
[SerializeField] Button lockBtn;
|
[SerializeField] UIEffect effect;
|
[SerializeField] GameObject equipLvObj;
|
[SerializeField] Text equipLvText;
|
|
ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
|
PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
JadeDynastyEquipModel equipModel { get { return ModelCenter.Instance.GetModel<JadeDynastyEquipModel>(); } }
|
|
public void SetDisplay(int index)
|
{
|
var singlePack = playerPack.GetSinglePackModel(PackType.rptJadeDynastyItem);
|
if (singlePack == null) return;
|
|
var itemModel = playerPack.GetItemModelByIndex(PackType.rptJadeDynastyItem, index);
|
itemCell.gameObject.SetActive(itemModel != null);
|
|
if(itemModel != null)
|
{
|
lockBtn.gameObject.SetActive(false);
|
itemCell.Init(itemModel,true);
|
if (itemModel.EquipPlace > 0)
|
{
|
equipLvObj.SetActive(true);
|
string equipLvSB = Language.Get(StringUtility.Contact("Num_CHS_", itemModel.chinItemModel.LV));
|
equipLvText.text = Language.Get("L1091", equipLvSB);
|
}
|
|
itemCell.cellBtn.RemoveAllListeners();
|
itemCell.cellBtn.AddListener(()=>
|
{
|
equipModel.ClearLookItemModel();
|
tipsModel.SetItemTipsModel(itemModel.packType,itemModel.itemInfo.ItemGUID,false,true);
|
tipsModel.SetJadeDynastyItemTipsBtn(tipsModel.curAttrData);
|
tipsModel.ShowUICtrl();
|
});
|
UpdatePlayerEffect(itemModel.itemInfo.ItemGUID);
|
}
|
else
|
{
|
equipLvObj.SetActive(false);
|
bool isLock = index > (singlePack.openGridCount - 1);
|
lockBtn.gameObject.SetActive(isLock);
|
UpdatePlayerEffect(null);
|
}
|
}
|
|
private void UpdatePlayerEffect(string guid)
|
{
|
if (effect == null) return;
|
|
if(string.IsNullOrEmpty(guid))
|
{
|
if(effect.IsPlaying)
|
{
|
effect.Stop();
|
}
|
}
|
else
|
{
|
if(guid == equipModel.lookGuid)
|
{
|
if (!effect.IsPlaying)
|
{
|
effect.Play();
|
}
|
}
|
}
|
}
|
}
|
}
|