少年修仙传客户端代码仓库
client_Zxw
2018-09-19 92948f5aa10abc4edf464d00a16f59dbb8ca7198
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, September 11, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TableConfig;
using EnhancedUI.EnhancedScroller;
 
namespace Snxxz.UI
{
    //功能预告面板
    public enum FeatureNoticeEnum
    {
        Pet = 6,//灵宠
        Horse = 8,//坐骑
        Wing = 97,//翅膀
        GossipFurnace = 87,//八卦炉
    }
 
    public class FeatureNoticeWin : Window
    {
        [SerializeField] Text m_TextAdvanceName;//功能名
        [SerializeField] Image m_FeaturesImage;//功能图标
        [SerializeField] Text m_Text_ShowA;//显示内容1
        [SerializeField] Text m_TextShowB;//显示内容2
        [SerializeField] Text m_TextShowC;//显示内容3
        [SerializeField] Text m_TextShowD;//显示内容4
        [SerializeField] ScrollerController m_ScrollerController;
        [SerializeField] Button m_CloseButton;
        [SerializeField] Text m_TextTurnedOn;//已开启
        [SerializeField] Text m_TextUnopened;//未开启
        [SerializeField] Text m_Textschedule;//进度
        [SerializeField] Button m_ButtonGoto;
        [SerializeField] RawImage m_RawImage1;
        [SerializeField] RawImage m_RawImage2;
        [SerializeField] RawImage m_RawImage3;
        [SerializeField] RawImage m_RawImage4;
        [SerializeField] Text m_keyName;
        [SerializeField] FeatureNoticeTip m_FeatureNoticeTip;
        [SerializeField] ScaleTween m_ScaleTween;
        [SerializeField] Transform m_Tran;
        public int Offset = 0;//偏移
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        FeatureNoticeModel featureNoticeModel { get { return ModelCenter.Instance.GetModel<FeatureNoticeModel>(); } }
        private bool IsJump = false;
        #region Built-in
        private int ClickFuncID = 0;
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseButton.AddListener(OnClickBtn);
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
        }
 
