少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
 
public class SimpleMapTrasfer : MonoBehaviour
{
    private Vector3 target;
    private SFXController cloud;
    private Animator moveAnimator;
    private UnityAction m_OnStarted;
    private UnityAction m_OnFinished;
    private bool m_IsMoveHero;
    public int curveType = 1;
 
    public void Init(int effectID, Vector3 position, bool isMoveHero, UnityAction onStart, UnityAction onFinished)
    {
        target = position;
        if (effectID != -1)
        {
            cloud = SFXPlayUtility.Instance.PlayWithEulerAngle(effectID, transform.position, Vector3.zero);
            cloud.duration = -1;
            cloud.transform.position = transform.position;
            moveAnimator = cloud.transform.GetComponent<Animator>();
            moveAnimator.enabled = false;
            moveAnimator.Play("Empty");
        }
        m_OnFinished = null;
        m_OnStarted = null;
        m_OnFinished += onFinished;
        m_OnStarted += onStart;
        m_IsMoveHero = isMoveHero;
        m_HasHandle = false;
 
        if (!isMoveHero)
        {
            StopCoroutine("CheckHeroPosition");
            StartCoroutine("CheckHeroPosition");
        }
    }
 
    bool m_HasHandle = false;
 
    private void OnTriggerEnter(Collider other)
    {
        if (m_HasHandle)
        {
            return;
        }
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        if (_hero == null)
        {
            return;
        }
 
        if (m_OnStarted != null)
        {
            m_OnStarted();
            m_OnStarted = null;
        }
 
        if (m_IsMoveHero)
        {
            StartCoroutine(MoveHero());
        }
 
        vnxbqy.UI.WindowCenter.Instance.Close<vnxbqy.UI.NewGuideWin>();
        vnxbqy.UI.WindowCenter.Instance.Close<vnxbqy.UI.GuideMessageWin>();
 
        m_HasHandle = true;
    }
 
    private void OnTriggerStay(Collider other)
    {
        if (m_HasHandle)
        {
            return;
        }
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        if (_hero == null)
        {
            return;
        }
 
        if (m_OnStarted != null)
        {
            m_OnStarted();
            m_OnStarted = null;
        }
 
        if (m_IsMoveHero)
        {
            StartCoroutine(MoveHero());
        }
 
        vnxbqy.UI.WindowCenter.Instance.Close<vnxbqy.UI.NewGuideWin>();
        vnxbqy.UI.WindowCenter.Instance.Close<vnxbqy.UI.GuideMessageWin>();
 
        m_HasHandle = true;
    }
 
    private IEnumerator CheckHeroPosition()
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        if (_hero == null)
        {
            yield break;
        }
 
        float _distSqrt = float.MaxValue;
        float _radius = transform.localScale.x * .5f;
        while (_distSqrt > _radius * _radius)
        {
            _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, target);
            yield return null;
        }
 
        if (m_OnFinished != null)
        {
            m_OnFinished();
        }
    }
 
    private IEnumerator MoveHero()
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        if (_hero == null)
        {
            yield break;
        }
 
        if (_hero.State == E_ActorState.AutoRun)
        {
            _hero.StopPathFind();
        }
 
        _hero.IdleImmediate();
        _hero.needSyncGroundHeight = false;
        GA_Hero.s_MapSwitching = true;
 
        if (curveType == 1)
        {
            if (moveAnimator != null)
            {
                moveAnimator.enabled = true;
                moveAnimator.Play("Yun_Move_1");
            }
        }
        else
        {
            if (moveAnimator != null)
            {
                moveAnimator.enabled = true;
                moveAnimator.Play("Yun_Move_2");
            }
        }
 
        _hero.Root.SetParent(cloud.transform);
 
        while (moveAnimator != null
            && moveAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1f)
        {
            _hero.PrevPos = _hero.Pos = cloud.transform.position;
 
            yield return null;
        }
 
        _hero.Root.SetParent(null);
        DontDestroyOnLoad(_hero.Root);
        _hero.needSyncGroundHeight = true;
        GA_Hero.s_MapSwitching = false;
 
        if (m_OnFinished != null)
        {
            m_OnFinished();
        }
 
        yield return WaitingForSecondConst.WaitMS1000;
 
        if (moveAnimator != null)
        {
            moveAnimator.Play("Empty");
        }
 
        yield return null;
        SFXPlayUtility.Instance.Release(cloud);
        cloud = null;
        moveAnimator = null;
    }
}