using UnityEngine;
|
using UnityEngine.EventSystems;
|
using UnityEngine.UI;
|
|
|
namespace vnxbqy.UI
|
{
|
public class PoolItemCell : MonoBehaviour,IDragHandler
|
{
|
[SerializeField] CommonItemBaisc itemBaisc;
|
[SerializeField] Image bestIcon;
|
[SerializeField] Text nameText;
|
|
WishingPoolModel wishingModel { get { return ModelCenter.Instance.GetModel<WishingPoolModel>(); } }
|
int index = -1;
|
|
public void OnDrag(PointerEventData eventData)
|
{
|
wishingModel.isDraging = true;
|
wishingModel.dragIndex = index;
|
}
|
|
public void Display(int index)
|
{
|
this.index = index;
|
WishingPoolModel.WishingWellItem wellItem = null;
|
bool isPoolData = wishingModel.TryGetPoolDataByIndex(index,out wellItem);
|
ItemConfig itemConfig = ItemConfig.Get(wellItem.itemId);
|
nameText.text = itemConfig.ItemName;
|
nameText.color = UIHelper.GetUIColor(itemConfig.ItemColor);
|
string rareIconKey = string.Empty;
|
bool isRare = wishingModel.TryGetItemRareIcon(wellItem.rare,out rareIconKey);
|
bestIcon.SetActive(isRare);
|
if(isRare)
|
{
|
bestIcon.SetSprite(rareIconKey);
|
}
|
ItemCellModel cellModel = new ItemCellModel(wellItem.itemId,false,(ulong)wellItem.itemCount);
|
itemBaisc.Init(cellModel);
|
itemBaisc.button.RemoveAllListeners();
|
itemBaisc.button.AddListener(()=>
|
{
|
ItemTipUtility.Show(wellItem.itemId);
|
});
|
}
|
|
}
|
}
|