少年修仙传客户端代码仓库
hch
2025-07-02 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
using vnxbqy.UI;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
class EquipEvolveWin : ILWindow
{
    ScrollerController scrollerRealm;
    ScrollerController scrollerEquip;
    ItemCell tagetItemCell;
    Transform proEmpty;
    Transform proShow;
    List<Text> countTexts = new List<Text>();
    List<ItemCell> materialItems = new List<ItemCell>();
    List<Image> lockImages = new List<Image>();
    Text fromText;
    Text toText;
    Transform evolveShow;
    ScrollerController scrollerProperty;
    Button evolveBtn;
    Button decomposeBtn;
 
    Text Base1Txt_Current;
    Text Base1Txt_Next;
    Text Base2Txt_Current;
    Text Base2Txt_Next;
    List<Text> LegendCurrent = new List<Text>();
    List<Text> LegendNext = new List<Text>();
    List<Transform> PropertyLines = new List<Transform>();
    Transform BasePropertyLine_2;
    Transform LegendTitle;
 
    int equipID = 0;    //当前选中的装备
    int finalEquipID = 0;   //进阶到最高级时的装备ID
    EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
    PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
    #region Built-in
    protected override void BindController()
    {
        scrollerRealm = proxy.GetWidgtEx<ScrollerController>("ScrollerRealm");
        scrollerEquip = proxy.GetWidgtEx<ScrollerController>("ScrollerEquip");
        tagetItemCell = proxy.GetWidgtEx<ItemCell>("tagetItemCell");
        materialItems.Add(proxy.GetWidgtEx<ItemCell>("Material1"));
        materialItems.Add(proxy.GetWidgtEx<ItemCell>("Material2"));
        proEmpty = proxy.GetWidgtEx<Transform>("Container_Empty");
        proShow = proxy.GetWidgtEx<Transform>("Container_Details");
        countTexts.Add(proxy.GetWidgtEx<Text>("Count1"));
        countTexts.Add(proxy.GetWidgtEx<Text>("Count2"));
        lockImages.Add(proxy.GetWidgtEx<Image>("Img_Lock1"));
        lockImages.Add(proxy.GetWidgtEx<Image>("Img_Lock2"));
        fromText = proxy.GetWidgtEx<Text>("fromText");
        toText = proxy.GetWidgtEx<Text>("toText");
        evolveShow = proxy.GetWidgtEx<Transform>("Container_EvolveText");
        scrollerProperty = proxy.GetWidgtEx<ScrollerController>("ScrollerProperty");
        evolveBtn = proxy.GetWidgtEx<Button>("Btn_Evolve");
        decomposeBtn = proxy.GetWidgtEx<Button>("BtnDecompose");
 
        Base1Txt_Current = proxy.GetWidgtEx<Text>("Base1Txt_Current");
        Base1Txt_Next = proxy.GetWidgtEx<Text>("Base1Txt_Next");
        Base2Txt_Current = proxy.GetWidgtEx<Text>("Base2Txt_Current");
        Base2Txt_Next = proxy.GetWidgtEx<Text>("Base2Txt_Next");
        LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend1Txt_Current"));
        LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend2Txt_Current"));
        LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend3Txt_Current"));
        LegendNext.Add(proxy.GetWidgtEx<Text>("Legend1Txt_Next"));
        LegendNext.Add(proxy.GetWidgtEx<Text>("Legend2Txt_Next"));
        LegendNext.Add(proxy.GetWidgtEx<Text>("Legend3Txt_Next"));
        PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_1"));
        PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_2"));
        PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_3"));
        BasePropertyLine_2 = proxy.GetWidgtEx<Transform>("BasePropertyLine_2");
        LegendTitle = proxy.GetWidgtEx<Transform>("Img_Title");
    }
 
