少年修仙传客户端代码仓库
client_Wu Xijin
2019-04-16 fc714208ff3a320c3bb52bddd5ea3d91f647a206
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using System;
 
namespace Snxxz.UI
{
    public class TrialExchangeBehaviour : MonoBehaviour
    {
        [SerializeField] RectTransform m_ContainerSpecial;
        [SerializeField] RectTransform m_ContainerNormal;
        [SerializeField] Image m_Bottom;
        [SerializeField] ItemCell m_Item;
        [SerializeField] Text m_Description;
        [SerializeField] Text m_SpecialDescription;
        [SerializeField] Text m_ChestDescription;
        [SerializeField] ItemBehaviour m_Token;
        [SerializeField] LongPressButton 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>(); } }
 
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        int trialExchangeId = 0;
        private void Awake()
        {
            m_Exchange.onClick.AddListener(Exchange);
            m_Exchange.onPress.AddListener(LongPress);
        }
 
        private void Exchange()
        {
            if (trialExchangeId != 0)
            {
                int error = 0;
                var config = TrialExchangeConfig.Get(trialExchangeId);
                if (config != null)
                {
                    var itemConfig = ItemConfig.Get(model.GetExchangeItemByJob(config));
                    ItemAttrData itemAttrData = new ItemAttrData(itemConfig.ID, true, (ulong)config.exchangeItemCount);
                    ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData, false);
                    ModelCenter.Instance.GetModel<ItemTipsModel>().curAttrData.SetTipsFuncBtn(ItemOperateType.exchange,
                        (ItemOperateType btnType, string value) =>
                     {
                         if (btnType == ItemOperateType.exchange)
                         {
                             if (!model.TrialSendExchange(trialExchangeId, out error))
                             {
                                 if (error == 1)
                                 {
                                     ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(config.tokenId);
                                 }
                             }
                         }
                     });
                    ModelCenter.Instance.GetModel<ItemTipsModel>().ShowTip();
                }
            }
        }
 
        private void LongPress()
        {
            if (trialExchangeId != 0)
            {
                var config = TrialExchangeConfig.Get(trialExchangeId);
                if (config != null)
                {
                    var itemConfig = ItemConfig.Get(model.GetExchangeItemByJob(config));
                    if (itemConfig.EquipPlace == 0)
                    {
                        return;
                    }
                    ItemAttrData itemAttrData = new ItemAttrData(itemConfig.ID, true, (ulong)config.exchangeItemCount, -1, true);
                    ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
                }
            }
        }
 
        public void Display(int id, bool equipBetter = true, bool first = false)
        {
            m_Bottom.SetSprite(first ? "XT_VIP_63" : "XT_VIP_63");
            m_ContainerSpecial.gameObject.SetActive(first);
            m_ContainerNormal.gameObject.SetActive(!first);
            trialExchangeId = id;
            var config = TrialExchangeConfig.Get(id);
            if (config == null)
            {
                trialExchangeId = 0;
                return;
            }
            m_Item.button.RemoveAllListeners();
            m_Item.gameObject.SetActive(true);
            ItemCellModel cellModel = new ItemCellModel(model.GetExchangeItemByJob(config), true, (ulong)config.exchangeItemCount);
            m_Item.Init(cellModel);
            m_Item.button.AddListener(() =>
            {
                ItemAttrData itemAttrData = new ItemAttrData(model.GetExchangeItemByJob(config), true, (ulong)config.exchangeItemCount, -1, true);
                ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
            });
            m_Description.text = config.description;
            if (m_SpecialDescription != null)
            {
                m_SpecialDescription.text = config.description;
            }
            if (m_ChestDescription != null)
            {
                m_ChestDescription.text = config.chestDesc;
            }
            m_Token.SetItem(config.tokenId, config.tokenCount);
            var count = model.GetTrialTokenCount(config.tokenId);
            m_Token.count.text = StringUtility.Contact(count >= config.tokenCount ? "<color=#109d06>" : string.Empty, count,
                count >= config.tokenCount ? "</color>" : string.Empty, "/", config.tokenCount);
            var equipCompare = model.EquipCompare(model.GetExchangeItemByJob(config));
            m_Up.gameObject.SetActive(equipCompare == 1);
            m_Down.gameObject.SetActive(equipCompare == -1);
 
            var exchangeItemConfig = ItemConfig.Get(model.GetExchangeItemByJob(config));
            m_Redpoint.gameObject.SetActive(count >= config.tokenCount && (equipBetter || exchangeItemConfig.EquipPlace == 0)
                && PlayerDatas.Instance.baseData.LV < model.trialExchangeRemindLevel);
        }
    }
}