少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, July 18, 2018
//--------------------------------------------------------
 
using Spine;
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
//砍树获得装备界面
namespace vnxbqy.UI
{
    public class EquipExchangeWin : Window
    {
        [SerializeField] EquipExchangeCell oldEquipObj;
        [SerializeField] EquipExchangeCell newEquipObj;
        [SerializeField] List<Image> baseAttrStates;
        [SerializeField] List<Image> fightAttrStates;
        [SerializeField] Text fightPowerNum;
        [SerializeField] Toggle decomposeCheck;
        [SerializeField] Button decomposeButton;
        [SerializeField] Button exchangeButton;
        [SerializeField] Button putonButton;
        [SerializeField] Button closeButton;
 
 
        ItemModel oldEquip;
 
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        CutTreeModel cutTreeModel { get { return ModelCenter.Instance.GetModel<CutTreeModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        AutoCutTreeModel autoCutTreeModel { get { return ModelCenter.Instance.GetModel<AutoCutTreeModel>(); } }
        #region Built-in
 
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            decomposeCheck.onValueChanged.AddListener((bool isOn) => {
                LocalSave.SetBool("floorEDecomp" + PlayerDatas.Instance.baseData.PlayerID, isOn);
            });
            decomposeButton.AddListener(DecomposeEquip);
            exchangeButton.AddListener(ExchangeEquip);
            putonButton.AddListener(() =>
            {
                cutTreeModel.SendCutTreeEquipOP(new byte[] { (byte)cutTreeModel.selectFloorEquip.gridIndex }, 1);
                CloseClick();
            });
            closeButton.AddListener(CloseClick);
        }
 
 
        protected override void OnPreOpen()
        {
            decomposeCheck.isOn = LocalSave.GetBool("floorEDecomp" + PlayerDatas.Instance.baseData.PlayerID);
            packModel.refreshItemCountEvent += OnRefreshItem;
            Display();
            if (cutTreeModel.newEquipIDToGuideID.ContainsKey(cutTreeModel.selectFloorEquip.itemId))
            {
                if (!NewBieCenter.Instance.IsGuideCompleted(cutTreeModel.newEquipIDToGuideID[cutTreeModel.selectFloorEquip.itemId]))
                    NewBieCenter.Instance.StartNewBieGuideEx(cutTreeModel.newEquipIDToGuideID[cutTreeModel.selectFloorEquip.itemId]);
            }
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            packModel.refreshItemCountEvent -= OnRefreshItem;
        }
 
        protected override void OnAfterClose()
        {
        }
 
        #endregion
 
        void Display()
        {
            oldEquip = GetEquipByFloorEquip();
            int oldScore = 0;
            if (oldEquip == null)
            {
                oldEquipObj.SetActive(false);
                newEquipObj.SetActive(true);
                newEquipObj.Display(cutTreeModel.selectFloorEquip);
                decomposeButton.SetActive(false);
                exchangeButton.SetActive(false);
                putonButton.SetActive(true);
                decomposeCheck.SetActive(false);
                oldScore = 0;
            }
            else
            {
                oldEquipObj.SetActive(true);
                newEquipObj.SetActive(true);
                oldEquipObj.Display(oldEquip);
                newEquipObj.Display(cutTreeModel.selectFloorEquip);
                decomposeButton.SetActive(true);
                exchangeButton.SetActive(true);
                putonButton.SetActive(false);
                decomposeCheck.SetActive(true);
                oldScore = oldEquip.score;
 
            }
            ShowAttrState();
            int showFightPower = EquipFightPower.Instance.GetFightPowerBuyScore(cutTreeModel.selectFloorEquip.score - oldScore);
 
            if (showFightPower < 0)
            {
                fightPowerNum.text = showFightPower.ToString();
                fightPowerNum.color = UIHelper.GetUIColor(TextColType.Red, true);
            }
            else
            {
                fightPowerNum.text = "+" + showFightPower;
                fightPowerNum.color = UIHelper.GetUIColor(TextColType.Green, true);
            }
        }
 
 
        void ShowAttrState()
        {
            if (oldEquip == null)
            {
                for (int i = 0; i < baseAttrStates.Count; i++)
                {
                    var list = equipModel.GetEquipBaseValues(cutTreeModel.selectFloorEquip);
                    if (list == null || i >= list.Count)
                    {
                        baseAttrStates[i].SetActive(false);
                    }
                    else
                    {
                        baseAttrStates[i].SetActive(true);
                        baseAttrStates[i].SetSprite("EquipUpIcon");
                        baseAttrStates[i].SetNativeSize();
                    }
                }
 
                for (int i = 0; i < fightAttrStates.Count; i++)
                {
                    var list = equipModel.GetEquipFightValues(cutTreeModel.selectFloorEquip);
                    if (list == null || i >= list.Count)
                    {
                        fightAttrStates[i].SetActive(false);
                    }
                    else
                    {
                        fightAttrStates[i].SetActive(true);
                        fightAttrStates[i].SetSprite("EquipAttrNew");
                        fightAttrStates[i].SetNativeSize();
                    }
                }
 
                return;
            }
 
 
            //基础属性 排序和个数是一致的
            for (int i = 0; i < baseAttrStates.Count; i++)
            {
                var list = equipModel.GetEquipBaseValues(cutTreeModel.selectFloorEquip);
                var list2 = equipModel.GetEquipBaseValues(oldEquip);
                if (list == null || i >= list.Count)
                {
                    baseAttrStates[i].SetActive(false);
                }
                else
                {
                    baseAttrStates[i].SetActive(true);
                    var value = i < list2.Count ? list2[i] : 0;
                    if (list[i] == value)
                    {
                        baseAttrStates[i].SetActive(false);
                    }
                    else
                    {
                        baseAttrStates[i].SetActive(true);
                        baseAttrStates[i].SetSprite(value == 0 ? "EquipAttrNew" : list[i] > value ? "EquipUpIcon" : "EquipDownIcon");
                        baseAttrStates[i].SetNativeSize();
                    }
                }
            }
 
            for (int i = 0; i < fightAttrStates.Count; i++)
            {
                //战斗属性 排序和个数不一致 根据ID进行对比
                var list = equipModel.GetEquipFightValues(cutTreeModel.selectFloorEquip);
                var list2 = equipModel.GetEquipFightValues(oldEquip);
 
                var idList = equipModel.GetEquipFightAttrs(cutTreeModel.selectFloorEquip);
                var idList2 = equipModel.GetEquipFightAttrs(oldEquip);
 
                if (list == null || i >= list.Count)
                {
                    fightAttrStates[i].SetActive(false);
                }
                else
                {
                    fightAttrStates[i].SetActive(true);
                    var value = !list2.IsNullOrEmpty() && i < list2.Count ? list2[i] : 0;
                    var id = !idList2.IsNullOrEmpty() && i < idList2.Count ? idList2[i] : 0;
                    if (idList[i] == id && list[i] == value)
                    {
                        fightAttrStates[i].SetActive(false);
                    }
                    else
                    {
                        fightAttrStates[i].SetActive(true);
                        if (idList[i] != id)
                        {
                            fightAttrStates[i].SetSprite("EquipAttrNew");
                        }
                        else
                        {
                            fightAttrStates[i].SetSprite(list[i] > value ? "EquipUpIcon" : "EquipDownIcon");
                        }
                        fightAttrStates[i].SetNativeSize();
 
                    }
                }
            }
        }
 
        //获取地板装备对应的身上装备
        ItemModel GetEquipByFloorEquip()
        {
            var equipGuid = equipModel.GetEquip(new Int2(PlayerDatas.Instance.baseData.suitLevel, cutTreeModel.selectFloorEquip.config.EquipPlace));
            if (string.IsNullOrEmpty(equipGuid))
                return null;
            return packModel.GetItemByGuid(equipGuid);
        }
 
        void DecomposeEquip()
        {
            //战力判定进行二次确认
            if (!cutTreeModel.dontNotifyDecompose && cutTreeModel.selectFloorEquip.score > oldEquip.score)
            {
                ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"),
                Language.Get("EquipExchangeWin5"),
                Language.Get("FlyShoseConfirmwin_Text2"), (bool ok, bool isToggle) =>
                {
                    if (isToggle)
                    {
                        cutTreeModel.dontNotifyDecompose = true;
                    }
 
                    if (ok)
                    {
                        autoCutTreeModel.isWaitPlayer = false;
                        cutTreeModel.SendCutTreeEquipOP(new byte[] { (byte)cutTreeModel.selectFloorEquip.gridIndex }, 2);
                    }
                    else
                    {
                        WindowCenter.Instance.Open<EquipExchangeWin>();
                    }
                }, Language.Get("EquipExchangeWin6"));
            }
            else
            {
                autoCutTreeModel.isWaitPlayer = false;
                cutTreeModel.SendCutTreeEquipOP(new byte[] { (byte)cutTreeModel.selectFloorEquip.gridIndex }, 2);
            }
            CloseClick();
        }
 
