少年修仙传客户端代码仓库
leonard Wu
2018-08-03 c2d2d5d3a840bf50968b3f95e304929bc62a7b70
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TableConfig;
using System;
 
namespace Snxxz.UI
{
    public class TrialExchangeCell : CellView
    {
        [SerializeField] ItemCell m_Item;
        [SerializeField] Text m_Description;
        [SerializeField] ItemBehaviour m_Token;
        [SerializeField] Button m_Exchange;
        TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
 
        int trialExchangeId = 0;
        private void Awake()
        {
            m_Exchange.AddListener(Exchange);
        }
 
        private void Exchange()
        {
            if (trialExchangeId != 0)
            {
                int error = 0;
                if (!model.TrialSendExchange(trialExchangeId, out error))
                {
                    if (error == 1)
                    {
                        var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(trialExchangeId);
                        if (config != null)
                        {
                            ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(config.tokenId);
                        }
                    }
                    model.ProcessTrialError(error);
                }
            }
        }
 
        public void Display(int id)
        {
            trialExchangeId = id;
            var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(id);
            if (config == null)
            {
                trialExchangeId = 0;
                return;
            }
            m_Item.cellBtn.RemoveAllListeners();
            m_Item.gameObject.SetActive(true);
            ItemCellModel cellModel = new ItemCellModel(config.exchangeItemID, true, (ulong)config.exchangeItemCount, config.exchangeItemIsBind);
            m_Item.Init(cellModel);
            m_Item.cellBtn.AddListener(() =>
            {
                ItemAttrData itemAttrData = new ItemAttrData(config.exchangeItemID, true, (ulong)config.exchangeItemCount, -1, config.exchangeItemIsBind);
                ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
            });
            m_Description.text = config.description;
            m_Token.SetItem(config.tokenId, config.tokenCount);
        }
    }
}