少年修仙传客户端代码仓库
client_Wu Xijin
2019-04-09 f5dfc8135aa8b217985ab38a65a2f7e7eee2c38d
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, September 16, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
namespace Snxxz.UI
{
 
    public class DailyQuestWin : Window
    {
        [SerializeField] FunctionButtonGroup m_FunctionGroup;
        [SerializeField] FunctionButton m_EveryDaily;
        [SerializeField] FunctionButton m_TimeLimit;
        [SerializeField] FunctionButton m_ResourcesBack;
        [SerializeField] Button m_Left;
        [SerializeField] Button m_Right;
        [SerializeField] ButtonEx m_CloseButton;
 
        [SerializeField] RectTransform m_DailyQuestContainer;
        [SerializeField] CyclicScroll m_QuestScroll;
        [SerializeField] Button m_Calendar;
        [SerializeField] DailyQuestHangTimeBehaviour m_HangTimeBehaviour;
        [SerializeField] DailyQuestActiveSlider m_DailyQuestActiveSlider;
 
        [SerializeField] RectTransform m_ResourcesBackContainer;
 
        DailyQuestModel model { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
        DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
        TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
        MapModel mapModel { get { return ModelCenter.Instance.GetModel<MapModel>(); } }
 
        public int guidingDailyQuestId = 0;
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseButton.AddListener(CloseClick);
            m_Calendar.AddListener(ShowCalendar);
            m_EveryDaily.AddListener(ShowEveryDayQuests);
            m_TimeLimit.AddListener(ShowTimeLimit);
            m_ResourcesBack.AddListener(ShowResourcesBack);
            m_Left.AddListener(ShowLastFunction);
            m_Right.AddListener(ShowNextFunction);
        }
 
        protected override void OnPreOpen()
        {
            guidingDailyQuestId = model.currentDailyQuest;
        }
 
        protected override void OnAfterOpen()
        {
            model.currentActiveValueUpdateEvent += OnUpdateCurrentActive;
        }
 
        protected override void OnPreClose()
        {
            guidingDailyQuestId = 0;
            model.currentDailyQuest = 0;
            m_HangTimeBehaviour.Dispose();
            m_QuestScroll.Dispose();
 
            model.currentActiveValueUpdateEvent -= OnUpdateCurrentActive;
        }
 
        protected override void OnAfterClose()
        {
            if (!WindowJumpMgr.Instance.IsJumpState)
            {
                WindowCenter.Instance.Open<MainInterfaceWin>();
            }
        }
 
        protected override void OnActived()
        {
            base.OnActived();
 
            if (guidingDailyQuestId != 0)
            {
                var preferTimeLimit = false;
                var dailyQuests = model.GetDailyQuests();
                foreach (var quest in dailyQuests)
                {
                    var dailyQuestState = model.GetQuestState(quest);
                    DailyQuestOpenTime openTime;
                    if (model.TryGetOpenTime(quest, out openTime) && !openTime.always)
                    {
                        var completedTimes = model.GetDailyQuestCompletedTimes(quest);
                        var totalTimes = model.GetDailyQuestTotalTimes(quest);
                        if ((dailyQuestState == DailyQuestModel.DailyQuestState.Normal && completedTimes < totalTimes))
                        {
                            preferTimeLimit = true;
                        }
                        break;
                    }
                }
 
                if (preferTimeLimit)
                {
                    functionOrder = 1;
                }
            }
 
            m_FunctionGroup.TriggerByOrder(functionOrder);
        }
 
        #endregion
 
        private void ShowEveryDayQuests()
        {
            var dailyQuests = model.GetDailyQuests(DailyQuestModel.DailyQuestCategory.EveryDay);
            m_DailyQuestContainer.gameObject.SetActive(true);
            m_ResourcesBackContainer.gameObject.SetActive(false);
            ShowQuestGroups(dailyQuests);
            functionOrder = m_EveryDaily.order;
        }
 
        private void ShowTimeLimit()
        {
            var dailyQuests = model.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
            m_DailyQuestContainer.gameObject.SetActive(true);
            m_ResourcesBackContainer.gameObject.SetActive(false);
            ShowQuestGroups(dailyQuests);
            functionOrder = m_TimeLimit.order;
        }
 
        private void ShowResourcesBack()
        {
            m_DailyQuestContainer.gameObject.SetActive(false);
            m_ResourcesBackContainer.gameObject.SetActive(true);
 
            functionOrder = m_ResourcesBack.order;
        }
 