        void ExchangeEquip()
        {
            //战力判定进行二次确认
            if (!cutTreeModel.dontNotifyExchangeDecompose && cutTreeModel.selectFloorEquip.score < oldEquip.score && decomposeCheck.isOn)
            {
                ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"),
                    Language.Get("EquipExchangeWin4"),
                    Language.Get("FlyShoseConfirmwin_Text2"), (bool ok, bool isToggle) =>
                    {
                        if (isToggle)
                        {
                            cutTreeModel.dontNotifyExchangeDecompose = true;
                        }
 
                        if (ok)
                        {                 
                            autoCutTreeModel.isWaitPlayer = false;
                            cutTreeModel.SendCutTreeEquipOP(new byte[] { (byte)cutTreeModel.selectFloorEquip.gridIndex }, 1, decomposeCheck.isOn);
                        }
                        else
                        {
                            WindowCenter.Instance.Open<EquipExchangeWin>();
                        }
                    }, Language.Get("ItemHandle_Replace"));
            }
            else
            {
                autoCutTreeModel.isWaitPlayer = false;
                cutTreeModel.SendCutTreeEquipOP(new byte[] { (byte)cutTreeModel.selectFloorEquip.gridIndex }, 1, decomposeCheck.isOn);
            }
 
            if (decomposeCheck.isOn)
            {
                CloseClick();
            }
        }
 
        void OnRefreshItem(PackType packType, int index, int itemID)
        {
            if (packType == PackType.EquipOnFloor)
            {
                Display();
            }
        }
 
 
    }
 
}