少年修仙传客户端代码仓库
client_linchunjie
2018-09-19 9203f8bd22b3cf3fa9bfd537fd16b2e86d7223b1
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
using UnityEngine;
using UnityEngine.UI;
using TableConfig;
using System.Collections.Generic;
 
namespace Snxxz.UI
{
    public class XBItemCell : MonoBehaviour
    {
        [SerializeField] CommonItemBaisc itemCell;
        [SerializeField] GameObject selectIcon;
        [SerializeField] Text nameText;
 
        ItemTipsModel itemTips { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
        int xbIndex = 0;
 
        public void SetModel(int itemId,int count,int index)
        {
            this.xbIndex = index;
            ItemCellModel cellModel = new ItemCellModel(itemId,true,(ulong)count);
            itemCell.Init(cellModel);
            ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(itemId);
            if(itemConfig != null)
            {
                nameText.text = itemConfig.ItemName;
                nameText.color = UIHelper.GetUIColor(itemConfig.ItemColor,false);
            }
            itemCell.cellBtn.RemoveAllListeners();
            itemCell.cellBtn.AddListener(()=>
            {
                ItemAttrData attrData = new ItemAttrData(itemId,true,(ulong)count);
                itemTips.SetItemTipsModel(attrData);
            });
            selectIcon.SetActive(false);
        }
 
        public void RefreshSelectIcon(int curSelect)
        {
            if(curSelect == xbIndex)
            {
                selectIcon.SetActive(true);
            }
            else
            {
                selectIcon.SetActive(false);
            }
        }
    }
}