少年修仙传客户端代码仓库
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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public class GatherSoulHoleBehaviour : MonoBehaviour
    {
        [SerializeField] int hole;
        [SerializeField] RectTransform m_ContainreItem;
        [SerializeField] RectTransform m_ContainerEquipSign;
        [SerializeField] RectTransform m_ContainerLock;
        [SerializeField] RectTransform m_ContaienrRedpoint;
        [SerializeField] Image m_Icon;
        [SerializeField] Text m_ItemName;
        [SerializeField] Text m_Level;
        [SerializeField] Text m_Condition;
        [SerializeField] Button m_Func;
 
        GatheringSoulModel model
        {
            get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
        }
 
        GatherSoulComposeModel composeModel
        {
            get { return ModelCenter.Instance.GetModel<GatherSoulComposeModel>(); }
        }
 
        bool existItem = false;
 
        private void Awake()
        {
            m_Func.onClick.AddListener(OnFunc);
        }
 
        public void Display()
        {
            model.gatherSoulHoleRefresh -= GatherSoulHoleRefresh;
            model.gatherSoulHoleRefresh += GatherSoulHoleRefresh;
 
            RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
            RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
 
            DisplayBase();
            DisplayRedpoint();
        }
 
        void DisplayBase()
        {
            bool unlockHole = model.IsHoleUnlock(hole);
            GatherSoulItem item;
            bool equiped = model.TryGetItem(hole, out item);
            m_ContainreItem.gameObject.SetActive(equiped);
            m_ContainerLock.gameObject.SetActive(!unlockHole);
            m_ContainerEquipSign.gameObject.SetActive(!equiped && unlockHole);
            existItem = equiped;
            if (equiped)
            {
                var config = ItemConfig.Get(item.id);
                m_Icon.SetSprite(config.IconKey);
                m_ItemName.text = config.ItemName;
                m_Level.text = item.level.ToString();
                m_ItemName.color = UIHelper.GetUIColor(config.ItemColor);
            }
            if (!unlockHole)
            {
                DisplayCondition();
            }
        }
 
        void DisplayCondition()
        {
            GatherSoulHoleCondition condition;
            if (model.TryGetHoleCondition(hole, out condition))
            {
                m_Condition.text = Language.Get("GatherSoulHoleOpenCondition", condition.level);
            }
        }
 
        private void OnFunc()
        {
            if (!model.IsHoleUnlock(hole))
            {
                GatherSoulHoleCondition condition;
                if (model.TryGetHoleCondition(hole, out condition))
                {
                    SysNotifyMgr.Instance.ShowTip("GatherSoulHoleOpenCondition", condition.level);
                }
            }
            else
            {
                GatherSoulItem item;
                if (model.TryGetItem(hole, out item))
                {
                    var itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>();
                    var data = new ItemAttrData(item.id, true);
                    data.SetGatherSoul(item.level, hole);
                    GatherSoulComposeModel.Compose compose;
                    bool requireCompose = composeModel.ExistInComposeMat(item.id, out compose);
                    data.SetTipsFuncBtn(ItemOperateType.putOff, OnTipFunc);
                    if (requireCompose)
                    {
                        data.SetTipsFuncBtn(ItemOperateType.compose, OnTipFunc);
                    }
                    if (!model.IsGatherSoulMaxLevel(item.id, item.level))
                    {
                        data.SetTipsFuncBtn(ItemOperateType.LevelUp, OnTipFunc);
                    }
                    List<GatherSoulItem> list = new List<GatherSoulItem>();
                    model.TryGetSatisfyReplaceSouls(hole, ref list);
                    if (list.Count > 0)
                    {
                        data.SetTipsFuncBtn(ItemOperateType.Replace, OnTipFunc);
                        list = null;
                    }
                    itemTipsModel.SetItemTipsModel(data);
                }
                else
                {
                    if (!model.ContainsEquipSoul(hole))
                    {
                        SysNotifyMgr.Instance.ShowTip("NoneSoulSatisfyEquip");
                    }
                    else
                    {
                        GatherSoulEquipListWin.selectHole = hole;
                        WindowCenter.Instance.Open<GatherSoulEquipListWin>();
                    }
                }
            }
        }
 
        private void RedpointValueChangeEvent(int id)
        {
            if (id == model.equipRedpoint.id || id == model.levelUpRedpoint.id
                || id == model.replaceRedpoint.id)
            {
                DisplayRedpoint();
            }
        }
 
        void DisplayRedpoint()
        {
            bool requireRedpoint = (model.equipRedpoint.state == RedPointState.Simple && model.equipRedpointHole == hole)
                || (model.levelUpRedpoint.state == RedPointState.Simple && model.levelUpRedpointHole == hole);
            m_ContaienrRedpoint.gameObject.SetActive(requireRedpoint);
        }
 
        private void OnTipFunc(ItemOperateType funcType, string arg2)
        {
            switch (funcType)
            {
                case ItemOperateType.compose:
                    {
                        GatherSoulItem item;
                        if (model.TryGetItem(hole, out item))
                        {
                            model.HandleSoulTipFunc(funcType, item);
                        }
                    }
                    break;
                case ItemOperateType.putOff:
                    {
                        WindowCenter.Instance.Close<GatherSoulTipWin>();
                        GatherSoulItem item;
                        if (model.TryGetItem(hole, out item))
                        {
                            model.ExecutePutOffSoul(item);
                        }
                    }
                    break;
                case ItemOperateType.LevelUp:
                    WindowCenter.Instance.Close<GatherSoulTipWin>();
                    GatherSoulLevelUpWin.selectHole = hole;
                    WindowCenter.Instance.Open<GatherSoulLevelUpWin>();
                    break;
                case ItemOperateType.Replace:
                    WindowCenter.Instance.Close<GatherSoulTipWin>();
                    GatherSoulEquipListWin.selectHole = hole;
                    WindowCenter.Instance.Open<GatherSoulEquipListWin>();
                    break;
            }
        }
 
        private void GatherSoulHoleRefresh(int hole)
        {
            if (this.hole == hole)
            {
                bool exist = existItem;
                DisplayBase();
                if (!exist && existItem && model.serverInited)
                {
                    EffectMgr.Instance.PlayUIEffect(3079, 2100, transform, false);
                }
            }
        }
 
        public void Dispose()
        {
            model.gatherSoulHoleRefresh -= GatherSoulHoleRefresh;
            RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
        }
    }
}