少年修仙传客户端代码仓库
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
using UnityEngine;
 
 
public class SnxxzGame : SingletonMonobehaviour<SnxxzGame>
{
    private event UnityAction m_UpdateActions;
    private event UnityAction m_LateUpdateActions;
    private event UnityAction m_OnDrawGizmosActions;
    private event UnityAction onApplicationOutEvent;
 
    private void Awake()
    {
#if UNITY_EDITOR
        gameObject.AddMissingComponent<RuntimeLogUtility>();
#endif
 
        TargetBriefInfo.Init();
        ExperienceGetBehaviour.Init();
        SpGetBehaviour.Init();
        BossAreaMark.Init();
        HeroNearDeathBehaviour.Init();
        HeroRoundGird.Instance.Init(40, 40);
    }
 
    private void Update()
    {
        float _realTime = Time.realtimeSinceStartup;
        Vector4 _timeVec4 = new Vector4(_realTime * .05f, _realTime, _realTime * 2f, _realTime * 3f);
        Shader.SetGlobalVector("_RealTime", _timeVec4);
 
        if (m_UpdateActions != null)
        {
            m_UpdateActions();
        }
    }
 
    private void LateUpdate()
    {
        if (m_LateUpdateActions != null)
        {
            m_LateUpdateActions();
        }
    }
 
#if UNITY_EDITOR
    private void OnDrawGizmos()
    {
        if (m_OnDrawGizmosActions != null)
        {
            m_OnDrawGizmosActions();
        }
 
        Gizmos.color = Color.black;
 
        if (RuntimeLogUtility.s_ShowMapLine)
        {
            GA_Hero _hero = PlayerDatas.Instance.hero;
 
            int row = 50;
            int column = 50;
            float size = 0.5f;
 
            float _startX = (int)_hero.Pos.x - 12.5f;
            float _startZ = (int)_hero.Pos.z - 12.5f;
 
            if (_hero != null)
            {
                Vector3 _start;
                Vector3 _end;
 
                for (int i = 0; i < row + 1; ++i)
                {
                    _start = new Vector3(_startX, _hero.Pos.y + 0.001f, _startZ + i * size);
                    _end = new Vector3(_startX + column * .5f, _hero.Pos.y + 0.001f, _startZ + i * size);
 
                    Gizmos.DrawLine(_start, _end);
                }
 
                for (int i = 0; i < column + 1; ++i)
                {
                    _start = new Vector3(_startX + i * size, _hero.Pos.y + 0.001f, _startZ);
                    _end = new Vector3(_startX + i * size, _hero.Pos.y + 0.001f, _startZ + row * .5f);
 
                    Gizmos.DrawLine(_start, _end);
                }
            }
        }
    }
#endif
 
    protected sealed override void OnDestroy()
    {
        base.OnDestroy();
        m_UpdateActions = null;
        m_LateUpdateActions = null;
        m_OnDrawGizmosActions = null;
    }
 
    public void AddUpdateAction(UnityAction method)
    {
        m_UpdateActions += method;
    }
 
    public void RemoveUpdateAction(UnityAction method)
    {
        m_UpdateActions -= method;
    }
 
    public void AddLateUpdateAction(UnityAction method)
    {
        m_LateUpdateActions += method;
    }
 
    public void RemoveLateUpdateAction(UnityAction method)
    {
        m_LateUpdateActions -= method;
    }
 
    public void AddOnDrawGizmosAction(UnityAction method)
    {
        m_OnDrawGizmosActions += method;
    }
 
    public void RemoveOnDrawGizmosAction(UnityAction method)
    {
        m_OnDrawGizmosActions -= method;
    }
 
    public void AddApplicationOutAction(UnityAction method)
    {
        onApplicationOutEvent += method;
    }
 
    public void RemoveApplicationOutAction(UnityAction method)
    {
        onApplicationOutEvent -= method;
    }
 
    public void StartTimePause(float lastTime)
    {
        StopTimePause();
        StartCoroutine("DoTimePause", lastTime);
    }
 
    private void StopTimePause()
    {
        StopCoroutine("TimePause");
        Time.timeScale = 1;
    }
 