        private void ShowLastFunction()
        {
            m_FunctionGroup.TriggerLast();
        }
 
        private void ShowNextFunction()
        {
            m_FunctionGroup.TriggerNext();
        }
 
        private void ShowQuestGroups(List<int> _quests)
        {
            m_HangTimeBehaviour.Display();
            m_DailyQuestActiveSlider.Initialize();
            m_DailyQuestActiveSlider.UpdateCurrentActiveValue(model.currentActiveValue, model.dailyQuestTotalActiveValue);
            var groupDatas = new List<DailyQuestGroup.GroupData>();
            var max = _quests.Count;
            for (int i = 0; i < max; i++, i++)
            {
                DailyQuestData data1 = null;
                model.TryGetDailyQuest(_quests[i], out data1);
                DailyQuestData data2 = null;
                if (i + 1 < max)
                {
                    model.TryGetDailyQuest(_quests[i + 1], out data2);
                }
                groupDatas.Add(new DailyQuestGroup.GroupData(data1, data2, this));
            }
 
            m_QuestScroll.Init(groupDatas);
 
            var currentQuestIndex = _quests.IndexOf(model.currentDailyQuest);
            if (currentQuestIndex != -1)
            {
                m_QuestScroll.MoveToCenter(currentQuestIndex / 2);
            }
        }
 
        private void ShowCalendar()
        {
            WindowCenter.Instance.Open<DailyQuestCalendarWin>();
        }
 
        private void OnUpdateCurrentActive()
        {
            m_DailyQuestActiveSlider.UpdateCurrentActiveValue(model.currentActiveValue, model.dailyQuestTotalActiveValue);
        }
 
        public void GotoDailyQuest(int _id)
        {
            switch ((DailyQuestType)_id)
            {
                case DailyQuestType.FairyLand:
                    GotoNormalDungeon(_id);
                    break;
                case DailyQuestType.IceCrystal:
                    WindowCenter.Instance.Open<IceCrystalVeinWin>();
                    break;
                case DailyQuestType.GuardSky:
                    var _fairyModel = ModelCenter.Instance.GetModel<FairyModel>();
                    if (!_fairyModel.SatisfyGuardSkyFairyLv())
                    {
                        SysNotifyMgr.Instance.ShowTip("GuardSkyOpenLvError", _fairyModel.guardSkyOpenFairyLv);
                        break;
                    }
                    if (_fairyModel.completeGuardSky)
                    {
                        SysNotifyMgr.Instance.ShowTip("TheEmperor1");
                        break;
                    }
                    GotoNormalDungeon(_id);
                    break;
                case DailyQuestType.Kirin:
                    GotoMultipleDifficultyDungeon(_id);
                    break;
                case DailyQuestType.BountyMission:
                    WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.BountyInterface);
                    break;
                case DailyQuestType.Demon:
                    GotoChaosDemon(_id);
                    break;
                case DailyQuestType.Trial:
                    GotoTrial();
                    break;
                case DailyQuestType.BlastStove:
                    GotoBlastStove();
                    break;
                case DailyQuestType.AncientBattleGround:
                    GotoNormalDungeon(_id, dungeonModel.GetBelongToLine(_id));
                    break;
                case DailyQuestType.EmperorRelic:
                    GotoNuwa();
                    break;
                case DailyQuestType.WyTaiChi:
                    GotoTaiChiDungeon(_id);
                    break;
                case DailyQuestType.HeavenBattle:
                    GotoHeavenBattleDungeon(_id);
                    break;
                case DailyQuestType.Prayer:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<WelfareWin>(false, 1);
                    WindowCenter.Instance.Close<MainInterfaceWin>();
                    break;
                case DailyQuestType.WorldBoss:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<FindPreciousFrameWin>();
                    break;
                case DailyQuestType.DemonJar:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<LootPreciousFrameWin>();
                    break;
                case DailyQuestType.FairyTask:
                    WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.UnionTask);
                    break;
                case DailyQuestType.FairyLeague:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<UnionPanel>(false, 4);
                    break;
                case DailyQuestType.FairyFeast:
                    if (CrossServerUtility.IsCrossServer())
                    {
                        SysNotifyMgr.Instance.ShowTip("CrossMap10");
                        break;
                    }
                    var config = DailyQuestConfig.Get(_id);
                    dungeonModel.SingleChallenge(config.RelatedID);
                    break;
                case DailyQuestType.RuneTowerSweep:
                    RuneTowerWin.guideSweep = true;
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<TowerWin>(false, 0);
                    break;
                case DailyQuestType.BossHome:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<FindPreciousFrameWin>(false, 1);
                    break;
                case DailyQuestType.PersonalBoss:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<FindPreciousFrameWin>(false, 2);
                    break;
                case DailyQuestType.ElderGodArea:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<FindPreciousFrameWin>(false, 3);
                    break;
                case DailyQuestType.RuneTower:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<TowerWin>(false, 0);
                    break;
                case DailyQuestType.TreasureCollectSoul:
                    GotoTreasureCollectSoul();
                    break;
                case DailyQuestType.DungeonAssist:
                    WindowCenter.Instance.Open<DungeonAssistWin>();
                    break;
                case DailyQuestType.FairyGrabBoss:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<LootPreciousFrameWin>(false, 1);
                    break;
                case DailyQuestType.KillMonster:
                    var point = mapModel.GetRecommendHangPoint();
                    var mapEventConfig = MapEventPointConfig.Get(point);
                    mapModel.wannaLookLocalMap = mapEventConfig.MapID;
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<LocalMapWin>();
                    break;
                case DailyQuestType.GatherSoulDungeon:
                    GotoNormalDungeon(_id, 0);
                    break;
                case DailyQuestType.CrossServerPk:
                    WindowCenter.Instance.Close<DailyQuestWin>();
                    WindowCenter.Instance.Open<CrossServerWin>();
                    break;
                case DailyQuestType.AllianceBoss1:
                    GotoAllianceBoss(_id, 0);
                    break;
                case DailyQuestType.AllianceBoss2:
                    GotoAllianceBoss(_id, 1);
                    break;
                default:
                    CSharpCallLua.GotoLuaDailyQuest(_id);
                    break;
            }
 
