少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 f1f2599ba0e6b64358ffef7ae5c9f9af3ed8b8b4
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
 
public class CreateRoleBehaviour : MonoBehaviour
{
    [SerializeField] int m_Job;
    [SerializeField] float m_Scale = 1;
    [SerializeField] EnterPictureType m_EnterPictureType;
 
    [SerializeField] ShowAnimation m_RoutimeShowAnimation;
 
    [SerializeField] Effect[] m_PersistentEffect;
    [SerializeField] Effect[] m_RoutimeShowEffect;
 
    [SerializeField] CreateRoleHeroPlatform m_Platform;
    [SerializeField] ActorShadowCaster m_Shadow;
 
    CreateRoleTimeLine showTimeLine = new CreateRoleTimeLine();
 
    public State state { get; private set; }
 
    List<SFXController> sfxControllers = new List<SFXController>();
 
    public void DoRoutineShow()
    {
        m_Shadow.gameObject.SetActive(false);
        m_Platform.transform.localEulerAngles = new Vector3(0, 180, 0);
        m_Platform.ForbidSeconds(m_RoutimeShowAnimation.delay + m_RoutimeShowAnimation.duration);
        CreateRoleManager.Instance.LoadModel(m_Job, (bool ok, UnityEngine.Object @object) =>
        {
            if (ok)
            {
                var model = @object as GameObject;
                model.transform.SetParentEx(m_Platform.transform, Vector3.zero, Quaternion.identity, Vector3.one * m_Scale);
 
                switch (m_EnterPictureType)
                {
                    case EnterPictureType.OutIn:
                        model.SetActive(false);
                        break;
                    case EnterPictureType.Stand:
                        model.SetActive(true);
                        m_Shadow.gameObject.SetActive(true);
                        m_Shadow.Cast(model.transform);
                        break;
                }
 
                ReleaseEffects();
                state = State.RoutimeShow;
 
                showTimeLine.ClearNode();
                showTimeLine.AddNone(m_RoutimeShowAnimation.delay, () =>
                {
                    if (m_EnterPictureType == EnterPictureType.OutIn)
                    {
                        model.SetActive(true);
                    }
 
                    var animator = model.GetComponent<Animator>();
                    animator.Play(m_RoutimeShowAnimation.animation);
                });
 
                showTimeLine.AddNone(m_RoutimeShowAnimation.delay+0.1f, () =>
                {
                    if (m_EnterPictureType == EnterPictureType.OutIn)
                    {
                        m_Shadow.gameObject.SetActive(true);
                        m_Shadow.Cast(model.transform);
                    }
                });
 
                foreach (var effect in m_PersistentEffect)
                {
                    showTimeLine.AddNone(effect.delay, () =>
                    {
                        PlayEffect(model.transform, effect);
                    });
                }
 
                foreach (var effect in m_RoutimeShowEffect)
                {
                    showTimeLine.AddNone(effect.delay, () =>
                    {
                        PlayEffect(model.transform, effect);
                    });
                }
 
                showTimeLine.AddNone(2f, () =>
                {
                    WindowCenter.Instance.Open<CreateRoleWin>();
                });
 
                showTimeLine.OnComplete(() => { state = State.Idle; });
                showTimeLine.Begin();
            }
        });
    }
 
    public void Dispose()
    {
        showTimeLine.Dispose();
        ReleaseEffects();
    }
 
    private void PlayEffect(Transform model, Effect effect)
    {
        var config = EffectConfig.Get(effect.id);
        Transform parent = null;
        if (!string.IsNullOrEmpty(config.nodeName))
        {
            parent = model.transform.GetChildTransformDeeply(config.nodeName);
        }
        else
        {
            parent = model.transform;
        }
 
        sfxControllers.Add(SFXPlayUtility.Instance.Play(effect.id, parent));
    }
 
    public void ReleaseEffects()
    {
        for (var i = sfxControllers.Count - 1; i >= 0; i--)
        {
            SFXPlayUtility.Instance.Release(sfxControllers[i]);
        }
 
        sfxControllers.Clear();
    }
 
    [System.Serializable]
    public struct ShowAnimation
    {
        public string animation;
        public float delay;
        public float duration;
    }
 
    [System.Serializable]
    public struct Effect
    {
        public int id;
        public float delay;
    }
 
    public enum EnterPictureType
    {
        Stand,
        OutIn,
    }
 
    public enum State
    {
        Idle,
        EnterShow,
        RoutimeShow,
    }
 
}