using UnityEngine;
|
using UnityEngine.UI;
|
|
|
//拥有的物品:数量显示,点击按钮显示途径tip
|
public class OwnItemCell : MonoBehaviour
|
{
|
[SerializeField] Image itemIcon;
|
[SerializeField] Text numText;
|
[SerializeField] Button wayBtn;
|
public int itemID;
|
|
void Start()
|
{
|
if (itemID != 0)
|
itemIcon.SetOrgSprite(ItemConfig.Get(itemID).IconKey);
|
|
wayBtn.AddListener(()=>
|
{
|
ItemTipUtility.Show(itemID, true);
|
});
|
}
|
void OnEnable()
|
{
|
PackManager.Instance.RefreshItemEvent += RefreshItemEvent;
|
Display();
|
}
|
|
void OnDisable()
|
{
|
PackManager.Instance.RefreshItemEvent -= RefreshItemEvent;
|
}
|
|
public void RefreshItemEvent(PackType packType, int index, int itemID)
|
{
|
if (packType != PackType.Item && this.itemID != itemID)
|
{
|
return;
|
}
|
|
Display();
|
}
|
|
|
public void Display(bool resetIcon = false)
|
{
|
if (itemID == 0)
|
{
|
Debug.LogError("itemID == 0");
|
return;
|
}
|
numText.text = UIHelper.ReplaceLargeNum(PackManager.Instance.GetItemCountByID(PackType.Item, itemID));
|
if (resetIcon)
|
{
|
itemIcon.SetOrgSprite(ItemConfig.Get(itemID).IconKey);
|
}
|
}
|
}
|