少年修仙传客户端代码仓库
hch
2 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class UI3DHeroSkillShow : MonoBehaviour
    {
        static UI3DHeroSkillShow m_Instance = null;
        public static UI3DHeroSkillShow Instance {
            get {
                if (m_Instance == null)
                {
                    var gameObject = Instantiate(UILoader.LoadTreasure("Misc", "UI3DHeroSkillShow"));
                    m_Instance = gameObject.GetComponent<UI3DHeroSkillShow>();
                    Instance.transform.position = new Vector3(0, 4000, 5000);
                    m_Instance.name = "UI3DHeroSkillShow";
                    m_Instance.SetActive(true);
                    DontDestroyOnLoad(gameObject);
                }
 
                return m_Instance;
            }
        }
 
        [SerializeField] Transform m_Stage;
        [SerializeField] Camera m_ShowCamera;
        [SerializeField] Animator m_CameraAnimator;
        [SerializeField] List<RuntimeAnimatorController> m_HeroShowControllers;
        [SerializeField] List<TreasureSkill> m_TreasureSkills;
        [SerializeField] List<SkillAct> m_SkillActs;
 
        UI3DShowHero m_HeroShow = new UI3DShowHero();
 
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        Transform m_HeroPoint;
        public Transform hero {
            get {
                return m_HeroPoint;
            }
        }
 
        Animator m_HeroAnimator;
 
        Action m_HeroSkillCompletet;
 
        SFXController m_SkillExtraSfx;
 
        public int cacheSkillId { get; private set; }
 
        public Camera showCamera { get { return m_ShowCamera; } }
 
        public SFXController skillEffect;
 
        public Transform MP_Name1 {
            get {
                var mp_name = hero.GetChildTransformDeeply("A_Name2");
                if (!mp_name)
                {
                    return hero;
                }
                return mp_name;
            }
        }
 
        public Transform MP_Weapon {
            get {
                var mp_weapon = hero.GetChildTransformDeeply(WEAPON_NODE);
                if (mp_weapon != null)
                {
                    if (mp_weapon.childCount > 0)
                    {
                        return mp_weapon.GetChild(0);
                    }
                    return mp_weapon;
                }
                return hero;
            }
        }
 
        const string WEAPON_NODE = "Bip001 Prop1";
 
 
        private void ShowHeroSkill(int _skillId, string _clip)
        {
            if (UI3DTreasureSelectStage.Instance.IsOpen)
            {
                UI3DTreasureSelectStage.Instance.showCamera.enabled = false;
            }
 
            cacheSkillId = _skillId;
 
            var _job = PlayerDatas.Instance.baseData.Job;
 
            #region 装备
            var appearance = ModelCenter.Instance.GetModel<EquipModel>().GetAppearance();
 
            var _clothesId = appearance.clothes;
            var _wingsId = appearance.wings;
            var _secondaryId = appearance.secondary;
            var _weaponId = appearance.weapon;
            var fashionClothesId = appearance.fashionClothes;
            var fashionWeaponId = appearance.fashionWeapon;
            var fashionSecondaryId = appearance.fashionSecondary;
 
            int _suitLevel = 0;
            #endregion
 
            UI3DPlayerExhibitionData data = new UI3DPlayerExhibitionData()
            {
                job = _job,
                fashionClothesId = fashionClothesId,
                clothesId = _clothesId,
                suitLevel = _suitLevel,
                fashionWeaponId = fashionWeaponId,
                weaponId = _weaponId,
                wingsId = _wingsId,
                fashionSecondaryId = fashionSecondaryId,
                secondaryId = _secondaryId,
                isDialogue = false,
            };
 
            var _hero = m_HeroShow.Show(data, m_Stage);
            if (_hero != null)
            {
                m_HeroPoint = _hero.transform;
                m_HeroAnimator = _hero.GetComponent<Animator>();
                if (m_HeroAnimator != null)
                {
                    m_HeroAnimator.runtimeAnimatorController = m_HeroShowControllers[_job - 1];
                    StartCoroutine(Co_PlaySkill());
                }
            }
 
            m_Stage.localEulerAngles = Vector3.zero;
            m_ShowCamera.SetActive(true);
 
            m_CameraAnimator.Play(_clip, 0, 0);
            m_CameraAnimator.speed = 0;
        }
 
        public void ShowTreasureSkill(int _treasureId, Action callback)
        {
            StopShow();
 
            Treasure _treasure;
            ModelCenter.Instance.GetModel<TreasureModel>().TryGetTreasure(_treasureId, out _treasure);
            if (_treasure != null)
            {
                m_HeroSkillCompletet = callback;
                var _skillId = _treasure.skillId;
                var _index = m_TreasureSkills.FindIndex((x) =>
                {
                    return x.treasureId == _treasureId;
                });
                var _treasureSkill = _index != -1 ? m_TreasureSkills[_index] : m_TreasureSkills[0];
                _index = _treasureSkill.clip.FindIndex((x) =>
                {
                    return (int)x.job == PlayerDatas.Instance.baseData.Job;
                });
                var _clip = _index != -1 ? _treasureSkill.clip[_index] : _treasureSkill.clip[0];
                ShowHeroSkill(_skillId, _clip.clip);
                if (_treasureSkill.effects != null && _treasureSkill.effects.Count > 0)
                {
                    _index = _treasureSkill.effects.FindIndex((x) =>
                    {
                        return (int)x.job == PlayerDatas.Instance.baseData.Job;
                    });
                    var _effect = _index != -1 ? _treasureSkill.effects[_index] : _treasureSkill.effects[0];
                    StartCoroutine(Co_PlayExtraEffect(_effect));
                }
            }
        }
 
        private void StartPlaySkill(int _skillId)
        {
            var config = SkillConfig.Get(_skillId);
            if (config == null)
            {
                return;
            }
            var skillActMark = config.Skillactmark;
 
            var index = m_SkillActs.FindIndex((x) =>
            {
                return x.skillId == _skillId;
            });
 
            if (index != -1)
            {
                skillActMark = m_SkillActs[index].mark;
            }
 
            if (skillActMark > 0 && skillActMark < 20)
            {
                switch (config.Skillactmark)
                {
                    case 10:
                        m_HeroAnimator.Play(GAStaticDefine.State_Attack1Hash, 0);
                        break;
                    case 11:
                        m_HeroAnimator.Play(GAStaticDefine.State_Attack2Hash, 0);
                        break;
                    case 12:
                        m_HeroAnimator.Play(GAStaticDefine.State_Attack3Hash, 0);
                        break;
                    case 13:
                        m_HeroAnimator.Play(GAStaticDefine.State_Attack4Hash, 0);
                        break;
                }
            }
            else
            {
                switch (skillActMark)
                {
                    case 21:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill21, 0);
                        break;
                    case 22:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill22, 0);
                        break;
                    case 23:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill23, 0);
                        break;
                    case 24:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill24, 0);
                        break;
                    case 25:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill25, 0);
                        break;
                    case 26:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill26, 0);
                        break;
                    case 27:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill27, 0);
                        break;
                    case 28:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill28, 0);
                        break;
                    case 29:
                        m_HeroAnimator.Play(GAStaticDefine.State_Skill29, 0);
                        break;
                    case 99:
                        m_HeroAnimator.Play(GAStaticDefine.State_RollHash, 0);
                        break;
                }
            }
 
 
        }
 
        IEnumerator Co_PlaySkill()
        {
            yield return WaitingForSecondConst.WaitMS1000;
            if (m_HeroAnimator != null)
            {
                StartPlaySkill(cacheSkillId);
            }
 
            m_CameraAnimator.speed = 1;
            yield return null;
            var _showTime = m_CameraAnimator.GetCurrentAnimatorStateInfo(0).length;
            yield return new WaitForSeconds(_showTime);
            if (m_HeroSkillCompletet != null)
            {
                m_HeroSkillCompletet();
            }
            StopShow();
        }
 
        IEnumerator Co_PlayExtraEffect(Effect effect)
        {
            yield return new WaitForSeconds(effect.startTime);
            if (m_SkillExtraSfx != null)
            {
                SFXPlayUtility.Instance.Release(m_SkillExtraSfx);
                m_SkillExtraSfx = null;
            }
            var parent = hero;
            if (!string.IsNullOrEmpty(effect.parentName) && hero != null)
            {
                parent = hero.GetChildTransformDeeply(effect.parentName, true);
            }
            m_SkillExtraSfx = SFXPlayUtility.Instance.Play(effect.id, parent);
            if (m_SkillExtraSfx != null)
            {
                m_SkillExtraSfx.duration = effect.duration;
                m_SkillExtraSfx.transform.localPosition = effect.position;
            }
        }
 
        public void StopShow()
        {
            if (UI3DTreasureSelectStage.Instance.IsOpen)
            {
                UI3DTreasureSelectStage.Instance.showCamera.enabled = true;
            }
            m_ShowCamera.SetActive(false);
            m_HeroSkillCompletet = null;
            m_HeroShow.Dispose();
            if (m_SkillExtraSfx != null)
            {
                SFXPlayUtility.Instance.Release(m_SkillExtraSfx);
                m_SkillExtraSfx = null;
            }
 
            if (skillEffect != null)
            {
                SFXPlayUtility.Instance.Release(skillEffect);
                skillEffect = null;
            }
        }
 
        [Serializable]
        public struct CameraClip
        {
            public PlayerJob job;
            public string clip;
        }
 
        [Serializable]
        public struct Effect
        {
            public PlayerJob job;
            public int id;
            public float startTime;
            public float duration;
            public string parentName;
            public Vector3 position;
        }
 
        [Serializable]
        public struct TreasureSkill
        {
            public int treasureId;
            public List<CameraClip> clip;
            public List<Effect> effects;
        }
 
        [Serializable]
        public struct SkillAct
        {
            public int skillId;
            public int mark;
        }
 
        public enum PlayerJob
        {
            Qiang = 1,
            Fashi,
        }
    }
}