少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using vnxbqy.UI;
 
 
class SpiritEquipBreachWin : ILWindow
{
 
    PackModel packModel;
 
    Transform equGridContainer;
    Transform breachMatContainer;
    Transform prefabs;
    ItemCell nowItemCell;
    ItemCell nextItemCell;
    Text nowText;
    Text nextText;
    Transform maxTip;
    Transform emptyTip;
    Transform equAttrContainer;
    Transform breachBg;
    Transform otherBg;
    Transform attrBg;
    Transform breachEquContianer;
    Button breachButton;
    RawImage equShow;
    RectTransform equShowRT;
    Button FosterButton;
 
    RoleEquipType[] equTypes = new RoleEquipType[]
{
       RoleEquipType.Guard,
       RoleEquipType.Wing,
       RoleEquipType.PeerlessWeapon1,
       RoleEquipType.PeerlessWeapon2,
};
 
    int[] euqPlaceNameIDs = new int[] { 14, 13, 16, 17 };
 
    bool bIsCanBreach = false;
    RoleEquipType curEquType;
    int lessMatID;
 
    List<MatGridBehaviour> matGridBehaviours = new List<MatGridBehaviour>();
    List<EquGridBehaviour> equGridBehaviours = new List<EquGridBehaviour>();
    List<Text> attrTexts = new List<Text>();
 
    protected override void BindController()
    {
        base.BindController();
        this.packModel = ModelCenter.Instance.GetModelEx<PackModel>();
        this.equGridContainer = this.transform.Find("Container_EquGrid");
        this.breachMatContainer = this.transform.Find("Container_BreachEqu/Container_BreachMat");
        this.prefabs = this.transform.Find("Prefabs");
        this.nowItemCell = this.transform.FindComponentEx<ItemCell>("Container_BreachEqu/ItemCell_Now");
        this.nextItemCell = this.transform.FindComponentEx<ItemCell>("Container_BreachEqu/ItemCell_Next");
        this.nowText = this.transform.FindComponentEx<Text>("Container_BreachEqu/Text_Now");
        this.nextText = this.transform.FindComponentEx<Text>("Container_BreachEqu/Text_Next");
        this.maxTip = this.transform.Find("Text_MaxTip");
        this.emptyTip = this.transform.Find("Text_EmptyTip");
        this.equAttrContainer = this.transform.Find("Container_EquShow/Container_EquAttr");
        this.breachBg = this.transform.Find("Cotainer_Bg/Img_Bg_1");
        this.otherBg = this.transform.Find("Cotainer_Bg/Img_Bg_2");
        this.attrBg = this.transform.Find("Cotainer_Bg/Img_Bg_8");
        this.breachEquContianer = this.transform.Find("Container_BreachEqu");
        this.breachButton = this.transform.FindComponentEx<Button>("Btn_Breach");
        this.equShow = this.transform.FindComponentEx<RawImage>("Container_EquShow/EquShow");
        this.equShowRT = this.transform.FindComponentEx<RectTransform>("Container_EquShow/EquShow");
        this.FosterButton = this.transform.FindComponentEx<ButtonEx>("Container_EquShow/FosterBtn");
    }
 
