少年修仙传客户端代码仓库
client_linchunjie
2018-08-27 d106f11e7f44c748f595da36e0cdfd54849649e6
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TableConfig;
using System;
 
namespace Snxxz.UI
{
    public class TrialExchangeBehaviour : MonoBehaviour
    {
        [SerializeField] Image m_Bottom;
        [SerializeField] ItemCell m_Item;
        [SerializeField] Text m_Description;
        [SerializeField] ItemBehaviour m_Token;
        [SerializeField] Button m_Exchange;
        [SerializeField] Image m_Redpoint;
        [SerializeField] Image m_Up;
        [SerializeField] Image m_Down;
        TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
        DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
 
        PlayerPackModel packModel { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
 
        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 = Config.Instance.Get<TrialExchangeConfig>(trialExchangeId);
                        if (config != null)
                        {
                            ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(config.tokenId);
                        }
                    }
                }
            }
        }
 
        public void Display(int id, bool equipBetter = true, bool first = false)
        {
            m_Bottom.SetSprite(first ? "SpecialExchangeBottom" : "Title_PopupWindow");
            trialExchangeId = id;
            var config = Config.Instance.Get<TrialExchangeConfig>(id);
            if (config == null)
            {
                trialExchangeId = 0;
                return;
            }
            m_Item.cellBtn.RemoveAllListeners();
            m_Item.gameObject.SetActive(true);
            ItemCellModel cellModel = new ItemCellModel(model.GetExchangeItemByJob(config), true, (ulong)config.exchangeItemCount, config.exchangeItemIsBind);
            m_Item.Init(cellModel);
            m_Item.cellBtn.AddListener(() =>
            {
                ItemAttrData itemAttrData = new ItemAttrData(model.GetExchangeItemByJob(config), true, (ulong)config.exchangeItemCount, -1, config.exchangeItemIsBind, true);
                ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
            });
            m_Description.text = config.description;
            m_Token.SetItem(config.tokenId, config.tokenCount);
            var count = model.GetTrialTokenCount(config.tokenId);
            m_Token.count.color = UIHelper.GetUIColor(count >= config.tokenCount ? TextColType.Green : TextColType.NavyBrown, true);
            var equipCompare = model.EquipCompare(model.GetExchangeItemByJob(config));
            m_Up.gameObject.SetActive(equipCompare == 1);
            m_Down.gameObject.SetActive(equipCompare == -1);
 
            var exchangeItemConfig = Config.Instance.Get<ItemConfig>(model.GetExchangeItemByJob(config));
            m_Redpoint.gameObject.SetActive(count >= config.tokenCount && (equipBetter || exchangeItemConfig.EquipPlace == 0));
        }
    }
}