少年修仙传客户端代码仓库
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
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace vnxbqy.UI
{
    public class TaskFeedbackModel : Model
    {
        Dictionary<int, TaskFeedback> m_TaskFeedbacks = new Dictionary<int, TaskFeedback>();
 
        public readonly List<int> taskFeedbackFuncs = new List<int>();
 
        public static Vector3 s_ClickPosition = Vector3.zero;
 
        ReikiRootModel reikiRootModel { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        EquipStrengthModel equipStrengthModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } }
        TreasureSkillModel treasureSkillModel { get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); } }
 
        public override void Init()
        {
            ParseConfig();
        }
 
        public override void UnInit()
        {
        }
 
        void ParseConfig()
        {
            var configs = TaskFeedbackConfig.GetValues();
            foreach (var config in configs)
            {
                if (config.type == 100)
                {
                    continue;
                }
 
                var feedback = new TaskFeedback()
                {
                    taskId = config.taskId,
                    type = (TaskFeedbackType)config.type,
                };
 
                switch (feedback.type)
                {
                    case TaskFeedbackType.SideTask:
                    case TaskFeedbackType.FightPowerSideTask:
                        {
                            var array = LitJson.JsonMapper.ToObject<int[][]>(config.sideTasks);
                            if (array != null)
                            {
                                List<int[]> sideTasks = new List<int[]>(array.Length);
                                for (int i = 0; i < array.Length; i++)
                                {
                                    sideTasks.Add(array[i]);
                                }
                                feedback.sideTasks = sideTasks;
                            }
                        }
                        break;
                    case TaskFeedbackType.Equip:
                        {
                            var array = LitJson.JsonMapper.ToObject<int[]>(config.equips);
                            feedback.equipCondition = array;
                        }
                        break;
                    case TaskFeedbackType.ItemCount:
                        {
                            var array = LitJson.JsonMapper.ToObject<int[][]>(config.items);
                            if (array != null)
                            {
                                List<Item> items = new List<Item>();
                                for (int i = 0; i < array.Length; i++)
                                {
                                    items.Add(new Item()
                                    {
                                        id = array[i][0],
                                        count = array[i][1],
                                    });
                                }
                                feedback.items = items;
                            }
                        }
                        break;
                    case TaskFeedbackType.SkyTowerFightPoint:
                        {
                            if (!string.IsNullOrEmpty(config.reikiRoot))
                            {
                                var point = 0;
                                int.TryParse(config.reikiRoot, out point);
                                feedback.totalPoints = point;
                            }
                        }
                        break;
                    case TaskFeedbackType.ReikiPoint:
                        {
                            if (!string.IsNullOrEmpty(config.reikiRoot))
                            {
                                var json = LitJson.JsonMapper.ToObject(config.reikiRoot);
                                feedback.reikiRoots = new Dictionary<int, List<int[]>>();
                                foreach (var jobKey in json.Keys)
                                {
                                    var job = int.Parse(jobKey);
                                    var intArray = LitJson.JsonMapper.ToObject<int[][]>(json[jobKey].ToJson());
                                    feedback.reikiRoots.Add(job, new List<int[]>());
                                    for (int i = 0; i < intArray.Length; i++)
                                    {
                                        feedback.reikiRoots[job].Add(intArray[i]);
                                    }
                                }
                            }
                        }
                        break;
                }
 
                if (!string.IsNullOrEmpty(config.failFuncs))
                {
                    var funcArray = LitJson.JsonMapper.ToObject<int[][]>(config.failFuncs);
                    if (funcArray != null)
                    {
                        List<int[]> failFuncs = new List<int[]>(funcArray.Length);
                        for (int i = 0; i < funcArray.Length; i++)
                        {
                            failFuncs.Add(funcArray[i]);
                        }
                        feedback.failFuns = failFuncs;
                    }
                }
 
                m_TaskFeedbacks.Add(config.taskId, feedback);
            }
        }
 
        public bool TryGetTaskFeedback(int taskId, out TaskFeedback feedback)
        {
            return m_TaskFeedbacks.TryGetValue(taskId, out feedback);
        }
 
        public void ExecuteTaskFeedback(int taskId)
        {
            if (NewBieCenter.Instance.inGuiding)
            {
                return;
            }
 
            if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>() && taskId != 3110)
            {
                //特殊写死3110限制105级开启宗门试炼 触发提示逻辑,如后续不需要,请果断删除
                return;
            }
 
            TaskFeedback feedback;
            if (TryGetTaskFeedback(taskId, out feedback))
            {
                var config = TaskFeedbackConfig.Get(taskId);
 
                switch (feedback.type)
                {
                    case TaskFeedbackType.FightPower:
                    case TaskFeedbackType.Copper:
                    case TaskFeedbackType.ReikiPoint:
                    case TaskFeedbackType.Guide:
                    case TaskFeedbackType.Equip:
                    case TaskFeedbackType.ItemCount:
                    case TaskFeedbackType.SkyTowerFightPoint:
                    case TaskFeedbackType.DemonTreasure:
                    case TaskFeedbackType.AlchemyItem:
                    case TaskFeedbackType.HasFairy:
                        {
                            int condition = 0;
                            if (IsSatisfyCondition(feedback, out condition))
                            {
                                ExecuteSuccFeedback(taskId);
                            }
                            else
                            {
                                if (config.remind != null && config.remind.Length > 0)
                                {
                                    var index = Mathf.Min(condition, config.remind.Length - 1);
                                    SysNotifyMgr.Instance.ShowTip(config.remind[index]);
                                }
                                if (feedback.failFuns != null)
                                {
                                    var index = Mathf.Min(condition, feedback.failFuns.Count - 1);
                                    var funcTitle = index < config.funcTitles.Length ? config.funcTitles[index] : string.Empty;
                                    List<int> succFuncs;
                                    if (TryGetSatisfyConditionFuncs(feedback.failFuns[index], out succFuncs))
                                    {
                                        taskFeedbackFuncs.Clear();
                                        if (config.onlyOneFunc != null &&
                                            index < config.onlyOneFunc.Length && config.onlyOneFunc[index] == 1)
                                        {
                                            taskFeedbackFuncs.Add(succFuncs[0]);
                                        }
                                        else
                                        {
                                            taskFeedbackFuncs.AddRange(succFuncs);
                                        }
                                        TaskFeedbackFuncWin.funcTitle = funcTitle;
                                        WindowCenter.Instance.Open<TaskFeedbackFuncWin>();
                                    }
                                }
                            }
                        }
                        break;
                    case TaskFeedbackType.SideTask:
                        {
                            int condition = 0;
                            if (IsSatisfyCondition(feedback, out condition))
                            {
                                ExecuteSuccFeedback(taskId);
                            }
                            else
                            {
                                if (config.remind != null && config.remind.Length > 0)
                                {
                                    var taskIndex = feedback.IndexOfSideTasks(condition);
                                    var index = Mathf.Min(taskIndex, config.remind.Length - 1);
                                    SysNotifyMgr.Instance.ShowTip(config.remind[index]);
                                }
                                if (feedback.failFuns != null)
                                {
                                    var taskIndex = feedback.IndexOfSideTasks(condition);
                                    var index = Mathf.Min(taskIndex, feedback.failFuns.Count - 1);
                                    var funcTitle = index < config.funcTitles.Length ? config.funcTitles[index] : string.Empty;
                                    List<int> succFuncs;
                                    if (TryGetSatisfyConditionFuncs(feedback.failFuns[index], out succFuncs))
                                    {
                                        taskFeedbackFuncs.Clear();
                                        if (config.onlyOneFunc != null &&
                                            index < config.onlyOneFunc.Length && config.onlyOneFunc[index] == 1)
                                        {
                                            taskFeedbackFuncs.Add(succFuncs[0]);
                                        }
                                        else
                                        {
                                            taskFeedbackFuncs.AddRange(succFuncs);
                                        }
                                        TaskFeedbackFuncWin.funcTitle = funcTitle;
                                        WindowCenter.Instance.Open<TaskFeedbackFuncWin>();
                                    }
                                }
                            }
                        }
                        break;
                    case TaskFeedbackType.FightPowerSideTask:
                        {
                            int condition = 0;
                            if (IsSatisfyCondition(feedback, out condition))
                            {
                                ExecuteSuccFeedback(taskId);
                            }
                            else
                            {
                                if (config.remind != null && config.remind.Length > 0)
                                {
                                    var index = Mathf.Min(condition, config.remind.Length - 1);
                                    SysNotifyMgr.Instance.ShowTip(config.remind[index]);
                                }
                                if (feedback.failFuns != null)
                                {
                                    var sideTaskId = 0;
                                    IsSatisfySideTask(feedback.sideTasks, out sideTaskId);
                                    var taskIndex = feedback.IndexOfSideTasks(sideTaskId);
                                    var index = Mathf.Min(taskIndex, feedback.failFuns.Count - 1);
                                    var funcTitle = index < config.funcTitles.Length ? config.funcTitles[index] : string.Empty;
                                    List<int> succFuncs;
                                    if (TryGetSatisfyConditionFuncs(feedback.failFuns[index], out succFuncs))
                                    {
                                        taskFeedbackFuncs.Clear();
                                        if (config.onlyOneFunc != null &&
                                            index < config.onlyOneFunc.Length && config.onlyOneFunc[index] == 1)
                                        {
                                            taskFeedbackFuncs.Add(succFuncs[0]);
                                        }
                                        else
                                        {
                                            taskFeedbackFuncs.AddRange(succFuncs);
                                        }
                                        TaskFeedbackFuncWin.funcTitle = funcTitle;
                                        WindowCenter.Instance.Open<TaskFeedbackFuncWin>();
                                    }
                                }
                            }
                        }
                        break;
                    case TaskFeedbackType.OnekeyHangUp:
                        {
                            OnekeyHangUp();
                        }
                        break;
                }
            }
        }
 
        public void OnekeyHangUp()
        {
 
            var mapModel = ModelCenter.Instance.GetModel<MapModel>();
            var point = mapModel.GetRecommendHangPoint();
            var config = MapEventPointConfig.Get(point);
 
            var mapId = MapUtility.GetMapId(config.DataMapID, config.LineId);
            MapTransferUtility.Instance.MissionFlyTo(mapId, config.NPCID, MapTransferType.WorldTransport);
        }
 
        public void ExecuteSuccFeedback(int id)
        {
            var config = TaskFeedbackConfig.Get(id);
            var guide = config.succGuide;
            if (guide != 0 && !NewBieCenter.Instance.IsGuideCompleted(guide))
            {
                ExecuteGuide(guide);
            }
            else
            {
                if (config.jump != 0)
                {
                    WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.jump);
                }
            }
        }
 
        public void ExecuteGuide(int id)
        {
            if (id == 0)
            {
                return;
            }
            var config = GuideConfig.Get(id);
            if (config == null)
            {
                DebugEx.LogFormat("引导<color=#ff0000>{0}</color>未添加", id);
                return;
            }
            switch ((GuideType)config.Type)
            {
                case GuideType.Functional:
                    if (FunctionalGuideCenter.Instance.ExistUnderwayGuide(id))
                    {
                        FunctionalGuideCenter.Instance.RemoveGuide(id);
                        NewBieCenter.Instance.ResetGuide(id);
                        SnxxzGame.Instance.StartCoroutine(_ExecuteGuide(id));
                    }
                    else
                    {
                        FunctionalGuideCenter.Instance.StartGuide(id);
                    }
                    break;
                default:
                    NewBieCenter.Instance.StartNewBieGuideEx(id);
                    break;
            }
        }
 
        IEnumerator _ExecuteGuide(int id)
        {
            yield return null;
            FunctionalGuideCenter.Instance.StartGuide(id);
        }
 
        public bool IsSatisfyCondition(TaskFeedback feedback, out int condition)
        {
            var config = TaskFeedbackConfig.Get(feedback.taskId);
            condition = 0;
            switch (feedback.type)
            {
                case TaskFeedbackType.FightPower:
                    return PlayerDatas.Instance.baseData.FightPoint >= (ulong)config.condition;
                case TaskFeedbackType.SideTask:
                    return IsSatisfySideTask(feedback.sideTasks, out condition);
                case TaskFeedbackType.ReikiPoint:
                    {
                        if (reikiRootModel.GetReikiRootTotalPointWithFree() < config.condition)
                        {
                            return false;
                        }
                        if (feedback.reikiRoots != null)
                        {
                            var job = PlayerDatas.Instance.baseData.Job;
                            var reikiRoots = feedback.reikiRoots[job];
                            foreach (var reikiRoot in reikiRoots)
                            {
                                if (reikiRootModel.GetReikiRootPoint(reikiRoot[0]) < reikiRoot[1])
                                {
                                    condition = 1;
                                    return false;
                                }
                            }
                        }
                    }
                    return true;
                case TaskFeedbackType.Equip:
                    {
                        var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
                        {
                            levels = new List<int>() { feedback.equipCondition[0] },
                            qualitys = new List<int>() { feedback.equipCondition[1] },
                            equipTypes = EquipModel.realmEquipTypes,
                            jobs = new List<int>() { PlayerDatas.Instance.baseData.Job },
                        });
                        return items != null && items.Count > 0;
                    }
                case TaskFeedbackType.Copper:
                    return PlayerDatas.Instance.baseData.allCopper >= (ulong)config.condition;
                case TaskFeedbackType.Guide:
                    return true;
                case TaskFeedbackType.FightPowerSideTask:
                    return PlayerDatas.Instance.baseData.FightPoint >= (ulong)config.condition;
                case TaskFeedbackType.ItemCount:
                    {
                        if (feedback.items != null)
                        {
                            foreach (var item in feedback.items)
                            {
                                if (packModel.GetItemCountByID(PackType.Item, item.id) < item.count)
                                {
                                    return false;
                                }
                            }
                        }
                        return true;
                    }
                case TaskFeedbackType.AlchemyItem:
                    {
                        if (!alchemyModel.IsGraspRecipe(config.condition))
                        {
                            var error = 0;
                            if (alchemyModel.TryLearn(config.condition, out error))
                            {
                                return true;
                            }
                            return false;
                        }
                        Item material;
                        return alchemyModel.GetStoveState(config.condition) != 0
                            || alchemyModel.IsAlchemyEnoughMaterial(config.condition, out material);
                    }
                case TaskFeedbackType.SkyTowerFightPoint:
                    {
                        var skyTowerConfig = SkyTowerConfig.Get(config.condition);
                        if (skyTowerConfig != null)
                        {
                            if (feedback.totalPoints > 0 && PlayerDatas.Instance.baseData.FightPoint < (ulong)NPCExConfig.Get(skyTowerConfig.bossId).SuppressFightPower)
                            {
                                condition = reikiRootModel.GetReikiRootTotalPointWithFree() >= feedback.totalPoints ? 0 : 1;
                                return false;
                            }
                            else
                            {
                                return PlayerDatas.Instance.baseData.FightPoint >= (ulong)NPCExConfig.Get(skyTowerConfig.bossId).SuppressFightPower;
                            }
                        }
                    }
                    break;
                case TaskFeedbackType.DemonTreasure:
                    {
                        TreasureDungeon treasureDungeon;
                        if (treasureModel.TryGetTreasureDungeon(config.condition, out treasureDungeon))
                        {
                            var dungeonInfo = treasureDungeon.Get(treasureDungeon.currentLevel + 1);
                            if (!dungeonInfo.Equals(default(TreasureDungeonInfo)))
                            {
                                return (int)UIHelper.GetPropertyValue(PropertyType.DEF) >= dungeonInfo.defense;
                            }
                            return true;
                        }
                    }
                    break;
                case TaskFeedbackType.HasFairy:
                    {
                        return PlayerDatas.Instance.baseData.FamilyId > 0;
                    }
            }
            return false;
        }
 
        public bool IsSatisfySideTask(List<int[]> sideTasks, out int condition)
        {
            condition = 0;
            foreach (var taskId in taskModel.SideQuestsDic.Keys)
            {
                for (int i = 0; i < sideTasks.Count; i++)
                {
                    if (taskId >= sideTasks[i][0]
                        && taskId <= sideTasks[i][1])
                    {
                        condition = taskId;
                        return false;
                    }
                }
            }
            return true;
        }
 
        public bool TryGetSatisfyConditionFuncs(int[] funcs, out List<int> succFuncs)
        {
            succFuncs = null;
            if (funcs != null && funcs.Length > 0)
            {
                succFuncs = new List<int>();
                for (int i = 0; i < funcs.Length; i++)
                {
                    if (IsSatisfyFuncConfition(funcs[i]))
                    {
                        succFuncs.Add(funcs[i]);
                    }
                }
                return succFuncs.Count > 0;
            }
            return false;
        }
 
        public bool IsSatisfyFuncConfition(int func)
        {
            var config = TaskFeedbackFuncConfig.Get(func);
            if (config != null)
            {
                switch (config.type)
                {
                    case 1:
                        foreach (var item in config.itemCondition)
                        {
                            var count = packModel.GetItemCountByID(PackType.Item, item.x);
                            if (count < item.y)
                            {
                                return false;
                            }
                        }
                        return true;
                    case 2:
                        return reikiRootModel.freePoint > 0;
                    case 3:
                        foreach (var equipSet in equipModel.GetUnLockedEquipSets())
                        {
                            if (equipModel.ExistBetterEquip(equipSet, EquipModel.realmEquipTypes))
                            {
                                return true;
                            }
                        }
                        return false;
                    case 4:
                        MissionDetailDates taskData;
                        if (taskModel.TryGetTaskData(config.condition, out taskData))
                        {
                            return taskData.MissionState != 3;
                        }
                        return false;
                    case 5:
                        return equipStrengthModel.ExistAnySatisfyStrengh();
                    case 6:
                        if (!alchemyModel.IsGraspRecipe(config.condition))
                        {
                            var error = 0;
                            if (alchemyModel.TryLearn(config.condition, out error))
                            {
                                return true;
                            }
                            return false;
                        }
                        Item material;
                        return alchemyModel.GetStoveState(config.condition) != 0
                            || alchemyModel.IsAlchemyEnoughMaterial(config.condition, out material);
                    case 7:
                        {
                            foreach (var funcId in config.excludeFuncs)
                            {
                                if (funcId == func)
                                {
                                    continue;
                                }
                                if (IsSatisfyFuncConfition(funcId))
                                {
                                    return false;
                                }
                            }
                            return true;
                        }
                    case 10:
                        {
                            if (config.expertSkills != null)
                            {
                                foreach (var skill in config.expertSkills)
                                {
                                    if (treasureSkillModel.IsSatisfyLevelUpSkill(skill.x, skill.y, skill.z))
                                    {
                                        return true;
                                    }
                                }
                            }
                            return false;
                        }
                    case 11:
                        {
                            if (config.condition != 0)
                            {
                                Treasure treasure;
                                if (treasureModel.TryGetTreasure(config.condition, out treasure)
                                    && treasure.state != TreasureState.Collected)
                                {
                                    return true;
                                }
                            }
                        }
                        return false;
                    default:
                        return true;
                }
            }
            return false;
        }
    }
 
    public struct TaskFeedback
    {
        public int taskId;
        public TaskFeedbackType type;
        public List<int[]> sideTasks;
        public int[] equipCondition;
        public List<Item> items;
        public Dictionary<int, List<int[]>> reikiRoots;
        public List<int[]> failFuns;
        public int totalPoints;
 
        public int IndexOfSideTasks(int taskId)
        {
            var index = 0;
            for (int i = 0; i < sideTasks.Count; i++)
            {
                if (taskId >= sideTasks[i][0]
                   && taskId <= sideTasks[i][1])
                {
                    index += taskId - sideTasks[i][0];
                    break;
                }
                index += (sideTasks[i][1] - sideTasks[i][0] + 1);
            }
            return index;
        }
    }
 
    public enum TaskFeedbackType
    {
        FightPower = 1,
        SideTask = 2,
        ReikiPoint = 3,
        Equip = 4,
        Copper = 5,
        Guide = 6,
        FightPowerSideTask = 7,
        ItemCount = 8,
        SkyTowerFightPoint = 9,
        DemonTreasure = 10,
        AlchemyItem = 11,
        HasFairy = 12,
        OnekeyHangUp = 13,
        //后续IL开发添加预设
        default1,
        default2,
        default3,
        default4,
        default5,
        default6,
        default7,
        default8,
        default9,
        default10,
    }
}