    protected override void AddListeners()
    {
        decomposeBtn.SetListener(()=> {
            WindowCenter.Instance.OpenIL<EquipShenDecomposeWin>();
        });
 
        evolveBtn.SetListener(OnEvolve);
    }
 
    /// <summary>
    /// 没有红点提示,可以定位第一件可进阶装备
    /// </summary>
    protected override void OnPreOpen()
    {
        equipID = 0;
        finalEquipID = 0;
        if (EquipEvolveModel.Instance.materialJumpPos == Int2.zero)
        {
            var equipPos = EquipEvolveModel.Instance.FindSatisfyEquip();
            EquipEvolveModel.Instance.selectLevelType = equipPos.x;
            EquipEvolveModel.Instance.selectPlaceType = equipPos.y;
        }
        else
        {
            EquipEvolveModel.Instance.selectLevelType = EquipEvolveModel.Instance.materialJumpPos.x;
            EquipEvolveModel.Instance.selectPlaceType = EquipEvolveModel.Instance.materialJumpPos.y;
            EquipEvolveModel.Instance.materialJumpPos = Int2.zero;
        }
 
        scrollerRealm.OnRefreshCell += OnRefreshRealmCell;
        scrollerEquip.OnRefreshCell += OnRefreshEquipCell;
        EquipEvolveModel.Instance.SelectLevelEvent += SelectLevelEvent;
        EquipEvolveModel.Instance.SelectPlaceEvent += SelectPlaceEvent;
        packModel.refreshItemCountEvent += RefreshItemCount;
        scrollerProperty.OnRefreshCell += OnRefreshProperty;
 
        
    }
 
    protected override void OnAfterOpen()
    {
        Display();
    }
 
    protected override void OnPreClose()
    {
        scrollerRealm.OnRefreshCell -= OnRefreshRealmCell;
        scrollerEquip.OnRefreshCell -= OnRefreshEquipCell;
        EquipEvolveModel.Instance.SelectLevelEvent -= SelectLevelEvent;
        EquipEvolveModel.Instance.SelectPlaceEvent -= SelectPlaceEvent;
        packModel.refreshItemCountEvent -= RefreshItemCount;
        scrollerProperty.OnRefreshCell -= OnRefreshProperty;
    }
 
    #endregion
 
 
    void Display()
    {
        CreateLevelBehaviours();
        CreateEquipBehaviours();
        ShowEvolveItem();
    }
 
