少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-25 cdb0198fb8e85811ec1e06b15f36df9cbe0fdb9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
namespace Snxxz.UI
{
    public class TreasureAnimation : MonoBehaviour
    {
        [SerializeField] UIAlphaTween m_DisplayAlphaTween;
 
        [SerializeField] RectTransform m_ContainerStars;
        [SerializeField] PositionTween m_StarPositionTween;
        [SerializeField] UIEffect[] m_Stars;
 
        [SerializeField] TreasureMeridianBehaviour[] m_TreasureMeridians;
 
        [SerializeField] PositionTween m_AchievementPosTween;
        [SerializeField] PositionTween m_ProgressPosTween;
 
        [SerializeField] RectTransform m_ContianerPotential;
        [SerializeField] RectTransform m_ContainerLevelUp;
 
        [SerializeField] PositionTween m_SkillPosTween;
        [SerializeField] ScaleTween m_SkillSclTween;
        [SerializeField] ScaleTween m_PotentialSclTween;
 
        [SerializeField] RectTransform m_AchievementSfxTarget;
 
        [SerializeField] PositionTween m_HeroShowSkillPowTween;
        [SerializeField] RectTransform m_ContainerSkillShowBottom;
 
        [SerializeField] ScaleTween[] m_PotentialPointSclTweens;
 
        [SerializeField] TreasurePotentialBriefInfo[] m_TreasurePotentials;
        [SerializeField] RectTransform[] m_PotentialLineMasks;
        [SerializeField] RectTransform m_PotentialSkill;
 
