少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-13 c7f64d977c4e2884d5411a5a2d0f37b6afa52963
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
using UnityEngine.UI;
using UnityEngine;
 
using System;
using System.Collections.Generic;
using DG.Tweening;
using Snxxz.UI;
using System.Collections;
using System.Linq;
 
namespace Snxxz.UI
{
    public class GetEquipPathWin : Window
    {
        #region 成员变量
        [SerializeField]
        protected ItemCell _itemCell;
 
        [SerializeField]
        protected Text _nameText;
 
        [SerializeField]
        Text equipScoreDes;
        [SerializeField]
        Text equipScoreValue;
        [SerializeField]
        Text needLvDes;
        [SerializeField]
        Text needLvValue;
        [SerializeField]
        Text realmTitleText;
        [SerializeField] Image realmImg;
 
        [SerializeField]
        List<Text> needPointTextlist = new List<Text>();
        [SerializeField]
        List<Text> needPointNumlist = new List<Text>();
 
        [SerializeField]
        protected Button _closeBtn;
 
        [SerializeField]
        protected GameObject _bottomPart;
 
        [SerializeField]
        private Button _getItemBtn;
 
        [SerializeField]
        protected RectTransform _itemInfoTips;
 
        [SerializeField]
        protected CanvasGroup _getWaysTips;
 
        [SerializeField]
        private ScrollerController _waysCtrl;
 
        [SerializeField]
        private Transform waysLineCell;
 
        [SerializeField]
        private Button _closeWaysBtn;
 
        [SerializeField]
        [Header("初始移动坐标")]
        protected float startPosX = 400f;
        [SerializeField]
        [Header("结束坐标")]
        protected float endPosX = 272f;
        [SerializeField]
        [Header("移动时间")]
        protected float _moveTime = 0.3f;
 
        [SerializeField]
        protected CanvasGroup tipAlpha;
        #region MidUI
        [Header("装备属性部分")]
        [SerializeField]
        RectTransform attrContent;
        [SerializeField]
        ScrollRect scrollRect;
        [SerializeField]
        LayoutElement scrollLayout;
 
        [SerializeField]
        GameObject basicAttr;
        [SerializeField]
        Text basicTitleText;
        [SerializeField]
        Text basicAttrDes;
 
        [SerializeField]
        GameObject exhaustedAttr;
        [SerializeField]
        Text exhaustedTitleText;
        [SerializeField]
        Text exhaustedAttrDes;
 
        [SerializeField]
        GameObject legendAttr;
        [SerializeField]
        Text legendTitleText;
        [SerializeField]
        Text legendCntPreview;
        [SerializeField]
        Text legendAttrDes;
 
        [SerializeField]
        GameObject gemAttr;
        [SerializeField]
        Text gemTitleText;
        [SerializeField]
        List<GemElementObj> gemObjlist = new List<GemElementObj>();
        #endregion
 
        #endregion
 
        GetItemPathModel _itemPathModel;
        protected GetItemPathModel itemPathModel
        {
            get
            {
                return _itemPathModel ?? (_itemPathModel = ModelCenter.Instance.GetModel<GetItemPathModel>());
            }
        }
 
        DailyQuestModel _questModel;
        protected DailyQuestModel QuestModel
        {
            get { return _questModel ?? (_questModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); }
        }
 
        ItemTipsModel _itemTipsModel;
        ItemTipsModel itemTipsModel
        {
            get
            {
                return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
            }
        }
 