        protected override void OnPreOpen()
        {
            m_ScaleTween.SetStartState();
            IsJump = WindowJumpMgr.Instance.IsJumpState;
            if (!IsJump)//是否经历跳转打开
            {
                DefaultSelection();//获取默认选择
            }
            m_FeatureNoticeTip.Init();
            OnCreateGridLineCell(m_ScrollerController);
            ContentDisplay();
 
 
        }
        protected override void OnActived()
        {
            var offset = 0f;
            m_ScrollerController.JumpIndex(JumpIndex(), ref offset);
            m_ScrollerController.JumpIndex(Offset + offset, 0, EnhancedScroller.TweenType.immediate);
        }
        protected override void OnAfterOpen()
        {
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnPlayersUpLV;
            treasureModel.treasureStateChangeEvent += treasureStateChangeEvent;
            treasureModel.treasureStageUpEvent += treasureStageUpEvent;
            if (!IsJump)//是否经历跳转打开
            {
                m_ScaleTween.Play(false, IsOpen);
            }
            else
            {
                m_ScaleTween.SetEndState();
            }
        }
        protected override void OnPreClose()
        {
            UI3DModelExhibition.Instance.StopShowNPC();
            UI3DModelExhibition.Instance.StopShowHourse();
            UI3DModelExhibition.Instance.StopShowWing();
            UI3DTreasureExhibition.Instance.StopShow();
        }
        protected override void OnAfterClose()
        {
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnPlayersUpLV;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
            treasureModel.treasureStateChangeEvent -= treasureStateChangeEvent;
            treasureModel.treasureStageUpEvent -= treasureStageUpEvent;
            if (featureNoticeModel.redPointStre1.state == RedPointState.Simple)
            {
                featureNoticeModel.redPointStre1.state = RedPointState.None;
            }
            WindowCenter.Instance.Open<MainInterfaceWin>();
        }
        private void treasureStageUpEvent(int obj)
        {
            ContentDisplay();
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
 
        private void treasureStateChangeEvent(int obj)
        {
            ContentDisplay();
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
 
        private void OnFuncStateChangeEvent(int obj)
        {
            ContentDisplay();
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
        private void OnPlayersUpLV(PlayerDataRefresh obj)
        {
            if (obj == PlayerDataRefresh.LV)
            {
                ContentDisplay();
                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
            }
        }
        void OnCreateGridLineCell(ScrollerController gridCtrl)
        {
            gridCtrl.Refresh();
            for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
            {
                if (i == 0)
                {
                    gridCtrl.AddCell(ScrollerDataType.Header, featureNoticeModel.FunctionList[i].FuncId);
                }
                else
                {
                    gridCtrl.AddCell(ScrollerDataType.Normal, featureNoticeModel.FunctionList[i].FuncId);
                }
            }
            gridCtrl.Restart();
        }
        private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            int funcId = cell.index;
            if (type == ScrollerDataType.Header)
            {
                FeaturesType1 featuresType1 = cell.GetComponent<FeaturesType1>();
                featuresType1.GetTheFeatureID(funcId);
                if (funcId == ClickFuncID)
                {
                    featuresType1.ImageSelected.SetActive(true);
                }
                else
                {
                    featuresType1.ImageSelected.SetActive(false);
                }
                featuresType1.Button.SetListener(() =>
                {
                    if (funcId != ClickFuncID)
                    {
                        ClickFuncID = funcId;
                        ContentDisplay();
                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
                    }
                });
            }
            else if (type == ScrollerDataType.Normal)
            {
                FeaturesType2 featuresType2 = cell.GetComponent<FeaturesType2>();
                featuresType2.GetTheFeatureID(funcId);
                if (funcId == ClickFuncID)
                {
                    featuresType2.ImageSelected.SetActive(true);
                }
                else
                {
                    featuresType2.ImageSelected.SetActive(false);
                }
                featuresType2.Button.SetListener(() =>
                {
                    if (funcId != ClickFuncID)
                    {
                        ClickFuncID = funcId;
                        ContentDisplay();
                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
                    }
                });
            }
        }
 
 
        #endregion
        private void DefaultSelection()//获取默认选择
        {
            var configs = Config.Instance.GetAllValues<FunctionForecastConfig>();
            foreach (var config in configs)
            {
                int openTag = config.FuncId;
                if (!FuncOpen.Instance.IsFuncOpen(openTag))
                {
                    ClickFuncID = openTag;
                    featureNoticeModel.FunctionForecastIndex = config.OpenNumber;
                    return;
                }
            }
            if (ClickFuncID == 0)
            {
                ClickFuncID = featureNoticeModel.FunctionList[0].FuncId;
            }
        }
 
        private int JumpIndex()//Jump选中
        {
            int Index = 0;
            Index = featureNoticeModel.FunctionList.FindIndex((x) =>
            {
                return x.FuncId == ClickFuncID;
            });
            return Index;
        }
 
        private void ContentDisplay()//内容显示
        {
            var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(ClickFuncID);
            if (functionForecastConfig == null)
            {
                return;
            }
            bool Type = false;
            int NeedLv = 0;
            int playerLv = PlayerDatas.Instance.baseData.LV;
            if (functionForecastConfig.OpenNumber - 2 >= featureNoticeModel.FunctionForecastIndex)
            {
                Type = true;
                NeedLv = featureNoticeModel.GetOpenLv(functionForecastConfig.OpenNumber - 2);
            }
            if (!FuncOpen.Instance.IsFuncOpen(ClickFuncID) && Type && NeedLv > playerLv)
            {
                m_Text_ShowA.gameObject.SetActive(false);
                m_TextShowB.gameObject.SetActive(false);
                m_TextShowC.gameObject.SetActive(false);
                m_TextShowD.gameObject.SetActive(false);
            }
            else
            {
                m_Text_ShowA.gameObject.SetActive(true);
                m_TextShowB.gameObject.SetActive(true);
                m_TextShowC.gameObject.SetActive(true);
                m_TextShowD.gameObject.SetActive(true);
            }
            m_TextAdvanceName.text = functionForecastConfig.FuncName;
            DisplayIcon(ClickFuncID);
            string[] StrList = ConfigParse.GetMultipleStr(functionForecastConfig.Content);
            if (StrList.Length > 0)
            {
                m_Text_ShowA.text = StrList[0];
                m_TextShowB.text = StrList[1];
                m_TextShowC.text = StrList[2];
                m_TextShowD.text = StrList[3];
            }
            if (FuncOpen.Instance.IsFuncOpen(ClickFuncID))
            {
                m_TextTurnedOn.gameObject.SetActive(true);
                m_TextUnopened.gameObject.SetActive(false);
                m_Textschedule.gameObject.SetActive(false);
                m_ButtonGoto.gameObject.SetActive(false);
            }
            else
            {
                TrailerClassification(ClickFuncID);
            }
        }
 
        private void DisplayIcon(int funcID)//显示图标或者模型
        {
            m_RawImage1.gameObject.SetActive(false);
            m_RawImage2.gameObject.SetActive(false);
            m_RawImage3.gameObject.SetActive(false);
            m_RawImage4.gameObject.SetActive(false);
            m_FeaturesImage.gameObject.SetActive(false);
            UI3DModelExhibition.Instance.StopShowNPC();
            UI3DModelExhibition.Instance.StopShowHourse();
            UI3DModelExhibition.Instance.StopShowWing();
            UI3DTreasureExhibition.Instance.StopShow();
            var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(ClickFuncID);
            bool Type = false;
            int NeedLv = 0;
            int playerLv = PlayerDatas.Instance.baseData.LV;
            if (functionForecastConfig.OpenNumber - 2 >= featureNoticeModel.FunctionForecastIndex)
            {
                Type = true;
                NeedLv = featureNoticeModel.GetOpenLv(functionForecastConfig.OpenNumber - 2);
            }
            if (!FuncOpen.Instance.IsFuncOpen(ClickFuncID) && Type && NeedLv > playerLv)
            {
                m_FeaturesImage.gameObject.SetActive(true);
                m_FeaturesImage.SetSprite("YGWENHAO");
                m_FeaturesImage.SetNativeSize();
                return;
            }
            switch (funcID)
            {
                case (int)FeatureNoticeEnum.Pet:
                    m_RawImage1.gameObject.SetActive(true);
                    var npcConfig = Config.Instance.Get<NPCConfig>(50106001);
                    UI3DModelExhibition.Instance.BeginShowNPC(50106001, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, m_RawImage1);
                    break;
                case (int)FeatureNoticeEnum.Horse:
                    m_RawImage2.gameObject.SetActive(true);
                    HorseConfig _model = Config.Instance.Get<HorseConfig>(100);
                    UI3DModelExhibition.Instance.BeginShowHourse(_model.Model, m_RawImage2);
                    break;
                case (int)FeatureNoticeEnum.Wing:
                    m_RawImage3.gameObject.SetActive(true);
                    var vec3 = new Vector3(0, 90, -90);
                    int job = PlayerDatas.Instance.baseData.Job;
                    if (job == 1)
                    {
                        var config = Config.Instance.Get<WingRefineExpConfig>(3711);
                        int _modelID = config.Model;
                        UI3DModelExhibition.Instance.BeginShowWing(_modelID, vec3, m_RawImage3);
                    }
                    else if (job == 2)
                    {
                        var config = Config.Instance.Get<WingRefineExpConfig>(3721);
                        int _modelID = config.Model;
                        UI3DModelExhibition.Instance.BeginShowWing(_modelID, vec3, m_RawImage3);
                    }
                    break;
                case (int)FeatureNoticeEnum.GossipFurnace:
                    m_RawImage4.gameObject.SetActive(true);
                    UI3DTreasureExhibition.Instance.BeginShowTreasure(301, m_RawImage4);
                    break;
                default:
                    m_FeaturesImage.gameObject.SetActive(true);
                    m_FeaturesImage.SetSprite(functionForecastConfig.Icon);
                    m_FeaturesImage.SetNativeSize();
                    break;
 
            }
        }
        void TrailerClassification(int funcID)//预告分类
        {
            m_TextTurnedOn.gameObject.SetActive(false);
            m_TextUnopened.gameObject.SetActive(false);
            m_Textschedule.gameObject.SetActive(false);
            m_ButtonGoto.gameObject.SetActive(false);
            FuncOpenLVConfig funcoPenConfig = Config.Instance.Get<FuncOpenLVConfig>(funcID);
            var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(ClickFuncID);
            bool Type = false;
            int NeedLv = 0;
            int playerLv = PlayerDatas.Instance.baseData.LV;
            if (functionForecastConfig.OpenNumber - 2 >= featureNoticeModel.FunctionForecastIndex)
            {
                Type = true;
                NeedLv = featureNoticeModel.GetOpenLv(functionForecastConfig.OpenNumber - 2);
            }
            if (!FuncOpen.Instance.IsFuncOpen(ClickFuncID) && Type && NeedLv > playerLv)
            {
                var functionForecastValue = Config.Instance.GetAllValues<FunctionForecastConfig>();
                string StrNanme = string.Empty;
                foreach (var value in functionForecastValue)
                {
                    if (value.OpenNumber == functionForecastConfig.OpenNumber - 2)
                    {
                        StrNanme = value.FuncName;
                    }
                }
                m_TextUnopened.gameObject.SetActive(true);
                m_TextUnopened.text = string.Format(Language.Get("NextYGLimit"), NeedLv, functionForecastConfig.FuncName);
                return;
            }
            if (funcoPenConfig.LimitMagicWeapon != 0 || funcoPenConfig.LimitMissionID != 0)
            {
                if (funcoPenConfig.LimitMagicWeapon != 0)//法宝
                {
                    int faBaoID = funcoPenConfig.LimitMagicWeapon / 100;
                    MagicWeapon(faBaoID);
 
                }
                else if (funcoPenConfig.LimitMissionID != 0)//任务
                {
                    m_TextUnopened.gameObject.SetActive(true);
                    if (PlayerDatas.Instance.baseData.LV >= funcoPenConfig.LimitLV)
                    {
                        m_TextUnopened.text = string.Format(Language.Get("YGTaskDone"), funcoPenConfig.LimitLV, PlayerDatas.Instance.baseData.LV, funcoPenConfig.LimitLV);
                    }
                    else
                    {
                        m_TextUnopened.text = string.Format(Language.Get("YGTask"), funcoPenConfig.LimitLV, PlayerDatas.Instance.baseData.LV, funcoPenConfig.LimitLV);
                    }
 
                    return;
                }
            }
            else//等级
            {
                m_TextUnopened.gameObject.SetActive(true);
                m_TextUnopened.text = string.Format(Language.Get("YGFuncLevel"), funcoPenConfig.LimitLV, PlayerDatas.Instance.baseData.LV, funcoPenConfig.LimitLV);
                return;
            }
        }
 
        private void MagicWeapon(int fabaoID)
        {
            m_Textschedule.gameObject.SetActive(true);
            m_ButtonGoto.gameObject.SetActive(true);
            Treasure treasure;
            TreasureConfig _treasure = Config.Instance.Get<TreasureConfig>(fabaoID);
            m_ButtonGoto.SetListener(() =>
            {
                var config = Config.Instance.Get<TreasureConfig>(fabaoID);
                treasureModel.selectedTreasure = fabaoID;
                treasureModel.currentCategory = (TreasureCategory)config.Category;
                WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureCollectSoul);
            });
            if (treasureModel.TryGetTreasure(fabaoID, out treasure)
                && treasure.state == TreasureState.Collected)
            {
                m_keyName.text = Language.Get("YGQWJX");
                var list = treasure.treasureStages;
                var funcStage = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].unlockType == TreasureStageUnlock.Func &&
                        list[i].func == ClickFuncID)
                    {
                        funcStage = i;
                        break;
                    }
                }
                if (treasure.stage < funcStage)
                {
                    if (treasure.stage == funcStage - 1 || funcStage == 0)
                    {
                        if (treasure.exp >= treasure.treasureStages[funcStage].exp)
                        {
                            m_Textschedule.text = string.Format(Language.Get("YGYouFBDone"), "100%");
                        }
                        else
                        {
                            double dou = Math.Round((double)treasure.exp / treasure.treasureStages[funcStage].exp, 2);
                            string str = dou * 100 + "%";
                            m_Textschedule.text = string.Format(Language.Get("YGYouFB"), str);
                        }
                    }
                    else
                    {
                        m_Textschedule.text = string.Format(Language.Get("YGYouFB"), "0%");
                    }
                }
            }
            else
            {
                m_keyName.text = Language.Get("YGHQFB");
                m_Textschedule.text = string.Format(Language.Get("YGNoFB"), _treasure.Name);
            }
        }
 
        private void OnClickBtn()
        {
            if (!WindowJumpMgr.Instance.IsJumpState)//是否经历跳
            {
                m_FeatureNoticeTip.FeatureNoticeTipObj.SetActive(true);
                m_ScaleTween.Play(true, IsClose);
            }
            else
            {
                Close();
            }
        }
        private void IsOpen()
        {
            m_FeatureNoticeTip.FeatureNoticeTipObj.SetActive(false);
        }
        private void IsClose()
        {
            Close();
        }
    }
 
}