少年修仙传客户端代码仓库
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
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
409
410
411
using System;
using UnityEngine;
using UnityEngine.UI;
 
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Events;
 
namespace vnxbqy.UI
{
    public class TreasureFindHostWin : Window
    {
        [SerializeField] RectTransform m_Content;
        [SerializeField] ScrollerController reciveConditionCtrl;
 
        [SerializeField] Button gotoBtn;
        [SerializeField] Text gotoText;
        [SerializeField] UIEffect effect;
        [SerializeField] GameObject alreadyGetImg;
        [SerializeField] Button treasureBtn;
        [SerializeField] Text getAwardDesText;
        [SerializeField] Text progressText;
 
        [SerializeField] Image treasureEffectImg1;
        [SerializeField] RawImage treasureIcon;
 
        [SerializeField] Text m_ReikiRemind;
 
        Button closeBtn;
        Button leftBtn;
        Button rightBtn;
 
        FunctionButtonGroup funcBtnGroup;
        List<FunctionButton> funcBtnlist = new List<FunctionButton>();
        List<RedpointBehaviour> funcRedlist = new List<RedpointBehaviour>();
        List<Text> funcTitlelist = new List<Text>();
 
        TreasureFindHostModel hostModel { get { return ModelCenter.Instance.GetModel<TreasureFindHostModel>(); } }
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        ReikiRootModel reikiRootModel { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
        TitleModel titleModel { get { return ModelCenter.Instance.GetModel<TitleModel>(); } }
 
        Dictionary<int, List<FindTreasureInfo>> findTreasureDict;
        int selectTreasureId = 0;
        List<FindTreasureInfo> findInfolist;
        List<FindTreasureInfo> orderFindlist = new List<FindTreasureInfo>();
        List<int> treasureIdlist;
        bool isOpenFirst = true;
        RectTransform moneyShow;
 
        protected override void BindController()
        {
            var oneLevelFrame = UIUtility.CreateWidget("OneLevelWin_Pattern_1", "Pivot");
            oneLevelFrame.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
            oneLevelFrame.transform.SetAsFirstSibling();
            var subWindowContainer = oneLevelFrame.transform.Find("Container_SubWindow");
            m_Content.SetParentEx(subWindowContainer, Vector3.zero, Quaternion.identity, Vector3.one);
 
            var titleIcon = oneLevelFrame.GetComponent<Image>("Container_BackGround/Img_Title");
            titleIcon.SetSprite("OneLevelTitle_22");
 
            funcBtnGroup = this.transform.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
            var functionContainer = funcBtnGroup.transform.Find("Content");
            for (int i = 0; i < 4; i++)
            {
                var instance = UIUtility.CreateWidget("FunctionButton_Pattern_1", StringUtility.Contact("FunctionButton_", i + 1));
                instance.transform.SetParentEx(functionContainer, Vector3.zero, Quaternion.identity, Vector3.one);
 
                var functionButton = instance.GetComponent<FunctionButton>();
                functionButton.order = i;
                functionButton.group = funcBtnGroup;
                funcBtnlist.Add(functionButton);
                funcRedlist.Add(functionButton.redpoint);
                funcTitlelist.Add(functionButton.title);
            }
 
            reciveConditionCtrl.OnRefreshCell += RefreshConditionCell;
            reciveConditionCtrl.lockType = EnhanceLockType.KeepVertical;
 
            moneyShow = oneLevelFrame.GetComponent<RectTransform>("Container_BackGround/FollowStoreBottom");
        }
 
        protected override void AddListeners()
        {
            leftBtn = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
            rightBtn = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
            closeBtn = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
 
            treasureBtn.AddListener(() => { WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)findInfolist[0].jumpId); });
            leftBtn.onClick.AddListener(OnClickLeftBtn);
            rightBtn.onClick.AddListener(OnClickRightBtn);
            closeBtn.AddListener(CloseClick);
            gotoBtn.AddListener(() => { WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)findInfolist[0].jumpId); });
        }
 
        protected override void OnPreOpen()
        {
            moneyShow.SetActive(false);
            isOpenFirst = true;
            hostModel.OnCompletedAct += OnCompleted;
            findTreasureDict = hostModel.GetFindTreasureInfoDict();
            treasureIdlist = findTreasureDict.Keys.ToList();
            selectTreasureId = treasureIdlist[0];
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            FuncBtnUICtrl();
            if (hostModel.jumpTreasureId == 0)
            {
                for (int i = funcBtnlist.Count - 1; i > -1; i--)
                {
                    if (i < treasureIdlist.Count)
                    {
                        if (funcBtnlist[i].state != TitleBtnState.Locked)
                        {
                            functionOrder = i;
                            break;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < treasureIdlist.Count; i++)
                {
                    if (treasureIdlist[i] == hostModel.jumpTreasureId)
                    {
                        functionOrder = i;
                        hostModel.jumpTreasureId = 0;
                        break;
                    }
                }
            }
 
            funcBtnGroup.TriggerByOrder(functionOrder);
        }
 
        protected override void OnAfterOpen()
        {
 
        }
 
        protected override void OnPreClose()
        {
            hostModel.OnCompletedAct -= OnCompleted;
        }
 
        protected override void OnAfterClose()
        {
            UI3DTreasureExhibition.Instance.Stop();
            for (int i = 0; i < funcBtnlist.Count; i++)
            {
                if (i < treasureIdlist.Count)
                {
                    funcBtnlist[i].OnPointClickLockFunc -= ClickLockBtn;
                }
            }
            if (!WindowJumpMgr.Instance.IsJumpState)
            {
                WindowCenter.Instance.Open<MainInterfaceWin>();
            }
        }
 
        void DisplayReikiRemind()
        {
            m_ReikiRemind.SetActive(reikiRootModel.treasureAddPoint.treasureId == selectTreasureId);
            if (reikiRootModel.treasureAddPoint.treasureId == selectTreasureId)
            {
                var reikiPoint = 0;
                if (PlayerDatas.Instance.baseData.LV >= reikiRootModel.reikiPointAutoAddLevel)
                {
                    reikiPoint = (PlayerDatas.Instance.baseData.LV - reikiRootModel.reikiPointAutoAddLevel + 1)
                        * reikiRootModel.treasureAddPoint.point;
                }
                m_ReikiRemind.text = Language.Get("FairyTreasure_14", reikiPoint);
            }
        }
 
        private void FuncBtnUICtrl()
        {
            for (int i = 0; i < funcBtnlist.Count; i++)
            {
                funcBtnlist[i].RemoveAllListeners();
                if (i < treasureIdlist.Count)
                {
                    funcBtnlist[i].OnPointClickLockFunc += ClickLockBtn;
                    funcBtnlist[i].SetActive(true);
                    int treasureId = treasureIdlist[i];
                    int index = i;
                    TreasureConfig config = TreasureConfig.Get(treasureId);
                    if (config != null)
                    {
                        funcRedlist[i].redpointId = hostModel.GetTreasureCellRedIdById(treasureId);
                        funcTitlelist[i].text = config.Name;
                    }
                    funcBtnlist[i].AddListener(() => { ClickTitleBtn(treasureId, index); });
 
                    if (i != 0)
                    {
                        int preTreasureId = treasureIdlist[i - 1];
                        Treasure treasure = null;
                        treasureModel.TryGetTreasure(preTreasureId, out treasure);
 
                        if (treasure != null && treasure.state != TreasureState.Collected)
                        {
                            funcBtnlist[i].state = TitleBtnState.Locked;
                        }
                        else if (treasure != null && treasure.state == TreasureState.Collected)
                        {
                            funcBtnlist[i].state = TitleBtnState.Normal;
                        }
                    }
                }
                else
                {
                    funcBtnlist[i].SetActive(false);
                }
            }
        }
 
        private void ClickLockBtn(string key)
        {
            int index = int.Parse(key.Substring(key.Length - 1, 1)) - 2;
            TreasureConfig config = TreasureConfig.Get(treasureIdlist[index]);
            if (config != null)
            {
                SysNotifyMgr.Instance.ShowTip("UnLock_TreasureLimit", config.Name);
            }
 
        }
 
        private void OnClickLeftBtn()
        {
            funcBtnGroup.TriggerLast();
        }
 
        private void OnClickRightBtn()
        {
            funcBtnGroup.TriggerNext();
        }
 
        private void ClickTitleBtn(int treasureId, int index)
        {
            if (isOpenFirst)
            {
                isOpenFirst = false;
            }
            else
            {
                if (treasureId == selectTreasureId)
                {
                    return;
                }
            }
 
            selectTreasureId = treasureId;
            hostModel.SetSelectTreasureId(treasureId);
            UI3DTreasureExhibition.Instance.ShowTreasure(selectTreasureId, treasureIcon);
            CreateConditionCell();
            functionOrder = index;
        }
 
        private void RefreshTreasureUI()
        {
            TreasureConfig config = TreasureConfig.Get(selectTreasureId);
            if (config == null) return;
 
            DisplayReikiRemind();
 
            string[] treasureEffectImgs = TreasureFindHostConfig.Get(findInfolist[0].id).EffectIconKeys;
            treasureEffectImg1.SetSprite(treasureEffectImgs[0]);
            treasureEffectImg1.SetNativeSize();
            getAwardDesText.text = Language.Get("TreasureFindHost_UnLock", config.Name);
            int progress = 0;
            Treasure treasure = null;
            treasureModel.TryGetTreasure(selectTreasureId, out treasure);
            if (hostModel.IsReachUnlock(selectTreasureId, out progress))
            {
                if (!effect.IsPlaying && treasure.state != TreasureState.Collected)
                {
                    effect.Play();
                }
                else
                {
                    effect.Stop();
                }
                progressText.text = UIHelper.AppendColor(TextColType.Green, StringUtility.Contact("(", progress, "/", findInfolist.Count, ")"), true);
            }
            else
            {
                if (effect.IsPlaying)
                {
                    effect.Stop();
                }
                progressText.text = UIHelper.AppendColor(TextColType.Red, StringUtility.Contact("(", progress, "/", findInfolist.Count, ")"));
            }
            gotoBtn.SetActive(true);
            if (treasure.state == TreasureState.Collected)
            {
                alreadyGetImg.SetActive(true);
                gotoText.text = Language.Get("TreasureFindHost_UnLock2");
            }
            else
            {
                alreadyGetImg.SetActive(false);
                gotoText.text = Language.Get("TreasureFindHost_UnLock1");
            }
        }
 
        private void OnCompleted()
        {
            CreateConditionCell();
            int progress = 0;
            if (hostModel.IsReachUnlock(selectTreasureId, out progress))
            {
                SysNotifyMgr.Instance.ShowTip("TreasureFindHost2");
            }
            else
            {
                SysNotifyMgr.Instance.ShowTip("TreasureFindHost1");
            }
 
        }
 
        private void CreateConditionCell()
        {
            findInfolist = findTreasureDict[selectTreasureId];
            RefreshTreasureUI();
            orderFindlist.Clear();
            orderFindlist.AddRange(findInfolist);
            orderFindlist.Sort(CompareByState);
            reciveConditionCtrl.Refresh();
            for (int i = 0; i < orderFindlist.Count; i++)
            {
                reciveConditionCtrl.AddCell(ScrollerDataType.Header, orderFindlist[i].id);
            }
            reciveConditionCtrl.Restart();
            reciveConditionCtrl.JumpIndex(0);
        }
 
        private int CompareByState(FindTreasureInfo start, FindTreasureInfo next)
        {
            bool x = IsReach(start);
            bool y = IsReach(next);
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
 
            x = IsNoReach(start);
            y = IsNoReach(next);
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
 
            x = start.IsCompleted;
            y = next.IsCompleted;
            if (x.CompareTo(y) != 0) return x.CompareTo(y);
 
            int orderx = findInfolist.IndexOf(start);
            int ordery = findInfolist.IndexOf(next);
            if (orderx.CompareTo(ordery) != 0) return orderx.CompareTo(ordery);
 
            return 0;
        }
 
        private bool IsReach(FindTreasureInfo info)
        {
            if (info.IsCompleted)
            {
                return false;
            }
            else
            {
                int process;
                if (hostModel.IsReachCondition(info, out process))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
 
        private bool IsNoReach(FindTreasureInfo info)
        {
            if (info.IsCompleted)
            {
                return false;
            }
            else
            {
                int process;
                if (hostModel.IsReachCondition(info, out process))
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }
 
        private void RefreshConditionCell(ScrollerDataType type, CellView cell)
        {
            ReciveConditionCell conditionCell = cell.GetComponent<ReciveConditionCell>();
            conditionCell.Display(cell.index);
        }
 
    }
}