yyl
2 天以前 973edc44a04dceb8b48a32ca912e6167f86189d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
        }
    }
}