    private IEnumerator DoTimePause(float lastTime)
    {
        Time.timeScale = 0;
        float _startTime = Time.realtimeSinceStartup;
        while (Time.realtimeSinceStartup - _startTime < lastTime)
        {
            yield return null;
        }
        Time.timeScale = 1;
    }
 
    private void OnApplicationQuit()
    {
        if (MaterialUtility.m_HudMaterial != null)
        {
            MaterialUtility.m_HudMaterial.SetTexture("_Tex1", null);
            MaterialUtility.m_HudMaterial.SetTexture("_Tex2", null);
        }
 
        GameNetSystem.Instance.Disconnect();
 
        if (onApplicationOutEvent != null)
        {
            onApplicationOutEvent();
        }
    }
 
    private void OnApplicationPause(bool pause)
    {
        if (!Application.isEditor)
        {
            if (!pause)
            {
                ResolutionUtility.AdjustResolution();
            }
        }
    }
 
    private void OnApplicationFocus(bool focus)
    {
        if (focus)
        {
            PlayerDatas.Instance.RequestWorldTick();
            ynmbxxjUtil.Instance.SendShowFloatWin();
        }
        else
            ynmbxxjUtil.Instance.SendHideFloatWin();
    }
 
    public void MovingCamera(bool start, int type)
    {
        if (start)
        {
            StartCoroutine("Co_MovingCamera", type);
        }
        else
        {
            StopCoroutine("Co_MovingCamera");
        }
    }
 
    public void ResetCamera(bool start)
    {
        if (start)
        {
            StartCoroutine("Co_ResetCamera");
        }
        else
        {
            StopCoroutine("Co_ResetCamera");
        }
    }
 
    public void StopAllCameraCo()
    {
        StopCoroutine("Co_ResetCamera");
        StopCoroutine("Co_MovingCamera");
    }
 
    private IEnumerator Co_MovingCamera(int _type)
    {
        var _areaCamera = AreaCameraConfig.Get(_type);
 
        if (_areaCamera == null
         || GA_Hero.s_MapSwitching)
        {
            yield break;
        }
 
        CameraController.Instance.AcceptInput = true;
 
        CameraController.Instance.ZoomDamping = 0.5f;
        CameraController.Instance.RotationDamping = 0.5f;
 
        CameraController.Instance.sceneDistance = CameraController.Instance.Distance = _areaCamera.Distance * Constants.F_DELTA;
        CameraController.Instance.rotationX = _areaCamera.RotX * Constants.F_DELTA;
        CameraController.Instance.rotationY = _areaCamera.RotY * Constants.F_DELTA;
 
        float _time = 2f;
        while (_time > 0 && !GA_Hero.s_MapSwitching)
        {
            _time -= Time.deltaTime;
            yield return null;
        }
 
        if (GA_Hero.s_MapSwitching)
        {
            yield break;
        }
 
        CameraController.Instance.AcceptInput = false;
 
        CameraController.Instance.Distance = _areaCamera.Distance * Constants.F_DELTA;
        CameraController.Instance.rotationX = _areaCamera.RotX * Constants.F_DELTA;
        CameraController.Instance.rotationY = _areaCamera.RotY * Constants.F_DELTA;
 
        CameraController.Instance.ZoomDamping = 0.1f;
        CameraController.Instance.RotationDamping = 0.02f;
    }
 
    private IEnumerator Co_ResetCamera()
    {
        CameraController.Instance.AcceptInput = true;
 
        CameraController.Instance.ZoomDamping = 0.5f;
        CameraController.Instance.RotationDamping = 0.5f;
 
        CameraController.Instance.sceneDistance = CameraController.Instance.Distance = 9;
        CameraController.Instance.rotationX = -45;
        CameraController.Instance.rotationY = 40;
 
        float _time = 2f;
        while (_time > 0)
        {
            _time -= Time.deltaTime;
            yield return null;
        }
 
        CameraController.Instance.AcceptInput = false;
 
        CameraController.Instance.Distance = 9;
        CameraController.Instance.rotationX = -45;
        CameraController.Instance.rotationY = 40;
 
        CameraController.Instance.ZoomDamping = 0.1f;
        CameraController.Instance.RotationDamping = 0.02f;
    }
}