少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace vnxbqy.UI
{
    
    public class EquipGemSelectWin : Window
    {
        [SerializeField] ScrollerController m_SrollerControl;
        [SerializeField] Button m_Strike;
        [SerializeField] Button m_Close;
 
        PackModel packModel {
            get { return ModelCenter.Instance.GetModel<PackModel>(); }
        }
 
        EquipGemModel model {
            get { return ModelCenter.Instance.GetModel<EquipGemModel>(); }
        }
 
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
 
        public static GemEquipType gemEquipType = GemEquipType.MultiEquip;
        public static int equipLevel = 0;
        public static int equipPlace = 0;
        public static int equipHole = 0;
 
        static List<string> itemGuids = new List<string>();
 
        bool inlayAble = false;
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_SrollerControl.OnRefreshCell += OnRefreshCell;
            m_Close.AddListener(OnClose);
            m_Strike.AddListener(OnStrikeBtn);
        }
 
        protected override void OnPreOpen()
        {
            Display();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        void Display()
        {
            m_SrollerControl.Refresh();
 
            int equipGem = 0;
            int[] equipGems = null;
            if (model.TryGetEquipGems(equipLevel, equipPlace, out equipGems))
            {
                if (equipHole < equipGems.Length)
                {
                    equipGem = equipGems[equipHole];
                }
            }
 
            inlayAble = false;
            EquipGemRedpoint equipGemRedpoint;
            if (model.TryGetRedpoint(equipLevel, equipPlace, out equipGemRedpoint))
            {
                var inlayRedpoint = equipGemRedpoint.GetInlayRedpoint(equipHole);
                inlayAble = inlayRedpoint.state == RedPointState.Simple;
            }
 
            m_Strike.SetActive(equipGem != 0);
 
            var isMaxLevel = model.IsEquipGemMaxLevel(equipGem);
 
            if (equipGem != 0 && !isMaxLevel)
            {
                m_SrollerControl.AddCell(ScrollerDataType.Header, 0, HandleGem);
            }
 
            if (equipGem != 0 && isMaxLevel)
            {
                m_SrollerControl.AddCell(ScrollerDataType.Extra2, 0, HandleGem);
            }
 
            itemGuids = model.GetSatisfyEquipGemGuids(equipPlace);
            if (itemGuids != null)
            {
                itemGuids.Sort(model.Compare);
                for (int i = 0; i < itemGuids.Count; i++)
                {
                    m_SrollerControl.AddCell(ScrollerDataType.Normal, i, HandleGem);
                }
            }
 
            List<int> gemTypes = null;
            if (model.TryGetGemTypes(equipPlace, out gemTypes))
            {
                foreach (var type in gemTypes)
                {
                    GemType gemType;
                    if (model.TryGetGemType(type, out gemType))
                    {
                        if (equipGem == 0 && gemType.shopItemId != 0)
                        {
                            m_SrollerControl.AddCell(ScrollerDataType.Tail, type, HandleGem);
                        }
                    }
                }
 
                foreach (var type in gemTypes)
                {
                    GemType gemType;
                    if (model.TryGetGemType(type, out gemType))
                    {
                        if (gemType.getWays != null)
                        {
                            foreach (var getWay in gemType.getWays)
                            {
                                if (getWay != 0)
                                {
                                    m_SrollerControl.AddCell(ScrollerDataType.Extra1, getWay * 100 + type, HandleGem);
                                }
                            }
                        }
                    }
                }
            }
            m_SrollerControl.Restart();
        }
 
        void HandleGem(CellView cell)
        {
            switch (cell.type)
            {
                case ScrollerDataType.Header:
                    CloseImmediately();
                    LevelUpGem();
                    break;
                case ScrollerDataType.Normal:
                    var index = cell.index;
                    if (index < itemGuids.Count)
                    {
                        OnInlayGem(itemGuids[index]);
                    }
                    CloseImmediately();
                    break;
                case ScrollerDataType.Tail:
                    CloseImmediately();
                    ItemConfig itemConfig = ItemConfig.GetGemDataByLevelAndType(1, cell.index);
                    var goodsConfig = StoreConfig.GetStoreCfgByItemIDEx(itemConfig.ID, 1);
                    if (goodsConfig != null)
                    {
                        var storeModel = ModelCenter.Instance.GetModel<StoreModel>();
                        storeModel.SetJumpToModel(itemConfig.ID);
                        if (goodsConfig.SecondType.Length > 0)
                            storeModel.selectSecondType = goodsConfig.SecondType[0];
 
                    }
 
                    WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.StoreFunc3);
                    break;
                case ScrollerDataType.Extra1:
                    var getWay = cell.index / 100;
                    CloseImmediately();
                    var config = GetItemWaysConfig.Get(getWay);
                    if (config != null)
                    {
                        WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.OpenpanelId);
                    }
                    break;
            }
        }
 
        void OnStrikeBtn()
        {
            var equipPosition = new Int2(equipLevel, equipPlace);
            var equipGuid = equipModel.GetEquip(equipPosition);
            if (string.IsNullOrEmpty(equipGuid))
            {
                return;
            }
 
            var _pak = new CA305_tagCMEquipStonePick();
            _pak.EquipIndex = (byte)EquipSet.ClientPlaceToServerPlace(equipPosition);
            _pak.HoleIndex = equipHole == 3 ? (byte)10 : (byte)equipHole;
            GameNetSystem.Instance.SendInfo(_pak);
            CloseImmediately();
        }
 
        void LevelUpGem()
        {
            var equipPosition = new Int2(equipLevel, equipPlace);
            var equipGuid = equipModel.GetEquip(equipPosition);
            if (string.IsNullOrEmpty(equipGuid))
            {
                return;
            }
            int equipGem;
            if (!model.TryGetEquipGem(equipLevel, equipPlace, equipHole, out equipGem))
            {
                return;
            }
            if (model.IsEquipGemMaxLevel(equipGem))
            {
                SysNotifyMgr.Instance.ShowTip("GemFullLevelError");
                return;
            }
            EquipGemLevelUpWin.equipLevel = equipLevel;
            EquipGemLevelUpWin.equipHole = equipHole;
            EquipGemLevelUpWin.equipPlace = equipPlace;
            EquipGemLevelUpWin.equipType = gemEquipType;
            WindowCenter.Instance.Open<EquipGemLevelUpWin>();
        }
 
        void OnInlayGem(string guid)
        {
            var equipPosition = new Int2(equipLevel, equipPlace);
            var equipGuid = equipModel.GetEquip(equipPosition);
            if (string.IsNullOrEmpty(equipGuid))
            {
                return;
            }
            var item = packModel.GetItemByGuid(guid);
            CA304_tagCMEquipEnchase _pak = new CA304_tagCMEquipEnchase();
            _pak.HoleIndex = equipHole == 3 ? (byte)10 : (byte)equipHole;
            _pak.StoneIndex = (byte)item.gridIndex;
            _pak.EquipIndex = (byte)EquipPlaceMapConfig.GetServerPlace(equipLevel, equipPlace);
            GameNetSystem.Instance.SendInfo(_pak);
            CloseClick();
        }
 
        private void OnClose()
        {
            CloseImmediately();
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView _cell)
        {
            switch (type)
            {
                case ScrollerDataType.Header:
                    {
                        var cell = _cell as EquipGemLevelUpCell;
                        int[] equipGems;
                        if (model.TryGetEquipGems(equipLevel, equipPlace, out equipGems))
                        {
                            if (equipHole < equipGems.Length)
                            {
                                cell.Display(equipGems[equipHole]);
                            }
                        }
                    }
 
                    break;
                case ScrollerDataType.Normal:
                    {
                        var cell = _cell as EquipGemItemCell;
                        var index = cell.index;
                        if (index < itemGuids.Count)
                        {
                            cell.Display(itemGuids[index], inlayAble && index == 0);
                        }
                    }
                    break;
                case ScrollerDataType.Tail:
                    {
                        var cell = _cell as EquipGemShopCell;
                        cell.Display(cell.index);
                    }
                    break;
                case ScrollerDataType.Extra1:
                    {
                        var getWay = _cell.index / 100;
                        var gemType = _cell.index % 100;
                        var cell = _cell as EquipGemGetWayCell;
                        cell.Display(gemType, getWay);
                    }
                    break;
                case ScrollerDataType.Extra2:
                    {
                        var cell = _cell as EquipGemFlauntCell;
                        int[] equipGems;
                        if (model.TryGetEquipGems(equipLevel, equipPlace, out equipGems))
                        {
                            if (equipHole < equipGems.Length)
                            {
                                cell.Display(equipGems[equipHole]);
                            }
                        }
                    }
                    break;
            }
        }
 
        bool IsBestGem(int itemId, List<ItemModel> list)
        {
            var config = ItemConfig.Get(itemId);
            for (int i = 0; i < list.Count; i++)
            {
                var compareItem = list[i];
                var compareConfig = ItemConfig.Get(compareItem.itemId);
                if (compareConfig.EffectValueB1 > config.EffectValueB1)
                {
                    return false;
                }
            }
            return true;
        }
    }
}