            WindowJumpMgr.Instance.ClearJumpData();
        }
 
        private void GotoTaiChiDungeon(int _dailyQuestId, int _lineId = 0)
        {
            if (VersionConfig.Get().isBanShu)
            {
                return;
            }
 
            var config = DailyQuestConfig.Get(_dailyQuestId);
            model.currentDailyQuest = config.ID;
            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, _lineId);
            WindowCenter.Instance.Open<TaiChilDungeonEntranceWin>();
        }
 
        private void GotoHeavenBattleDungeon(int _dailyQuestId, int _lineId = 0)
        {
            var config = DailyQuestConfig.Get(_dailyQuestId);
            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, _lineId);
            WindowCenter.Instance.Open<HeavenBattleWin>();
        }
 
        private void GotoNormalDungeon(int _dailyQuestId, int _lineId = 0)
        {
            var config = DailyQuestConfig.Get(_dailyQuestId);
            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, _lineId);
            WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
        }
 
        private void GotoMultipleDifficultyDungeon(int _dailyQuestId)
        {
            var config = DailyQuestConfig.Get(_dailyQuestId);
            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
            dungeonModel.selectedKylinDungeon = default(Dungeon);
            WindowCenter.Instance.Open<MultipleDifficultyDungeonWin>();
        }
 
        private void GotoChaosDemon(int _dailyQuestId)
        {
            var completedTimes = model.GetDailyQuestCompletedTimes(_dailyQuestId);
            var totalTimes = model.GetDailyQuestTotalTimes(_dailyQuestId);
            if (completedTimes >= totalTimes)
            {
                if (DayRemind.Instance.GetDayRemind(DayRemind.DUNGEON_DEMON_TIP))
                {
                    GotoNormalDungeon(_dailyQuestId);
                }
                else
                {
                    ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("TodayDungeonComplete"), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
                    {
                        if (isOk)
                        {
                            GotoNormalDungeon(_dailyQuestId);
                        }
                        if (isToggle)
                        {
                            DayRemind.Instance.SetDayRemind(DayRemind.DUNGEON_DEMON_TIP, true);
                        }
                    });
                }
                return;
            }
 
            GotoNormalDungeon(_dailyQuestId);
        }
 
        private void GotoNuwa()
        {
            var id = (int)DailyQuestType.EmperorRelic;
            var completedTimes = model.GetDailyQuestCompletedTimes(id);
            var totalTimes = model.GetDailyQuestTotalTimes(id);
            if (completedTimes >= totalTimes)
            {
                if (DayRemind.Instance.GetDayRemind(DayRemind.DUNGEON_RELIC_TIP))
                {
                    GotoNormalDungeon(id);
                }
                else
                {
                    ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("TodayDungeonComplete"), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
                    {
                        if (isOk)
                        {
                            GotoNormalDungeon(id);
                        }
                        if (isToggle)
                        {
                            DayRemind.Instance.SetDayRemind(DayRemind.DUNGEON_RELIC_TIP, true);
                        }
                    });
                }
                return;
            }
            GotoNormalDungeon(id);
        }
 
        private void GotoTrial()
        {
            var id = (int)DailyQuestType.Trial;
            var config = DailyQuestConfig.Get(id);
 
            var completedTimes = model.GetDailyQuestCompletedTimes(id);
            var totalTimes = model.GetDailyQuestTotalTimes(id);
 
            if (completedTimes >= totalTimes)
            {
                if (DayRemind.Instance.GetDayRemind(DayRemind.DUNGEON_TRIAL_TIP))
                {
                    dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                    WindowCenter.Instance.Open<TrialDungeonSelectWin>();
                }
                else
                {
                    ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("TodayTrialComplete"), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>
                    {
                        if (isOk)
                        {
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<TrialDungeonSelectWin>();
                        }
                        if (isToggle)
                        {
                            DayRemind.Instance.SetDayRemind(DayRemind.DUNGEON_TRIAL_TIP, true);
                        }
                    });
                }
                return;
            }
 
            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
            WindowCenter.Instance.Open<TrialDungeonSelectWin>();
        }
 
        private void GotoBlastStove()
        {
            WindowCenter.Instance.Close<DailyQuestWin>();
            WindowCenter.Instance.Open<BlastFurnaceWin>();
        }
 
        private void GotoBountyMission()
        {
            var inDungeon = IsDungeon();
            if (inDungeon)
            {
                SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
            }
            else
            {
                taskModel.DailyBountyMove();
                WindowCenter.Instance.Close<DailyQuestWin>();
                WindowCenter.Instance.Open<MainInterfaceWin>();
            }
        }
 
        private void GotoFairyTask()
        {
            var inDungeon = IsDungeon();
            if (inDungeon)
            {
                SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
            }
            else
            {
                taskModel.DailyFairyTaskMove();
                WindowCenter.Instance.Close<DailyQuestWin>();
                WindowCenter.Instance.Open<MainInterfaceWin>();
            }
        }
 
        private void GotoAllianceBoss(int id, int lineId)
        {
            dungeonModel.currentDungeon = new Dungeon(AllianceBossModel.DATAMAPID, lineId);
            AllianceBossEntranceWin.dailyQuestId = id;
            WindowCenter.Instance.Open<AllianceBossEntranceWin>();
        }
 
        private void GotoTreasureCollectSoul()
        {
            var treasureModel = ModelCenter.Instance.GetModel<TreasureModel>();
            var treasures = treasureModel.GetTreasureCategory(TreasureCategory.Human);
            var gotoTreasureId = 0;
            for (int i = treasures.Count - 1; i >= 0; i--)
            {
                if (IsTreasureCollectSoul(treasures[i]))
                {
                    gotoTreasureId = treasures[i];
                    break;
                }
            }
 
            if (gotoTreasureId == 0)
            {
                for (int i = 0; i < treasures.Count; i++)
                {
                    Treasure treasure;
                    if (treasureModel.TryGetTreasure(treasures[i], out treasure))
                    {
                        if (treasure != null
                            && (treasure.state == TreasureState.Locked || treasure.state == TreasureState.Collecting))
                        {
                            gotoTreasureId = treasure.id;
                            break;
                        }
                    }
                }
            }
 
            WindowCenter.Instance.Close<DailyQuestWin>();
 
            if (gotoTreasureId == 0)
            {
                treasureModel.currentCategory = TreasureCategory.Human;
                WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureFunc1);
            }
            else
            {
                var config = TreasureConfig.Get(gotoTreasureId);
                treasureModel.selectedTreasure = gotoTreasureId;
                treasureModel.currentCategory = (TreasureCategory)config.Category;
                WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureCollectSoul);
            }
        }
 
        private bool IsTreasureCollectSoul(int _treasureId)
        {
            return false;
        }
 
        private bool IsDungeon()//是否在副本中
        {
            var mapId = PlayerDatas.Instance.baseData.MapID;
            var mapConfig = MapConfig.Get(mapId);
            return mapConfig != null && mapConfig.MapFBType != 0;
        }
    }
 
}