少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 f1f2599ba0e6b64358ffef7ae5c9f9af3ed8b8b4
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
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
 
namespace Snxxz.UI
{
    public class RecycleDrugCell : MonoBehaviour
    {
        [SerializeField] ItemCell itemCell;
        [SerializeField] GameObject selectImg;
        BlastFurnaceModel blastFurnace { get { return ModelCenter.Instance.GetModel<BlastFurnaceModel>(); } }
 
        public void SetDisplayModel(List<ItemModel> list)
        {
            if(list == null || list.Count < 1)
            {
                itemCell.gameObject.SetActive(false);
                selectImg.SetActive(false);
            }
            else
            {
                itemCell.gameObject.SetActive(true);
                ItemModel itemModel = list[0];
                string key = itemModel.itemId.ToString();
                if (blastFurnace.recycleStrlist.Contains(key))
                {
                    selectImg.SetActive(true);
                }
                else
                {
                    selectImg.SetActive(false);
                }
                int itemCount = 0;
                for(int i = 0; i < list.Count; i++)
                {
                    itemCount += list[i].count;
                }
                ItemCellModel cellModel = new ItemCellModel(itemModel.itemId,false,(ulong)itemCount);
                itemCell.Init(cellModel);
                itemCell.button.RemoveAllListeners();
                itemCell.button.AddListener(() =>
                {
                    if (selectImg.activeInHierarchy)
                    {
                        selectImg.SetActive(false);
                        blastFurnace.RemoveSelectRecycleDan(itemModel);
                    }
                    else
                    {
                        selectImg.SetActive(true);
                        blastFurnace.AddSelectRecycleDan(itemModel);
                    }
                });
            }
        }
    }
}