        PackModelInterface _modelInterface;
        PackModelInterface modelInterface
        {
            get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); }
        }
 
        Dictionary<AttrEnum, int> needPointDict = new Dictionary<AttrEnum, int>();
 
        Color32 conditionColor = new Color32(255, 244, 205, 255);
        Color32 conditionRedColor = new Color32(255, 1, 1, 255);
 
        ItemAttrData itemAttrData;
 
        protected override void BindController()
        {
            _waysCtrl.OnRefreshCell += RefreshWayCell;
        }
 
        protected override void AddListeners()
        {
            _closeBtn.onClick.AddListener(CloseWin);
            _getItemBtn.onClick.AddListener(OnClickGetItemBtn);
            _closeWaysBtn.onClick.AddListener(CloseWin);
        }
 
        protected override void OnPreOpen()
        {
            _bottomPart.gameObject.SetActive(false);
            InitUI();
        }
 
        protected override void OnAfterOpen()
        {
            transform.SetAsLastSibling();
            StartCoroutine(SetScrollSize());
        }
 
        protected override void OnPreClose()
        {
 
        }
 
        protected override void OnAfterClose()
        {
            
        }
 
        #region iteminfoTips逻辑
 
        protected virtual IEnumerator SetScrollSize()
        {
            yield return null;
            yield return null;
            attrContent.anchoredPosition3D = new Vector3(attrContent.anchoredPosition3D.x, 0, 0);
            SetMidUIHeight(attrContent.rect.height);
            StartCoroutine(ShowBottomPart());
        }
 
        IEnumerator ShowBottomPart()
        {
            yield return null;
            _bottomPart.SetActive(true);
            StartCoroutine(SetPanelScale());
        }
 
        IEnumerator SetPanelScale()
        {
            yield return null;
            _itemInfoTips.anchoredPosition3D = new Vector3(startPosX, 0, 0);
            itemPathModel.SetInfoTipsPos(_itemInfoTips.GetComponent<RectTransform>(),_getWaysTips.GetComponent<RectTransform>());
            tipAlpha.alpha = 1;
        }
 
        private void InitUI()
        {
            if (itemPathModel.chinItemModel == null)
                return;
 
            itemAttrData = new ItemAttrData(itemPathModel.chinItemModel.ID,true,0,-1, itemPathModel.isBind);
            _closeBtn.gameObject.SetActive(true);
            _getWaysTips.alpha = 0;
            tipAlpha.alpha = 0;
            SetTopUI();
            SetMidUI();
        }
 
        private void SetTopUI()
        {
            ItemCellModel cellModel = new ItemCellModel(itemAttrData.itemId,false,0, itemPathModel.isBind);
            _itemCell.Init(cellModel);
            _nameText.text = itemAttrData.itemConfig.ItemName;
            _nameText.color = UIHelper.GetUIColor(itemAttrData.itemConfig.ItemColor);
            equipScoreDes.text = Language.Get("EquipWin_EquipPointText_1");
            equipScoreValue.text = itemAttrData.score.ToString();
            CheckUselimit();
        }
 
        private void CheckUselimit()
        {
            int[] uselimits = itemAttrData.itemConfig.UseCondiType;
            if (uselimits == null) return;
 
            needLvValue.gameObject.SetActive(false);
            needLvDes.gameObject.SetActive(false);
            realmTitleText.gameObject.SetActive(false);
            realmImg.gameObject.SetActive(false);
            for (int i = 0; i < needPointTextlist.Count; i++)
            {
                needPointTextlist[i].gameObject.SetActive(false);
                needPointNumlist[i].gameObject.SetActive(false);
            }
            for (int i = 0; i < uselimits.Length; i++)
            {
                switch (uselimits[i])
                {
                    case 0:
                        if (itemAttrData.itemConfig.UseLV > 1)
                        {
                            needLvValue.gameObject.SetActive(true);
                            needLvDes.gameObject.SetActive(true);
                        }
                        needLvDes.text = Language.Get("KnapS110");
                        if (itemAttrData.isHavePutLimit)
                        {
                            needLvValue.text = itemAttrData.itemConfig.UseLV.ToString();
                            if (PlayerDatas.Instance.baseData.LV >= itemAttrData.itemConfig.UseLV)
                            {
                                needLvValue.color = conditionColor;
                                needLvDes.color = conditionColor;
                            }
                            else
                            {
                                needLvValue.color = UIHelper.GetUIColor(TextColType.Red);
                                needLvDes.color = UIHelper.GetUIColor(TextColType.Red);
                            }
                        }
                        else
                        {
                            needLvValue.text = 1.ToString();
                            needLvDes.color = conditionColor;
                            needLvValue.color = conditionColor;
                        }
 
                        break;
                    case 1:
                        realmTitleText.gameObject.SetActive(true);
                        realmImg.gameObject.SetActive(true);
                        realmTitleText.text = Language.Get("RealmLimit1");
                        RealmConfig realmConfig = RealmConfig.Get(itemAttrData.itemConfig.RealmLimit);
                        if (itemAttrData.itemConfig.RealmLimit <= 0)
                        {
                            realmImg.SetSprite("NoRealm");
                        }
                        else
                        {
                            if (realmConfig != null)
                            {
                                realmImg.SetSprite(realmConfig.Img);
                            }
                        }
 
                        if (PlayerDatas.Instance.baseData.realmLevel >= itemAttrData.itemConfig.RealmLimit)
                        {
                            realmTitleText.color = conditionColor;
                        }
                        else
                        {
                            realmTitleText.color = UIHelper.GetUIColor(TextColType.Red);
                        }
                        break;
                    case 2:
                        RefreshNeedPointUI();
                        break;
                }
            }
 
        }
 
        private void RefreshNeedPointUI()
        {
            needPointDict.Clear();
            if (itemPathModel.chinItemModel.LimitSTR > 0)
            {
                needPointDict.Add(AttrEnum.POWER, itemPathModel.chinItemModel.LimitSTR);
            }
 
            if (itemPathModel.chinItemModel.LimitPHY > 0)
            {
                needPointDict.Add(AttrEnum.AGILITY, itemPathModel.chinItemModel.LimitPHY);
            }
 
            if (itemPathModel.chinItemModel.LimitPNE > 0)
            {
                needPointDict.Add(AttrEnum.MENTALITY, itemPathModel.chinItemModel.LimitPNE);
            }
 
            List<AttrEnum> needlist = needPointDict.Keys.ToList();
 
            int i = 0;
            for (i = 0; i < needPointTextlist.Count; i++)
            {
                if (i < needlist.Count)
                {
                    needPointTextlist[i].gameObject.SetActive(true);
                    needPointNumlist[i].gameObject.SetActive(true);
                    switch (needlist[i])
                    {
                        case AttrEnum.POWER:
                            if (itemAttrData.isHavePutLimit)
                            {
                                SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS113"));
                            }
                            else
                            {
                                SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS113"));
                            }
                            break;
                        case AttrEnum.AGILITY:
                            if (itemAttrData.isHavePutLimit)
                            {
                                SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS112"));
                            }
                            else
                            {
                                SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS112"));
                            }
 
                            break;
                        case AttrEnum.MENTALITY:
                            if (itemAttrData.isHavePutLimit)
                            {
                                SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS111"));
                            }
                            else
                            {
                                SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS111"));
                            }
                            break;
                    }
 
                }
                else
                {
                    needPointTextlist[i].gameObject.SetActive(false);
                    needPointNumlist[i].gameObject.SetActive(false);
                }
            }
 
        }
 
        private void SetNeedPointUI(float needPoint,Text needPoinText, Text needPoinNum, string msg)
        {
            needPoinNum.color = conditionColor;
            needPoinText.color = conditionColor;
            needPoinNum.text = needPoint.ToString();
            needPoinText.text = msg;
        }
 
        private void SetMidUI()
        {
            SetBasicAttrUI();
            SetExhaustedAttrUI();
            SetLegendAttrUI();
            SetGemAttrUI();
        }
 
        #region 设置属性UI
        private void SetBasicAttrUI()
        {
            basicAttr.SetActive(true);
            basicTitleText.text = Language.Get("RolePanel_BaseAttrText_1");
            basicAttrDes.text = itemTipsModel.GetBasicAttr(itemAttrData);
        }
 
        private void SetExhaustedAttrUI()
        {
            if (itemAttrData.exhaustedMaxDataDict == null)
            {
                exhaustedAttr.SetActive(false);
                return;
            }
            exhaustedAttr.SetActive(true);
            exhaustedTitleText.text = Language.Get("EquipWin_ExtinctPropObj_Text_1");
            exhaustedAttrDes.text = itemTipsModel.GetExhaustedAtrr(itemAttrData);
        }
 
        private void SetLegendAttrUI()
        {
            if (itemAttrData.legendDataDict == null)
            {
                legendAttr.SetActive(false);
                return;
            }
 
            legendAttr.SetActive(true);
            legendTitleText.text = Language.Get("EquipWin_LegendPropObj_Text_1");
            legendAttrDes.text = itemTipsModel.GetLegendAttr(itemAttrData);
 
            if (itemAttrData.isPreview)
            {
                legendCntPreview.gameObject.SetActive(true);
                switch (itemAttrData.itemConfig.EquipPlace)
                {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 10:
                    case 12:
                        legendCntPreview.text = itemTipsModel.GetEquipLegendAttrCntPreview(itemAttrData);
                        break;
                    case 11:
                        legendCntPreview.text = itemTipsModel.GetWingsLegendAttrCntPreview(itemAttrData);
                        break;
                    case 101:
                    case 102:
                    case 103:
                    case 104:
                    case 105:
                        legendCntPreview.text = itemTipsModel.GetDogzLegendAttrCntPreview(itemAttrData);
                        break;
                }
            }
            else
            {
                legendCntPreview.gameObject.SetActive(false);
            }
        }
 
 
        private void SetGemAttrUI()
        {
            var packType = GeneralDefine.GetPackTypeByItemType(itemAttrData.itemConfig.Type);
            int[] gemOpenLvs = packType == PackType.rptJadeDynastyItem ? itemTipsModel.jadeDynastyGemOpenLvs : itemTipsModel.gemOpenLvs;
            switch ((RoleEquipType)itemAttrData.itemConfig.EquipPlace)
            {
                case RoleEquipType.retWeapon:
                case RoleEquipType.retWeapon2:
                case RoleEquipType.retHat:
                case RoleEquipType.retClothes:
                case RoleEquipType.retBelt:
                case RoleEquipType.retTrousers:
                case RoleEquipType.retShoes:
                case RoleEquipType.retNeck:
                case RoleEquipType.retFairyCan:
                case RoleEquipType.retFairyCan2:
                case RoleEquipType.retSpiritAnimal:
                case RoleEquipType.JadeDynasty_Cloak:
                case RoleEquipType.JadeDynasty_FaceMask:
                case RoleEquipType.JadeDynasty_Glove1:
                case RoleEquipType.JadeDynasty_Glove2:
                case RoleEquipType.JadeDynasty_Pendant:
                case RoleEquipType.JadeDynasty_Ring1:
                case RoleEquipType.JadeDynasty_Ring2:
                case RoleEquipType.JadeDynasty_Ruyi:
                case RoleEquipType.JadeDynasty_Sword1:
                case RoleEquipType.JadeDynasty_Sword2:
                case RoleEquipType.JadeDynasty_Sword3:
                case RoleEquipType.JadeDynasty_Sword4:
                    if (itemAttrData.itemConfig.LV < gemOpenLvs[0])
                    {
                        gemAttr.SetActive(false);
                        return;
                    }
                    break;
                case RoleEquipType.retWing:
                    gemAttr.SetActive(false);
                    return;
            }
            gemAttr.SetActive(true);
            gemTitleText.text = Language.Get("EquipWin_GemPropObj_Text_1");
            int cnt = 0;
            int vipCnt = 0;
            if (itemAttrData.itemConfig.LV >= gemOpenLvs[0])
            {
                cnt++;
            }
 
            if (itemAttrData.itemConfig.LV >= gemOpenLvs[1])
            {
                cnt++;
            }
 
            if (itemAttrData.itemConfig.LV >= gemOpenLvs[2])
            {
                cnt++;
            }
 
            if (PlayerDatas.Instance.baseData.VIPLv >= itemTipsModel.gemOpenVipLv)
            {
                vipCnt++;
            }
 
            int i = 0;
            for (i = 0; i < gemObjlist.Count; i++)
            {
                int stoneId = 0;
                if (itemAttrData.stones != null)
                {
                    if (i < itemAttrData.stones.Length)
                    {
                        stoneId = (int)itemAttrData.stones[i];
                    }
                }
 
                if (i < gemObjlist.Count - 1)
                {
                    if (i < cnt)
                    {
 
                        gemObjlist[i].gameObject.SetActive(true);
                        gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, false);
                    }
                    else
                    {
                        gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, true);
                        gemObjlist[i].gameObject.SetActive(false);
                    }
 
                }
                else
                {
                    if (vipCnt != 0)
                    {
                        gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, false);
                    }
                    else
                    {
                        gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, true);
                    }
                }
            }
        }
 
 
        protected virtual void SetMidUIHeight(float midHeight)
        {
            scrollRect.enabled = false;
 
            if (midHeight < itemTipsModel.equipMidHeights[0])
            {
                scrollLayout.preferredHeight = itemTipsModel.equipMidHeights[0];
            }
            else if (midHeight > itemTipsModel.equipMidHeights[1])
            {
                scrollRect.enabled = true;
                scrollLayout.preferredHeight = itemTipsModel.equipMidHeights[1];
            }
            else
            {
                scrollLayout.preferredHeight = midHeight;
            }
        }
        #endregion
 
        #region 点击事件
        private void OnClickGetItemBtn()
        {
            if(_getWaysTips.alpha <= 0)
            {
                Vector3 pos = new Vector3(endPosX, _itemInfoTips.anchoredPosition3D.y, 0);
                _itemInfoTips.DOAnchorPos3D(pos, _moveTime);
                _getWaysTips.DOFade(1, _moveTime);
                _closeBtn.gameObject.SetActive(false);
                CreateWayCell();
            }
            else
            {
                Vector3 pos = new Vector3(startPosX, _itemInfoTips.anchoredPosition3D.y, 0);
                _itemInfoTips.DOAnchorPos3D(pos, _moveTime);
                _getWaysTips.DOFade(0, _moveTime);
                _closeBtn.gameObject.SetActive(true);
            }
          
        }
 
        private void CloseWin()
        {
            itemPathModel.ResetAllModel();
            Close();
        }
        #endregion
 
        #endregion
 
        #region getWaysTips逻辑
        private List<GetItemWaysConfig> getWayslist;
        protected virtual void CreateWayCell()
        {
            getWayslist = itemPathModel.GetWaysList(itemPathModel.chinItemModel);
            _waysCtrl.Refresh();
            int i = 0;
            int remain = getWayslist.Count % waysLineCell.childCount;
            int line = (int)getWayslist.Count / waysLineCell.childCount;
            if (remain > 0)
            {
                line += 1;
            }
 
            for (i = 0; i < line; i++)
            {
                _waysCtrl.AddCell(ScrollerDataType.Header,i);
            }
            _waysCtrl.Restart();
        }
 
        private void RefreshWayCell(ScrollerDataType type, CellView cell)
        {
            int i = 0;
            for(i = 0; i < cell.transform.childCount; i++)
            {
                WayCell wayCell = cell.transform.GetChild(i).GetComponent<WayCell>();
                if (wayCell == null)
                    wayCell = cell.transform.GetChild(i).gameObject.AddComponent<WayCell>();
 
                int index = (cell.transform.childCount) * cell.index + i;
                if(index <= getWayslist.Count - 1)
                {
                    cell.transform.GetChild(i).gameObject.SetActive(true);
                    GetItemWaysConfig itemWaysModel = getWayslist[index];
                    wayCell.icon.SetSprite(itemWaysModel.Icon);
                    wayCell.wayName.text = itemWaysModel.Text;
                    wayCell.funcName.text = itemWaysModel.name;
                    wayCell.wayButton.RemoveAllListeners();
                    wayCell.wayButton.AddListener(()=> {
                        ClickWayCell(itemWaysModel);
                    });
                }
                else
                {
                    cell.transform.GetChild(i).gameObject.SetActive(false);
                }
            }
        }
 
        public void ClickWayCell(GetItemWaysConfig itemWaysModel)
        {
            CloseImmediately();
            itemPathModel.ClickGetWay(itemPathModel.chinItemModel.ID,itemWaysModel);
        }
 
        #endregion
 
    }
}