    #region 境界装备
    private void OnRefreshRealmCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetILBehaviour<EquipRealmCell>();
        if (_cell == null) return;
        Debug.LogFormat("OnRefreshRealmCell: {0}", cell.index);
        _cell.Display(cell.index);
    }
 
 
    private void OnRefreshEquipCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetILBehaviour<EquipEvolveCell>();
        if (_cell == null) return;
        _cell.Display(cell.index);
    }
 
 
 
    private void CreateLevelBehaviours()
    {
        var levels = equipModel.GetUnLockedEquipSets();
 
        scrollerRealm.Refresh();
        for (int i = 0; i < levels.Count; i++)
        {
            scrollerRealm.AddCell(ScrollerDataType.Header, levels[i]);
        }
        scrollerRealm.Restart();
        
    }
 
    void CreateEquipBehaviours()
    {
        scrollerEquip.Refresh();
        for (int j = 1; j < 12; j++)
        {
            scrollerEquip.AddCell(ScrollerDataType.Header, j);
 
        }
        scrollerEquip.Restart();
        scrollerEquip.JumpIndex(EquipEvolveModel.Instance.selectPlaceType - 1);
    }
 
    void SelectLevelEvent()
    {
        scrollerRealm.m_Scorller.RefreshActiveCellViews();
        scrollerEquip.m_Scorller.RefreshActiveCellViews();
        ShowEvolveItem();
    }
 
    void SelectPlaceEvent()
    {
        scrollerEquip.m_Scorller.RefreshActiveCellViews();
        ShowEvolveItem();
    }
 
    #endregion
 
    #region 装备材料区
    void ShowEvolveItem()
    {
        var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType);
        var equipGuid = equipModel.GetEquip(position);
        for (int i = 0; i < materialItems.Count; i++)
        {
            materialItems[i].SetActiveIL(false);
            countTexts[i].SetActiveIL(false);
            lockImages[i].SetActiveIL(true);
        }
        proEmpty.SetActiveIL(false);
        proShow.SetActiveIL(false);
        evolveShow.SetActiveIL(false);
 
        if (string.IsNullOrEmpty(equipGuid))
        {
            tagetItemCell.SetActiveIL(false);
            proEmpty.SetActiveIL(true);
            proShow.SetActiveIL(false);
            return;
        }
        tagetItemCell.SetActiveIL(true);
        var equipItem = packModel.GetItemByGuid(equipGuid);
        if (equipItem == null)
            return;
 
        equipID = equipItem.itemId;
        var model = new ItemCellModel(equipID, false, (ulong)equipItem.count);
        tagetItemCell.Init(model);
        tagetItemCell.button.SetListener(() =>
        {
            ItemTipUtility.Show(equipGuid, false);
        });
 
        var materials = ILEquipShenEvolveConfig.TryGetMaterial(equipID);
        if (materials == null)
        {
            proEmpty.SetActiveIL(true);
            proShow.SetActiveIL(false);
            return;
        }
 
        proEmpty.SetActiveIL(false);
        proShow.SetActiveIL(true);
        evolveShow.SetActiveIL(true);
 
 
        //材料
        for (int i = 0; i < materials.Length; i++)
        {
            if (i >= materialItems.Count)
            {
                continue;
            }
            materialItems[i].SetActiveIL(true);
            var itemID = materials[i][0];
            var count = packModel.GetItemCountByID(PackType.Item, itemID);
            var materialModel = new ItemCellModel(itemID, false, 1);
            materialItems[i].Init(materialModel);
            materialItems[i].button.SetListener(() =>
            {
                ItemTipUtility.Show(itemID);
            });
            countTexts[i].SetActiveIL(true);
            countTexts[i].text = UIHelper.AppendColor(count >= materials[i][1] ? TextColType.Green : TextColType.Red, count + "/" + materials[i][1]);
            lockImages[i].SetActiveIL(false);
        }
 
        //显示下一进阶品质
        fromText.text = Language.Get("ShenEquipText" + EquipEvolveModel.Instance.GetRedEquipQuality(equipID));
        toText.text = Language.Get("ShenEquipText" + EquipEvolveModel.Instance.GetRedEquipQuality(ILEquipShenEvolveConfig.Get(equipID).EvolveID));
 
        ShowPro();
    }
 
    void RefreshItemCount(PackType packType, int index, int itemID)
    {
        if (packType == PackType.Equip)
        {
            ShowEvolveItem();
            scrollerEquip.m_Scorller.RefreshActiveCellViews();
        }
    }
 
    #endregion
 
    #region 属性区
    void ShowPro()
    {
        ShowBasePro();
        ShowLegendPro();
        CreateEvolveProperty();
    }
 
 
    //基础
    void ShowBasePro()
    {
        var nextEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID;
        var equipConfig = ItemConfig.Get(equipID);
        var nextEquipConfig = ItemConfig.Get(nextEquipID);
        Base1Txt_Current.text = StringUtility.Contact(PlayerPropertyConfig.Get(equipConfig.Effect1).Name, ":", PlayerPropertyConfig.GetValueDescription(equipConfig.Effect1, equipConfig.EffectValueA1));
        Base1Txt_Next.text = PlayerPropertyConfig.GetValueDescription(nextEquipConfig.Effect1, nextEquipConfig.EffectValueA1);
        BasePropertyLine_2.SetActiveIL(false);
        if (equipConfig.Effect2 != 0)
        {
            BasePropertyLine_2.SetActiveIL(true);
            Base2Txt_Current.text = StringUtility.Contact(PlayerPropertyConfig.Get(equipConfig.Effect2).Name, ":", PlayerPropertyConfig.GetValueDescription(equipConfig.Effect2, equipConfig.EffectValueA2));
            Base2Txt_Next.text = PlayerPropertyConfig.GetValueDescription(nextEquipConfig.Effect2, nextEquipConfig.EffectValueA2);
        }
 
    }
 
    void ShowLegendPro()
    {
        for (int i = 0; i < PropertyLines.Count; i++)
        {
            PropertyLines[i].SetActiveIL(false);
        }
        var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType);
        var equipGuid = equipModel.GetEquip(position);
 
        var nextEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID;
        var config = EquipShenAttrConfig.Get(nextEquipID);
        if (config == null)
        {
            return;
        }
        var curEquipLegends = ILItemCommon.GetLegendProperty(equipGuid);
        int index = 0;
        bool hasLegend = false;
        for (int i = 0; i < config.LegendAttrID.Length; i++)
        {
            int curValue = 0;
            var proValue = config.LegendAttrValue[i];
            var proID = config.LegendAttrID[i];
            curEquipLegends.TryGetValue(proID, out curValue);
            if (curValue == proValue)
            {
                continue;
            }
            PropertyLines[index].SetActiveIL(true);
            LegendCurrent[index].text = StringUtility.Contact(PlayerPropertyConfig.Get(proID).Name, ":", PlayerPropertyConfig.GetValueDescription(proID, curValue));
            LegendNext[index].text = PlayerPropertyConfig.GetValueDescription(proID, proValue);
            index++;
            hasLegend = true;
        }
        
        LegendTitle.SetActiveIL(hasLegend);
    }
 
 
    void CreateEvolveProperty()
    {
        finalEquipID = EquipEvolveModel.Instance.GetFinalEvolveEquip(equipID);
        var equipInfo = EquipShenAttrConfig.Get(finalEquipID);
        if (equipInfo == null) return;
        int count = equipInfo.ShenAttrID.Length + equipInfo.XianAttrID.Length + equipInfo.JiAttrID.Length;
        scrollerProperty.Refresh();
        for (int i = 0; i < count; i++)
        {
            scrollerProperty.AddCell(ScrollerDataType.Header, i);
        }
        scrollerProperty.Restart();
        
    }
 
    void OnRefreshProperty(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetILBehaviour<EvolvePropertyCell>();
        if (_cell == null) return;
        _cell.Display(finalEquipID, equipID, cell.index);
    }
 
 
    #endregion
 
    #region 操作区
 
    void OnEvolve()
    {
        var materials = ILEquipShenEvolveConfig.TryGetMaterial(equipID);
        if (materials == null)
        {
            return;
        }
        for (int i = 0; i < materials.Length; i++)
        {
            var count = packModel.GetItemCountByID(PackType.Item, materials[i][0]);
            if (count < materials[i][1])
            {
                //材料不足
                SysNotifyMgr.Instance.ShowTip("NotEnoughMaterial");
                return;
            }
            LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(4, materials[i][0], materials[i][1], 1,0);
        }
        //记录用于成功后的展示
        EquipEvolveModel.Instance.resultFromEquipID = equipID;
        EquipEvolveModel.Instance.resultToEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID;
        var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType);
        EquipEvolveModel.Instance.fromEquipLegends = ILItemCommon.GetLegendProperty(equipModel.GetEquip(position));
 
        var pak = new IL_CA330_tagCMEquipEvolve();
        pak.EquipIndex = (byte)EquipSet.ClientPlaceToServerPlace(new Int2(EquipEvolveModel.Instance.selectLevelType,
            EquipEvolveModel.Instance.selectPlaceType));
        GameNetSystem.Instance.SendInfo(pak);
    }
    #endregion
}