少年修仙传客户端代码仓库
client_linchunjie
2018-09-19 aecb6a5a62d8a4cfc7b924ce957a9c7ea90c235d
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
59
60
61
62
63
64
65
66
67
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class TreasureSoulPattern3 : TreasureSoulPattern
    {
        [SerializeField] RareItem[] m_Items;
        [SerializeField] Button m_Get;
        [SerializeField] Text m_GetText;
 
        private void Awake()
        {
            m_Get.onClick.AddListener(OnGet);
        }
 
        public override void Display(int _id)
        {
            base.Display(_id);
            Display();
        }
 
        public override void Dispose()
        {
            base.Dispose();
        }
 
        protected override void TreasurePrivilegeUpdateEvent(int _id)
        {
            base.TreasurePrivilegeUpdateEvent(_id);
            if (_id == (int)special.type)
            {
                Display();
            }
        }
 
        private void Display()
        {
            for (int i = 0; i < m_Items.Length; i++)
            {
                m_Items[i].gameObject.SetActive(special.items != null && i < special.items.Count);
                m_Items[i].cellBtn.RemoveAllListeners();
                if (special.items != null && i < special.items.Count)
                {
                    var award = special.items[i];
                    ItemCellModel cellModel = new ItemCellModel(award.item.id, true, (ulong)award.item.count, award.isBind);
                    m_Items[i].Init(cellModel);
                    m_Items[i].cellBtn.AddListener(() =>
                    {
                        ItemAttrData attrData = new ItemAttrData(award.item.id, true, (ulong)award.item.count, -1, award.isBind);
                        ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(attrData);
                    });
                }
            }
            m_Get.SetInteractable(m_GetText, special.state == TreasurePrivilegeState.Reward);
        }
 
        private void OnGet()
        {
            special.GetReward();
        }
    }
}