少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, May 03, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    
    public class HumanTreasureWin : Window
    {
        [SerializeField] Transform m_ContainerDisplay;
        [SerializeField] Transform m_Container;
        [SerializeField] PositionTween m_PositionTween1;
        [SerializeField] PositionTween m_PositionTween2;
        [SerializeField] Image m_TreasureName;
        [SerializeField] Text m_TaskTitle;
        [SerializeField] Text m_TreasureStory;
        [SerializeField] Button m_ViewDetail;
        [SerializeField] Image m_SkillIcon;
        [SerializeField] Text m_SkillName;
        [SerializeField] Button m_Challenge;
        [SerializeField] Transform m_ContainerCondition;
        [SerializeField] Text m_ChallengeCondition;
        [SerializeField] Text m_TaskClueTitle;
        [SerializeField] Slider m_TaskSlider;
        [SerializeField] Text m_TaskProgress;
        [SerializeField] UIEffect m_EffectInduction;
        [SerializeField] UIEffect m_EffectInduction1;
        [SerializeField] HumanTreasureTaskCell m_HumanTaskCell;
 
        [SerializeField] ScrollerController m_TaskController;
 
        bool animationStep = false;
 
        float displayTime = 0f;
 
        List<int> animationClues = new List<int>();
 
        TreasureModel model
        {
            get { return ModelCenter.Instance.GetModel<TreasureModel>(); }
        }
 
        TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
        RoleModel roleModel { get { return ModelCenter.Instance.GetModel<RoleModel>(); } }
 
        protected override void BindController()
        {
            m_TaskController.lockType = EnhanceLockType.KeepVertical;
        }
 
        protected override void AddListeners()
        {
            m_Challenge.AddListener(Challenge);
            m_ViewDetail.AddListener(ViewDetail);
 
            m_TaskController.OnRefreshCell += OnRefreshCell;
            m_TaskController.OnGetDynamicSize += OnGetDynamicSize;
        }
 
        protected override void OnPreOpen()
        {
            animationStep = false;
            model.isClickInduction = false;
            TreasureBaseWin.allowSelectTreasure += AllowSelectTreasure;
            model.treasureSelectedEvent += TreasureSelectedEvent;
            model.onInductionTaskComplete += OnInductionTaskComplete;
            HumanTreasureSkillDetailWin.onPreviewTreasureSkill += OnPreviewTreasureSkill;
            roleModel.OnCustomAwardsEvent += OnCustomAwardsEvent;
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            Display();
            DisplayAnimation();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            TreasureBaseWin.allowSelectTreasure -= AllowSelectTreasure;
            model.treasureSelectedEvent -= TreasureSelectedEvent;
            model.onInductionTaskComplete -= OnInductionTaskComplete;
            HumanTreasureSkillDetailWin.onPreviewTreasureSkill -= OnPreviewTreasureSkill;
            roleModel.OnCustomAwardsEvent -= OnCustomAwardsEvent;
 
            StopAllCoroutines();
        }
 
        protected override void OnAfterClose()
        {
        }
 
        void Display()
        {
            DisplayBase();
            DisplayProgress();
            DisplayTasks();
        }
 
        void DisplayBase()
        {
            //var config = TreasureConfig.Get(model.selectedTreasure);
            //m_TreasureName.SetSprite(config.TreasureNameIcon);
            //m_TreasureStory.text = config.Story;
 
            //var chapterConfig = TreasureChapterConfig.Get(model.selectedTreasure);
            //m_ChallengeCondition.text = chapterConfig.condition;
            //m_TaskClueTitle.text = chapterConfig.taskClueTitle;
 
            //List<int> tasks = null;
            //if (model.TryGetTreasureTasks(model.selectedTreasure, out tasks))
            //{
            //    var taskConfig = TaskListConfig.Get(tasks[0]);
            //    m_TaskTitle.text = taskConfig.ChapterName;
            //}
 
            //Treasure treasure;
            //if (model.TryGetTreasure(model.selectedTreasure, out treasure))
            //{
            //    var skillId = treasure.skillId;
            //    var skillConfig = SkillConfig.Get(skillId);
            //    m_SkillIcon.SetSprite(skillConfig.IconName);
            //    m_SkillName.text = skillConfig.SkillName;
            //}
        }
 
        void DisplayProgress()
        {
            Treasure treasure;
            if (model.TryGetTreasure(model.selectedTreasure, out treasure))
            {
                var satisfyChallenge = model.SatisfyChallenge(model.selectedTreasure);
 
                m_Challenge.SetActive(satisfyChallenge);
                m_ContainerCondition.SetActive(!satisfyChallenge && treasure.state != TreasureState.Collected);
 
                var progress = 1f;
 
                Dictionary<int, List<int>> clues;
                if (model.TryGetTreasureClues(model.selectedTreasure, out clues))
                {
                    var count = model.GetCompleteTaskCount(model.selectedTreasure);
                    progress = Mathf.Clamp01((float)count / clues.Count);
                    m_TaskProgress.text = StringUtility.Contact((int)(progress * 100), "%");
                }
 
                m_TaskSlider.value = progress;
            }
        }
 
        void DisplayTasks(bool taskAnimation = false)
        {
            //var inductionTaskId = 0;
            //model.TryGetLatestInductionTask(model.selectedTreasure, out inductionTaskId);
 
            //var inductionState = model.GetTreasureInductionState(model.selectedTreasure);
 
            //animationClues.Clear();
 
            //displayTime = 0f;
 
            //var index = -1;
            //var jumpIndex = -1;
 
            //m_TaskController.Refresh();
            //Dictionary<int, List<int>> clues;
            //if (model.TryGetTreasureClues(model.selectedTreasure, out clues))
            //{
            //    var lastClue = 0;
            //    foreach (var clue in clues.Keys)
            //    {
            //        var display = false;
            //        var tasks = clues[clue];
            //        switch (inductionState)
            //        {
            //            case -1:
            //            case 0:
            //                display = TaskListConfig.GetMissionIndex(inductionTaskId) > TaskListConfig.GetMissionIndex(tasks[tasks.Count - 1]);
            //                break;
            //            case 1:
            //                display = true;
            //                break;
            //        }
 
            //        var clueState = model.GetClueState(model.selectedTreasure, clue);
 
            //        if (display)
            //        {
            //            if (taskAnimation)
            //            {
            //                if (TaskListConfig.GetMissionIndex(model.displayInductionId) < TaskListConfig.GetMissionIndex(tasks[tasks.Count - 1]))
            //                {
            //                    animationClues.Add(clue);
            //                }
            //            }
 
            //            index++;
            //            m_TaskController.AddCell(ScrollerDataType.Header, clue);
            //            lastClue = clue;
 
            //            if (model.gotoAwardClue != -1)
            //            {
            //                if (clue == model.gotoAwardClue)
            //                    jumpIndex = index;
            //            }
            //            else if (clueState != 0)
            //            {
            //                jumpIndex = index;
            //            }
            //        }
            //    }
            //    HumanTreasureTaskCell.lastClue = lastClue;
            //    if (inductionState == 0)
            //    {
            //        index++;
            //        HumanTreasureTaskCell.lastClue = -1;
            //        m_TaskController.AddCell(ScrollerDataType.Normal, inductionTaskId);
            //        jumpIndex = index;
            //    }
            //}
            //m_TaskController.Restart();
 
            //if (taskAnimation)
            //{
            //    Clock.AlarmAfter(Mathf.CeilToInt(displayTime + 0.6f), () =>
            //    {
            //        m_TaskController.mScrollRect.enabled = true;
            //        animationClues.Clear();
            //    });
            //}
            //else
            //{
            //    m_TaskController.mScrollRect.enabled = true;
            //    if (jumpIndex != -1)
            //    {
            //        m_TaskController.JumpIndex(jumpIndex);
            //    }
            //}
            //model.gotoAwardClue = -1;
        }
 
        void DisplayAnimation()
        {
            animationStep = true;
 
            m_PositionTween1.Play();
            m_PositionTween2.Play();
 
            UI3DTreasureSelectStage.Instance.Tween(OnTweenComplete);
 
            m_Container.SetActive(false);
        }
 
        private void OnTweenComplete()
        {
            animationStep = false;
            m_Container.SetActive(true);
        }
 
        private void TreasureSelectedEvent(int obj)
        {
            StopAllCoroutines();
 
            m_PositionTween1.Stop();
            m_PositionTween2.Stop();
            m_PositionTween1.SetEndState();
            m_PositionTween2.SetEndState();
            m_Container.SetActive(true);
            UI3DTreasureSelectStage.Instance.SetEndState();
            Display();
        }
 
        private void OnPreviewTreasureSkill(bool state)
        {
            if (state)
            {
                UI3DTreasureSelectStage.Instance.CloseRenderCamera();
            }
            else
            {
                UI3DTreasureSelectStage.Instance.OpenRenderCamera();
            }
        }
 
        private void OnInductionTaskComplete(int id)
        {
            if (id == model.selectedTreasure)
            {
                var count = m_TaskController.GetNumberOfCells(m_TaskController.m_Scorller);
                m_TaskController.JumpIndex(count - 1);
                m_EffectInduction.Play();
                m_EffectInduction1.Play();
                m_TaskController.mScrollRect.enabled = false;
                StartCoroutine(Co_DelayShowTask());
            }
        }
 
        IEnumerator Co_DelayShowTask()
        {
            yield return WaitingForSecondConst.WaitMS3000;
            DisplayTasks(true);
 
            yield return WaitingForSecondConst.WaitMS1000;
            if (model.selectedTreasure == 102 && !NewBieCenter.Instance.inGuiding
                && !NewBieCenter.Instance.IsGuideCompleted(128))
            {
                FunctionalGuideCenter.Instance.StartGuide(128);
            }
        }
 
        private void Challenge()
        {
            var config = TreasureConfig.Get(model.selectedTreasure);
            if (config != null)
            {
                if (model.selectedTreasure == 101)
                {
                    ClientDungeonStageUtility.GotoNormalClientDungeon(TreasureModel.CLIENTDATAMAP, TreasureModel.CLIENTDATAMAP, 0);
                    return;
                }
                if (PlayerDatas.Instance.baseData.LV >= config.ChallengeLevel)
                {
                    model.collectingHuman = model.selectedTreasure;
                    ModelCenter.Instance.GetModel<DungeonModel>().SingleChallenge(TreasureModel.TREASURE_DATAMAPID, config.LineId);
                }
            }
        }
 
        private void ViewDetail()
        {
            HumanTreasureSkillDetailWin.treasureId = model.selectedTreasure;
            WindowCenter.Instance.Open<HumanTreasureSkillDetailWin>();
        }
 
        private bool AllowSelectTreasure(int treasureId)
        {
            if (NewBieCenter.Instance.inGuiding || animationStep)
            {
                return false;
            }
            return true;
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            if (type == ScrollerDataType.Header)
            {
                var taskCell = cell as HumanTreasureTaskCell;
                taskCell.transform.SetParent(m_TaskController.m_Scorller.LayoutGroup.transform);
                var animation = false;
                if (animationClues.Contains(cell.index))
                {
                    animation = true;
                    displayTime += 0.6f;
                }
                taskCell.Display(cell.index, animation, displayTime);
            }
            else if (type == ScrollerDataType.Normal)
            {
                var taskCell = cell as HumanInductionTaskCell;
                taskCell.Display(cell.index);
            }
        }
 
        private bool OnGetDynamicSize(ScrollerDataType type, int index, out float height)
        {
            height = 0;
            //if (type == ScrollerDataType.Normal)
            //{
            //    return false;
            //}
            //else
            //{
            //    var config = TreasureConfig.Get(model.selectedTreasure);
            //    Dictionary<int, List<int>> clues;
            //    if (model.TryGetTreasureClues(model.selectedTreasure, out clues)
            //        && clues.ContainsKey(index))
            //    {
            //        var tasks = clues[index];
            //        var clueState = model.GetClueState(model.selectedTreasure, index);
            //        if (clueState == 1 && tasks.Count > 0)
            //        {
            //            var text = m_HumanTaskCell.taskName;
            //            var singleLabelHeight = text.rectTransform.rect.height;
            //            var labelHeight = 0f;
            //            bool hasAward = false;
            //            for (int i = 0; i < tasks.Count; i++)
            //            {
            //                var taskConfig = TaskListConfig.Get(tasks[i]);
            //                var taskInfoConfig = TASKINFOConfig.Get(taskConfig.TaskName);
            //                if (taskInfoConfig != null)
            //                {
            //                    labelHeight += m_HumanTaskCell.taskName.cachedTextGeneratorForLayout.GetPreferredHeight(taskInfoConfig.show_writing,
            //                        text.GetGenerationSettings(new Vector2(text.rectTransform.rect.size.x, 0.0f))) / text.pixelsPerUnit;
            //                }
            //                else
            //                {
            //                    labelHeight += singleLabelHeight;
            //                }
            //                if (taskConfig.AwardID > 0)
            //                {
            //                    hasAward = true;
            //                }
            //            }
            //            labelHeight += hasAward ? 82 : 0;
 
            //            height = m_HumanTaskCell.height + (m_HumanTaskCell.taskLayout.spacing * (tasks.Count - 1)) + labelHeight
            //                + m_HumanTaskCell.taskLayout.padding.top + m_HumanTaskCell.taskLayout.padding.bottom;
            //            return true;
            //        }
            //        else if (tasks.Count > 0)
            //        {
            //            for (int i = 0; i < tasks.Count; i++)
            //            {
            //                var taskConfig = TaskListConfig.Get(tasks[i]);
            //                if (taskConfig.AwardID > 0)
            //                {
            //                    height = m_HumanTaskCell.height + 82;
            //                    return true;
            //                }
            //            }
            //        }
            //    }
            //}
            return false;
        }
 
        void OnCustomAwardsEvent()
        {
            m_TaskController.m_Scorller.RefreshActiveCellViews();
        }
    }
}