        TreasureModel m_Model;
        TreasureModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TreasureModel>());
            }
        }
 
        #region const
        const int POTENTIALUNLOCKSFX = 5190;
        public const int SPIRALSFX = 5126;
        const int CONVERGESFX = 5127;
        public const float LINE_NORMAL_LENGTH = 187f;
        public const float LINE_NORMAL_SCALE = 0.78f;
        const float POTENTIAL_TIME_SCALE = 0.5f;
        const float SPIRAL_SFX_TIME_SCALE = 0.6f;
        const float LINE_SFX_TIME_SCALE = 0.3f;
        const float POSITION_TWEEN_SPEED = 300f;
        public const int LINESFX = 5121;
        public const string LINE_STATE_1 = "Effect_FaBao_Xian1_01";
        public const string LINE_STATE_2 = "Effect_FaBao_Xian1_02";
        public const string LINE_STATE_3 = "Effect_FaBao_Xian1_03";
        public const string LINE_STATE_4 = "Effect_FaBao_Xian1_04";
        public const string LINE_STATE_5 = "Effect_FaBao_Xian1_05";
 
        public const int POTENTIAL_LINESFX = 5173;
        public const string POTENTIAL_LINE_STATE_1 = "Effect_FaBao_Xian2";
        public const string POTENTIAL_LINE_STATE_2 = "Effect_FaBao_Xian2_02";
 
        public static readonly int Param_Step = Animator.StringToHash("Step");
        #endregion
 
        #region public
        public int selectTreasureId { get; set; }
 
        private int displayTreasure { get; set; }
 
        public event Action OnStageUpLineComplete;
        public event Action<TreasureShowStep> OnStepComplete;
        public event Action<int> OnAchievementSfxComplete;
        public event Action OnAchievementTweenComplete;
        public event Action<int> OnUnlockPotentialComplete;
        public event Action<int,int> OnPotentialLevelUpComplete;
        public event Action<int> OnPotentialLineAnimComplete;
 
        TreasureShowStep m_Step = TreasureShowStep.None;
        TreasureShowStep m_BeforeStep = TreasureShowStep.None;
        public TreasureShowStep step
        {
            get
            {
                return m_Step;
            }
            set
            {
                stepComplete = true;
                if (step == value && value != TreasureShowStep.Lock)
                {
                    if (value == TreasureShowStep.UnLock)
                    {
                        m_ProgressPosTween.SetEndState();
                        m_PotentialSclTween.SetEndState();
                        UI3DTreasureSelectStage.Instance.SetEndState();
                    }
                    return;
                }
                switch (m_BeforeStep)
                {
                    case TreasureShowStep.Lock:
                        if (value != TreasureShowStep.Lock)
                        {
                            ExitShowLock();
                        }
                        break;
                }
                m_Step = value;
                m_BeforeStep = value;
                switch (value)
                {
                    case TreasureShowStep.Lock:
                        OnEnterShowLock();
                        break;
                    case TreasureShowStep.FirstUnLock:
                        OnEnterFisrtUnlock();
                        break;
                    case TreasureShowStep.UnLock:
                        OnEnterShowUnLock();
                        break;
                    case TreasureShowStep.FirstPotential:
                        OnEnterFirstPotential();
                        break;
                    case TreasureShowStep.Potential:
                        OnEnterPotential();
                        break;
                }
            }
        }
 
        public void DisplayPotentialLevelUp(int _index, int level)
        {
            if (_index >= m_TreasurePotentials.Length || _index < 0)
            {
                return;
            }
            if (level == 15 && _index < 2)
            {
                stepComplete = false;
            }
            displayTreasure = model.selectedTreasure;
            StartCoroutine(Co_PotentialLevelUp(_index, level));
        }
 
        IEnumerator Co_PotentialLevelUp(int _index, int level)
        {
            yield return StartCoroutine(Co_PotentialSpiral(_index, SPIRALSFX));
            if (displayTreasure != model.selectedTreasure)
            {
                stepComplete = true;
                yield break;
            }
            //UIEffect effect = null;
            //if (level == 1)
            //{
            //    effect = EffectMgr.Instance.PlayUIEffect(POTENTIAL_LINESFX, 2100, transform, false);
            //    if (effect == null)
            //    {
            //        stepComplete = true;
            //        yield break;
            //    }
            //    effect.keep = true;
            //    effect.maskArea = m_PotentialLineMasks[_index];
            //    effect.SetMask();
            //    yield return StartCoroutine(Co_DisplayPotentialLine(_index,effect));
            //}
            if (displayTreasure != model.selectedTreasure)
            {
                //StopPotentialLineEffect(effect);
                stepComplete = true;
                yield break;
            }
            if (OnPotentialLevelUpComplete != null)
            {
                OnPotentialLevelUpComplete(_index, level);
            }
            stepComplete = true;
            //yield return null;
            //StopPotentialLineEffect(effect);
        }
 
        public void DisplayPotentialLine(int _index)
        {
            stepComplete = false;
            StartCoroutine(Co_PotentialLineAnim(_index));
        }
 
        IEnumerator Co_PotentialLineAnim(int _index)
        {
            UIEffect effect = EffectMgr.Instance.PlayUIEffect(POTENTIAL_LINESFX, 2100, transform, false);
            if (effect == null)
            {
                stepComplete = true;
                yield break;
            }
            effect.keep = true;
            effect.maskArea = m_PotentialLineMasks[_index];
            effect.SetMask();
            yield return StartCoroutine(Co_DisplayPotentialLine(_index, effect));
            stepComplete = true;
            StopPotentialLineEffect(effect);
            if (OnPotentialLineAnimComplete != null)
            {
                OnPotentialLineAnimComplete(_index);
            }
        }
 
        private void StopPotentialLineEffect(UIEffect _effect)
        {
            if (_effect != null)
            {
                _effect.keep = false;
                _effect.maskArea = null;
                _effect.StopImediatly();
                _effect = null;
            }
        }
 
        IEnumerator Co_PotentialSpiral(int _index, int effectId)
        {
            var effect = EffectMgr.Instance.PlayUIEffect(effectId, 2700, m_TreasurePotentials[_index].transform, false);
            var duration = effect.duration;
            var _time = 0f;
            while (_time < duration)
            {
                _time += Time.deltaTime;
                yield return null;
                if (displayTreasure != model.selectedTreasure)
                {
                    effect.StopImediatly();
                    effect = null;
                    yield break;
                }
            }
        }
 
        IEnumerator Co_DisplayPotentialLine(int _index,UIEffect effect)
        {
            var _duration = effect.duration;
            var _time = 0f;
            var _frompos = transform.InverseTransformPoint(m_TreasurePotentials[_index].transform.TransformPoint(Vector3.zero));
            var _topos = transform.InverseTransformPoint(m_PotentialSkill.transform.TransformPoint(Vector3.zero));
            effect.transform.localPosition = _frompos;
            var _angle = VectorUtility.VectorAngle(_topos, _frompos);
            effect.transform.localEulerAngles = Vector3.zero.SetZ(_angle);
            var _animator = effect.target.GetAnimator();
            _animator.transform.localScale = Vector3.one.SetY(Vector2.Distance(_topos, _frompos)
                / LINE_NORMAL_LENGTH * LINE_NORMAL_SCALE);
            _animator.Play(POTENTIAL_LINE_STATE_1, 0, 0);
            while (_time < _duration)
            {
                _time += Time.deltaTime;
                yield return null;
                if (displayTreasure != model.selectedTreasure)
                {
                    yield break;
                }
            }
        }
 
        public void UnlockTreasurePotential(int _index)
        {
            if (_index >= m_TreasurePotentials.Length || _index < 0)
            {
                return;
            }
            stepComplete = false;
            displayTreasure = model.selectedTreasure;
            StartCoroutine(Co_UnlockTreasurePotential(_index));
        }
 
        IEnumerator Co_UnlockTreasurePotential(int _index)
        {
            StartCoroutine(Co_PotentialSpiral(_index, POTENTIALUNLOCKSFX));
            yield return WaitingForSecondConst.WaitMS600;
            if (displayTreasure != model.selectedTreasure)
            {
                stepComplete = true;
                yield break;
            }
            stepComplete = true;
            m_TreasurePotentials[_index].DisplayUnlock();
            if (OnUnlockPotentialComplete != null)
            {
                OnUnlockPotentialComplete(_index);
            }
        }
 
        public void OnStageUp(int _index)
        {
            stepComplete = false;
            StartCoroutine(Co_StepStage(_index));
        }
 
        IEnumerator Co_StepStage(int _index)
        {
            float _timer = 0f;
            float _duration = 0f;
            var _config = ScriptableObjectLoader.LoadSoTreasureMeridian(model.selectedTreasure);
            var _effect = EffectMgr.Instance.PlayUIEffect(SPIRALSFX, 2700, m_TreasureMeridians[_index].transform.parent, false);
            _effect.transform.localPosition = _config[_index].position;
            _duration = _effect.duration;
 
            if (_index == _config.stagePointNum - 1 && m_ProgressPosTween.gameObject.activeInHierarchy)
            {
                m_ProgressPosTween.Play(true);
            }
 
            while (_timer < _duration)
            {
                _timer += Time.deltaTime;
                yield return null;
            }
            _duration = 0.3f;
            _timer = 0f;
            var _current = m_TreasureMeridians[_index];
            _current.RequestStateSfx();
            _current.selectSfx.Play();
            if (_current.selectSfx.IsPlaying)
            {
                _current.selectSfx.transform.DOScale(Vector3.zero, _duration);
            }
            while (_timer < _duration)
            {
                _timer += Time.deltaTime;
                yield return null;
            }
            _current.selectSfx.StopImediatly();
 
            stepComplete = true;
            if (OnStageUpLineComplete != null)
            {
                OnStageUpLineComplete();
            }
        }
 
        public void OnStageLock(int _index)
        {
            StartCoroutine(Co_StageLock(_index));
        }
 
        IEnumerator Co_StageLock(int _index)
        {
            float _timer = 0f;
            float _duration = 0f;
            stepComplete = false;
            var _config = ScriptableObjectLoader.LoadSoTreasureMeridian(model.selectedTreasure);
            _index = Mathf.Max(_index, 0);
            var _current = m_TreasureMeridians[_index];
            if (_index < 0)
            {
                stepComplete = true;
                yield break;
            }
            if (_index < _config.stagePointNum - 1)
            {
                var _effect = EffectMgr.Instance.PlayUIEffect(LINESFX, 2500, m_TreasureMeridians[_index].transform.parent, false);
                _effect.transform.localPosition = _config[_index].position;
                var _angle = VectorUtility.VectorAngle(_config[_index + 1].position, _config[_index].position);
                _effect.transform.localEulerAngles = Vector3.zero.SetZ(_angle);
                var _animator = _effect.target.GetAnimator();
                _animator.transform.localScale = Vector3.one.SetY(Vector2.Distance(_config[_index + 1].position, _config[_index].position)
                    / LINE_NORMAL_LENGTH * LINE_NORMAL_SCALE);
                _animator.Play(LINE_STATE_1, 0, 0);
                _duration = _effect.duration;
                _timer = 0f;
                while (_timer < _duration * 0.6f)
                {
                    _timer += Time.deltaTime;
                    yield return null;
                }
                _effect.StopImediatly();
                var _next = m_TreasureMeridians[_index + 1];
                _current.RequestSfx();
                _next.RequestSfx();
                _duration = 0.3f;
                _timer = 0f;
                if (_next.selectSfx.IsPlaying)
                {
                    _next.selectSfx.transform.localScale = Vector3.zero;
                    _next.selectSfx.transform.DOScale(Vector3.one, _duration);
                }
                while (_timer < _duration)
                {
                    _timer += Time.deltaTime;
                    yield return null;
                }
            }
            stepComplete = true;
            if (OnStageUpLineComplete != null)
            {
                OnStageUpLineComplete();
            }
        }
 
        public void OnHeroSkillShow(int _index)
        {
            var _config = ScriptableObjectLoader.LoadSoTreasureMeridian(selectTreasureId);
            m_HeroShowSkillPowTween.gameObject.SetActive(true);
            m_ContainerSkillShowBottom.gameObject.SetActive(false);
            m_HeroShowSkillPowTween.from = _config[_index].position;
            m_HeroShowSkillPowTween.SetStartState();
            m_HeroShowSkillPowTween.Play(()=> 
            {
                m_ContainerSkillShowBottom.gameObject.SetActive(true);
            });
        }
 
        public void TreasureTween(bool _play = false)
        {
            UI3DTreasureSelectStage.Instance.SetStartState();
            if (_play)
            {
                UI3DTreasureSelectStage.Instance.Tween(null);
            }
        }
 
        [Header("领取成就特效")]
        [SerializeField, Header("单个飞行时间")]
        float achievement_sfx_duration = 1.0f;
        [SerializeField, Header("特效间隔时间")]
        float achievement_sfx_interval = 0.15f;
        [SerializeField, Header("特效个数")]
        int achievement_sfx_count = 5;
        public void ShowAchievementCompleteSfx(RectTransform _root, int _id)
        {
            var _worldPos = _root.TransformPoint(Vector3.zero);
            var _startPos = transform.InverseTransformPoint(_worldPos);
            _worldPos = m_AchievementSfxTarget.TransformPoint(Vector3.zero);
            var _endPos = transform.InverseTransformPoint(_worldPos);
            StartCoroutine(Co_AchivementGotSfx(_startPos, _endPos, _id));
        }
 
        IEnumerator Co_AchivementGotSfx(Vector3 _start, Vector3 _end, int _id)
        {
            float _timer = 0f;
            bool _boom = false;
            var _n = _end - _start;
            var _selectTreasure = selectTreasureId;
            _n = (Quaternion.AngleAxis(90, Vector3.forward) * _n).normalized;
            List<Vector3> _points = new List<Vector3>(achievement_sfx_count);
            List<UIEffect> _effects = new List<UIEffect>(achievement_sfx_count);
            UIEffect _boomSfx = null;
            for (int i = 0; i < achievement_sfx_count; i++)
            {
                var _d = UnityEngine.Random.Range(50f, 200.0f);
                var _m = (_start + _end) / 2 + (_d * (i % 2 == 0 ? 1 : -1)) * _n;
                _points.Add(_m);
            }
            while (_timer < achievement_sfx_duration +
                achievement_sfx_interval * (achievement_sfx_count - 1))
            {
                if (_selectTreasure != selectTreasureId)
                {
                    for (int i = 0; i < _effects.Count; i++)
                    {
                        _effects[i].StopImediatly();
                        _effects[i] = null;
                    }
                    if (_boomSfx != null)
                    {
                        _boomSfx.StopImediatly();
                        _boomSfx = null;
                    }
                    yield break;
                }
                yield return null;
                _timer += Time.deltaTime;
                int _count = Mathf.Min((int)(_timer / achievement_sfx_interval) + 1, achievement_sfx_count);
                for (int i = 0; i < _count; i++)
                {
                    if (_effects.Count < i + 1 || _effects[i] == null)
                    {
                        var _effect = EffectMgr.Instance.PlayUIEffect(3009, 2700, transform, _start, true);
                        _effects.Add(_effect);
                    }
                    var _t = Mathf.Clamp01((_timer - achievement_sfx_interval * i) / achievement_sfx_duration);
                    var _pos = Bezier.BezierCurve(_start, _points[i], _end, _t);
                    _effects[i].transform.localPosition = _pos;
                }
                if (!_boom && _timer > achievement_sfx_duration +
                    achievement_sfx_interval * (achievement_sfx_count - 1) - 0.5f)
                {
                    _boom = true;
                    _boomSfx = EffectMgr.Instance.PlayUIEffect(5138, 2500, transform, _end, false);
                }
            }
            for (int i = 0; i < _effects.Count; i++)
            {
                _effects[i].StopImediatly();
                _effects[i] = null;
            }
            _effects.Clear();
            if (OnAchievementSfxComplete != null)
            {
                OnAchievementSfxComplete(_id);
            }
        }
 
        public void SetDisplayEnd()
        {
            m_DisplayAlphaTween.SetEndState();
        }
        #endregion
 
        #region private
        float timer = 0f;
        public bool stepComplete { get; set; }
 
        List<UIEffect> m_LineSfxs = new List<UIEffect>();
 
        private void Init()
        {
            m_ContainerStars.gameObject.SetActive(false);
        }
 
        void ExitShowLock()
        {
            m_ContainerStars.gameObject.SetActive(false);
        }
 
        void OnEnterShowLock()
        {
            m_DisplayAlphaTween.SetStartState();
            m_DisplayAlphaTween.Play();
            m_ContainerStars.gameObject.SetActive(true);
            m_StarPositionTween.SetStartState();
            TreasureMeridianConfig _config = ScriptableObjectLoader.LoadSoTreasureMeridian(selectTreasureId);
            for (int i = 0; i < m_Stars.Length; i++)
            {
                if (_config == null || i >= _config.stagePointNum)
                {
                    m_Stars[i].gameObject.SetActive(false);
                }
                else
                {
                    m_Stars[i].gameObject.SetActive(true);
                    m_Stars[i].StopImediatly();
                    m_Stars[i].effect = _config[i].effect;
                    m_Stars[i].transform.localPosition = _config[i].position;
                    m_Stars[i].Play();
                    m_Stars[i].target.GetAnimator().Play("Effect_FaBao_Light_1", 0, UnityEngine.Random.Range(0, 0.8f));
                }
            }
 
            TreasureTween();
        }
 
        void OnEnterFisrtUnlock()
        {
            OnEnterShowLock();
 
            m_DisplayAlphaTween.SetStartState();
            m_AchievementPosTween.SetStartState();
            m_ProgressPosTween.SetStartState();
            m_StarPositionTween.SetStartState();
 
            for (int i = 0; i < m_TreasureMeridians.Length; i++)
            {
                m_TreasureMeridians[i].gameObject.SetActive(false);
            }
 
            stepComplete = false;
            m_DisplayAlphaTween.Play(() =>
            {
                TreasureTween(true);
                m_StarPositionTween.Play(OnStarTweenComplete);
            });
        }
 
        void OnStarTweenComplete()
        {
            timer = 0;
            StartCoroutine(Co_ShowMeridianLine());
        }
 
        IEnumerator Co_ShowMeridianLine()
        {
            var _index = 0;
            TreasureMeridianConfig _config = ScriptableObjectLoader.LoadSoTreasureMeridian(selectTreasureId);
            RecycleLineSfx();
            var _duration = 0f;
            while (_index < _config.stagePointNum)
            {
                timer = 0f;
                var _effect1 = EffectMgr.Instance.PlayUIEffect(SPIRALSFX, 2700, m_TreasureMeridians[_index].transform.parent, false);
                _effect1.transform.position = m_TreasureMeridians[_index].transform.position;
                _duration = _effect1.duration;
                while (timer < _duration * SPIRAL_SFX_TIME_SCALE)
                {
                    yield return null;
                }
                m_TreasureMeridians[_index].gameObject.SetActive(true);
                m_TreasureMeridians[_index].RequestStateSfx();
                m_Stars[_index].StopImediatly();
                timer = 0f;
                if (_index < _config.stagePointNum - 1)
                {
                    var _effect2 = EffectMgr.Instance.PlayUIEffect(LINESFX, 2500, m_TreasureMeridians[_index].transform.parent, false);
                    _duration = _effect2.duration;
                    _effect2.keep = true;
                    m_LineSfxs.Add(_effect2);
                    _effect2.transform.position = m_TreasureMeridians[_index].transform.position;
                    var _angle = VectorUtility.VectorAngle(_config[_index + 1].position, _config[_index].position);
                    _effect2.transform.localEulerAngles = Vector3.zero.SetZ(_angle);
                    var _animator = _effect2.target.GetAnimator();
                    _animator.transform.localScale = Vector3.one.SetY(Vector2.Distance(_config[_index + 1].position, _config[_index].position)
                        / LINE_NORMAL_LENGTH * LINE_NORMAL_SCALE);
                    _animator.SetInteger(Param_Step, 0);
                    _animator.Play(LINE_STATE_1, 0, 0);
                    while (timer < _duration * LINE_SFX_TIME_SCALE)
                    {
                        yield return null;
                    }
                    _animator.SetInteger(Param_Step, 1);
                }
                _index++;
            }
            for (int i = 0; i < _config.stagePointNum; i++)
            {
                m_TreasureMeridians[i].PlayLineSfx(2, true);
            }
            RecycleLineSfx();
            timer = 0f;
            _duration = m_AchievementPosTween.duration + m_AchievementPosTween.delay;
            m_AchievementPosTween.Play(() =>
            {
                if (OnAchievementTweenComplete != null)
                {
                    OnAchievementTweenComplete();
                }
            });
            Treasure treasure;
            model.TryGetTreasure(selectTreasureId, out treasure);
            if (!treasure.IsHighestStage)
            {
                m_ProgressPosTween.Play();
            }
            if (OnStepComplete != null)
            {
                OnStepComplete(TreasureShowStep.FirstUnLock);
            }
            while (timer < _duration)
            {
                yield return null;
            }
            stepComplete = true;
            model.TryGetTreasure(selectTreasureId, out treasure);
            if (treasure.treasureStages[0].unlockType != TreasureStageUnlock.None)
            {
                OnStageUp(0);
            }
            model.treasureEntranceShowId = 0;
        }
 
        void OnEnterShowUnLock()
        {
            stepComplete = false;
            m_DisplayAlphaTween.SetStartState();
            m_DisplayAlphaTween.Play();
 
            UI3DTreasureSelectStage.Instance.SetStartState();
 
            OnEnterPotential();
            m_ProgressPosTween.SetEndState();
            m_AchievementPosTween.SetEndState();
            m_PotentialSclTween.SetEndState();
 
 
            UI3DTreasureSelectStage.Instance.Tween(() =>
            {
                stepComplete = true;
                if (OnStepComplete != null)
                {
                    OnStepComplete(TreasureShowStep.UnLock);
                }
            });
        }
 
        void OnEnterFirstPotential()
        {
            timer = 0;
            stepComplete = false;
            for (int i = 0; i < m_TreasureMeridians.Length; i++)
            {
                m_TreasureMeridians[i].StopSfx();
            }
            StartCoroutine(Co_ShowFirstPotential());
        }
 
        IEnumerator Co_ShowFirstPotential()
        {
            Treasure _treasure;
            model.TryGetTreasure(selectTreasureId, out _treasure);
            if (_treasure == null)
            {
                stepComplete = true;
                yield break;
            }
            var _duration = 0.0f;
            var _stages = _treasure.treasureStages;
            var _config = ScriptableObjectLoader.LoadSoTreasureMeridian(model.selectedTreasure);
            var _skillStage = _stages.FindIndex((x) =>
            {
                return x.unlockType == TreasureStageUnlock.Skill;
            });
            var _skillStageIndex = _treasure.IndexOfStage(_skillStage);
            for (int i = 0; i < _config.stagePointNum; i++)
            {
                if (i == _skillStageIndex)
                {
                    continue;
                }
                _duration = Mathf.Max(m_TreasureMeridians[i].scaleTween.delay + m_TreasureMeridians[i].scaleTween.duration, _duration);
                m_TreasureMeridians[i].scaleTween.Play();
                m_TreasureMeridians[i].scaleTween.SetEndState();
            }
            while (timer < _duration)
            {
                yield return null;
            }
            timer = 0;
            _duration = 0;
            for (int i = 0; i < _config.stagePointNum; i++)
            {
                if (i == _skillStageIndex)
                {
                    continue;
                }
                var _positionTween = m_TreasureMeridians[i].positionTween;
                _positionTween.from = _config[i].position;
                _positionTween.to = _config[_skillStageIndex].position;
                var _distance = Vector2.Distance(_positionTween.from, _positionTween.to);
                _positionTween.duration = _distance / POSITION_TWEEN_SPEED;
                _duration = Mathf.Max(_positionTween.delay + _positionTween.duration, _duration);
                _positionTween.Play(() =>
                {
                    _positionTween.gameObject.SetActive(false);
                });
            }
            while (timer < _duration)
            {
                yield return null;
            }
            if (_config.stagePointNum > 1)
            {
                timer = 0;
                var _effect = EffectMgr.Instance.PlayUIEffect(CONVERGESFX, 2700, m_TreasureMeridians[_skillStageIndex].transform.parent, false);
                _effect.transform.localPosition = _config[_skillStageIndex].position;
                while (timer < 0.5f)
                {
                    yield return null;
                }
            }
            timer = 0;
            m_ContainerLevelUp.gameObject.SetActive(false);
            m_ContianerPotential.gameObject.SetActive(true);
            m_PotentialSclTween.SetStartState();
            m_SkillPosTween.from = _config[_skillStageIndex].position;
            m_SkillPosTween.SetStartState();
            m_SkillPosTween.Play();
            _duration = m_SkillPosTween.delay + m_SkillPosTween.duration;
            while (timer < _duration)
            {
                yield return null;
            }
            timer = 0;
            m_SkillSclTween.Play();
            m_SkillSclTween.SetEndState();
            _duration = m_SkillSclTween.delay + m_SkillSclTween.duration;
            while (timer < _duration * POTENTIAL_TIME_SCALE)
            {
                yield return null;
            }
            timer = 0f;
            m_PotentialSclTween.Play();
            _duration = m_PotentialSclTween.duration + m_PotentialSclTween.delay;
            while (timer < _duration)
            {
                yield return null;
            }
            for (int i = 0; i < m_PotentialPointSclTweens.Length; i++)
            {
                var _index = i;
                m_PotentialPointSclTweens[_index].Play();
                m_PotentialPointSclTweens[_index].SetEndState();
            }
            stepComplete = true;
            if (OnStepComplete != null)
            {
                OnStepComplete(TreasureShowStep.FirstPotential);
            }
        }
 
        private void OnEnterPotential()
        {
            m_SkillPosTween.SetEndState();
            m_SkillSclTween.SetEndState();
        }
 
        void RecycleLineSfx()
        {
            for (int i = 0; i < m_LineSfxs.Count; i++)
            {
                m_LineSfxs[i].keep = false;
                m_LineSfxs[i].StopImediatly();
            }
            m_LineSfxs.Clear();
        }
 
        private void LateUpdate()
        {
            switch (step)
            {
                case TreasureShowStep.FirstPotential:
                case TreasureShowStep.FirstUnLock:
                    timer += Time.deltaTime;
                    break;
            }
        }
        #endregion
 
        public enum TreasureShowStep
        {
            None,
            Lock,
            FirstUnLock,
            UnLock,
            FirstPotential,
            Potential,
        }
    }
}