    protected override void AddListeners()
    {
        base.AddListeners();
        this.breachButton.SetListener(() =>
        {
            OnBreachButtonDown();
        });
 
        this.FosterButton.SetListener(() =>
        {
            OnFosterButtonDown();
        });
    }
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        RefreshUI();
        SpiritEquipModel.Instance.IsEquipBreachOpen = true;
    }
 
    protected override void OnAfterOpen()
    {
        base.OnAfterOpen();
        SpiritEquipModel.Instance.refreshShowItemEvent += this.RefreshUI;
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
        SpiritEquipModel.Instance.refreshShowItemEvent -= this.RefreshUI;
        SpiritEquipModel.Instance.IsEquipBreachOpen = false;
    }
    void OnFosterButtonDown()
    {
        if (FosterModel.Instance.CheckLingQiOpen((int)curEquType,true))
        {
            WindowJumpMgr.Instance.WindowJumpToEx("FosterWin");
        }       
    }
    void OnBreachButtonDown()
    {
        if (this.bIsCanBreach)
        {
            SpiritEquipModel.Instance.SendBreachInfo(this.curEquType);
            this.bIsCanBreach = false;
        }
        else
        {
            var info = new ItemTipUtility.ItemViewInfo();
            info.itemId = this.lessMatID;
            info.unfoldGetWay = true;
            ItemTipUtility.Show(info);
            SysNotifyMgr.Instance.ShowTip("SpiritOrgan1");
        }
    }
 
    void RefreshUI()
    {
        if (this.equGridContainer.childCount == 0)
        {
            var equGridPrefab = this.prefabs.Find("EquGrid");
            for (int i = 0; i < this.equTypes.Length; i++)
            {
                var equType = this.equTypes[i];
                var equGrid = GameObject.Instantiate(equGridPrefab, this.equGridContainer);
                equGrid.SetActiveIL(true);
                equGrid.transform.Find("RedPoint").GetComponent<RedpointBehaviour>().redpointId = 1910200 + (int)equType;
                equGrid.localScale = Vector3.one;
                var behaviour = new EquGridBehaviour();
                behaviour.BindController(equGrid, () =>
                {
                    for (int j = 0; j < equGridBehaviours.Count; j++)
                    {
                        var bh = equGridBehaviours[j];
                        bh.equGridBtn.interactable = true;
                    }
                    behaviour.equGridBtn.interactable = false;
                    this.curEquType = equType;
                    this.ShowCurPlaceEqu();
                    //显示培养红点
                    SpiritEquipModel.Instance.ShowFosterRedPoint((int)equType);
                }, 1910200 + (int)equType);
                var place = new Int2(0, (int)equType);
                var index = EquipSet.ClientPlaceToServerPlace(place);
                var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
                var name = GeneralDefine.equipPlaceNameDict[this.euqPlaceNameIDs[i]];
                behaviour.Init(itemModel, Language.Get("SpiritEquipText_2", name));
                this.equGridBehaviours.Add(behaviour);
                
            }
            this.equGridBehaviours[0].equGridBtn.interactable = false;
            this.curEquType = this.equTypes[0];
        }
        else
        {
            for (int i = 0; i < this.equTypes.Length; i++)
            {
                var equType = this.equTypes[i];
                var place = new Int2(0, (int)equType);
                var index = EquipSet.ClientPlaceToServerPlace(place);
                var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
                var name = GeneralDefine.equipPlaceNameDict[this.euqPlaceNameIDs[i]];
                this.equGridBehaviours[i].Init(itemModel, Language.Get("SpiritEquipText_2", name));               
            }
        }
        this.ShowCurPlaceEqu();
    }
 
    void ShowCurPlaceEqu()
    {
        this.bIsCanBreach = false;
        var place = new Int2(0, (int)this.curEquType);
        var index = EquipSet.ClientPlaceToServerPlace(place);
        var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
        if (itemModel == null)
        {
            this.breachButton.SetActiveIL(false);
            //装备未穿戴
            this.equShow.SetActiveIL(false);
            this.breachEquContianer.SetActiveIL(false);
            this.equAttrContainer.SetActiveIL(false);
            this.attrBg.SetActiveIL(false);
            this.otherBg.SetActiveIL(true);
            this.breachBg.SetActiveIL(false);
            this.maxTip.SetActiveIL(false);
            this.emptyTip.SetActiveIL(true);
            this.FosterButton.SetActiveIL(false);
        }
        else
        {
            this.FosterButton.SetActiveIL(true);
            //显示培养红点
            SpiritEquipModel.Instance.ShowFosterRedPoint((int) curEquType);
 
            this.equShow.SetActiveIL(true);
            var config = SpiritWeaponConfig.Get(itemModel.itemId);
            var nowId = itemModel.itemId;
            var nextId = config.NextItemID;
            var bIsMaxLevle = (nextId == 0);
            SpiritEquipModel.Instance.curEquType = this.curEquType;
            //展示模型
            if (this.curEquType == RoleEquipType.Wing)
                UI3DModelExhibition.Instance.ShowWing(config.NPCID, this.equShow);
            else if (this.curEquType == RoleEquipType.Guard)
                UI3DModelExhibition.Instance.ShowNPC(config.NPCID, Vector3.zero, this.equShow, false, false);
            else
                UI3DModelExhibition.Instance.ShowEquipment(ItemConfig.Get(nowId).ChangeOrd, config.Rotation, config.scale, this.equShow);
            this.equShowRT.anchoredPosition3D = config.RawImgPos;
 
            //设置装备条目属性
            SpiritWeaponConfig nextItemConfig = null;
            var attrCount = config.AttrIDList.Length;
            var beforeAttrValueTable = new Dictionary<int, int>();
            for (int i = 0; i < config.AttrIDList.Length; i++)
                beforeAttrValueTable[config.AttrIDList[i]] = config.AttrValueList[i];
 
            var beforeAttrs = SpiritEquipModel.Instance.GetBaseProperty(nowId).baseProperties;
            var baseAttrCount = beforeAttrs.Count;
 
            List<Int2> afterBaseAttrs = null;
            if (bIsMaxLevle == false)
            {
                afterBaseAttrs = SpiritEquipModel.Instance.GetBaseProperty(nextId).baseProperties;
                baseAttrCount = afterBaseAttrs.Count;
                nextItemConfig = SpiritWeaponConfig.Get(nextId);
                attrCount = nextItemConfig.AttrIDList.Length;
            }
 
            var totalAttrCount = attrCount + baseAttrCount;
            var attrLerpCount = totalAttrCount - this.attrTexts.Count;
            var attrPrefab = this.prefabs.Find("AttrGrid");
            for (int i = 0; i < attrLerpCount;  i++)
            {
                var attrGrid = GameObject.Instantiate(attrPrefab, this.equAttrContainer);
                attrGrid.SetActiveIL(true);
                attrGrid.localScale = Vector3.one;
                var attrText = attrGrid.FindComponentEx<Text>("Text_Info");
                attrTexts.Add(attrText);
            }
 
            for (int i = 0; i < attrTexts.Count; i++)
            {
                var attrText = attrTexts[i];
                if (i >= totalAttrCount)
                    attrText.transform.parent.SetActiveIL(false);
                else
                {
                    attrText.transform.parent.SetActiveIL(true);
                    PlayerPropertyConfig attrConfig;
                    var nowAttrValue = 0;
                    var afterAttrValue = 0;
                    if (i >= baseAttrCount)
                    {
                        var id = i - baseAttrCount;
                        if (nextItemConfig != null)
                        {
                            afterAttrValue = nextItemConfig.AttrValueList[id];
                            attrConfig = PlayerPropertyConfig.Get(nextItemConfig.AttrIDList[id]);
                            beforeAttrValueTable.TryGetValue(nextItemConfig.AttrIDList[id], out nowAttrValue);
                        }
                        else
                        {
                            attrConfig = PlayerPropertyConfig.Get(config.AttrIDList[id]);
                            nowAttrValue = config.AttrValueList[id];
                        }
                    }
                    else
                    {
                        if (afterBaseAttrs != null)
                            afterAttrValue = afterBaseAttrs[i].y;
                        if (i < beforeAttrs.Count)
                        {
                            attrConfig = PlayerPropertyConfig.Get(beforeAttrs[i].x);
                            nowAttrValue = beforeAttrs[i].y;
                        }
                        else
                        {
                            attrConfig = PlayerPropertyConfig.Get(afterBaseAttrs[i].x);
                        }
                    }
 
                    var attrName = "";
                    var attrCurValue = "";
                    var attrAddValue = "";
 
                    attrName = attrConfig.Name;
                    attrCurValue = PlayerPropertyConfig.GetValueDescription(attrConfig.ID, nowAttrValue, false);
                    if (afterAttrValue != 0 && afterAttrValue - nowAttrValue > 0)
                        attrAddValue = "+" + PlayerPropertyConfig.GetValueDescription(attrConfig.ID, afterAttrValue - nowAttrValue, false);
 
                    attrText.text = Language.Get("SpiritEquipText_1", attrName, attrCurValue, attrAddValue);
                }
            }
 
            if (bIsMaxLevle)
            {
                this.breachButton.SetActiveIL(false);
                //装备满级
                this.breachEquContianer.SetActiveIL(false);
                this.equAttrContainer.SetActiveIL(true);
                this.attrBg.SetActiveIL(true);
                this.otherBg.SetActiveIL(true);
                this.breachBg.SetActiveIL(false);
                this.maxTip.SetActiveIL(true);
                this.emptyTip.SetActiveIL(false);
            }
            else
            {
                this.breachButton.SetActiveIL(true);
                this.bIsCanBreach = true;
 
                //SpiritEquipModel.Instance.breachBtnRedPoint.state = SpiritEquipModel.Instance.redPoints[(int)this.curEquType].state;
                if(SpiritEquipModel.Instance.redBreachDic[(int)this.curEquType])
                {
                    SpiritEquipModel.Instance.breachBtnRedPoint.state = RedPointState.Simple;
                }
                else
                {
                    SpiritEquipModel.Instance.breachBtnRedPoint.state = RedPointState.None;
                }
                    
                //装备可升级
                this.breachEquContianer.SetActiveIL(true);
                this.equAttrContainer.SetActiveIL(true);
                this.attrBg.SetActiveIL(true);
                this.otherBg.SetActiveIL(false);
                this.breachBg.SetActiveIL(true);
                this.maxTip.SetActiveIL(false);
                this.emptyTip.SetActiveIL(false);
 
                //显示升级前后
                this.nowItemCell.Init(new ItemCellModel(nowId));
                this.nextItemCell.Init(new ItemCellModel(nextId));
                this.nowText.text = ItemConfig.Get(nowId).ItemName;
                this.nextText.text = ItemConfig.Get(nextId).ItemName;
                this.nowItemCell.button.SetListener(() =>
                {
                    ItemTipUtility.Show(nowId);
                });
                this.nextItemCell.button.SetListener(() =>
                {
                    ItemTipUtility.Show(nextId);
                });
 
                //显示升级材料
                var bHasDecideLessMat = false;
                var lerpCount = config.UpCostItem.Length - this.matGridBehaviours.Count;
                var matGridPrefab = this.prefabs.Find("MatGrid");
                for (int i = 0; i < lerpCount; i++)
                {
                    var matGrid = UnityEngine.Object.Instantiate(matGridPrefab, this.breachMatContainer);
                    matGrid.SetActiveIL(true);
                    matGrid.localScale = Vector3.one;
                    var matGridBehaviour = new MatGridBehaviour();
                    matGridBehaviour.BindController(matGrid);
                    matGridBehaviours.Add(matGridBehaviour);
                }
                for (int i = 0; i < matGridBehaviours.Count; i++)
                {
                    var bh = matGridBehaviours[i];
                    if (i >= config.UpCostItem.Length)
                        bh.Init();
                    else
                    {
                        var remainCount = this.packModel.GetItemCountByID(PackType.Item, config.UpCostItem[i].x);
                        bh.Init(config.UpCostItem[i], remainCount);
                        if (remainCount < config.UpCostItem[i].y)
                        {
                            this.bIsCanBreach = false;
                            if (bHasDecideLessMat == false)
                            {
                                bHasDecideLessMat = true;
                                this.lessMatID = config.UpCostItem[i].x;
                            }
                        }
                    }
                }
            }
        }
    }
}