少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using UnityEngine;
using System.Collections.Generic;
using vnxbqy.UI;
 
public class FoTransmit : FlyObject
{
    private int m_Index;
    private SoFoTransmit m_FoTransMit;
 
    private float m_ShowTime;
    private List<SFXController> m_CacheAllEffect = new List<SFXController>();
    private float m_LastTime;
 
    public override bool Initialize(InitInfo initInfo)
    {
        bool _result = base.Initialize(initInfo);
 
        RecycleAllEffect();
 
        m_FoTransMit = m_Config as SoFoTransmit;
 
        if (m_FoTransMit == null)
        {
            return false;
        }
 
        m_ShowTime = 0;
        m_Index = 0;
        m_LastTime = Time.time;
 
        return _result;
    }
 
    protected sealed override void PlayEffect() { }
 
    protected sealed override void OnUpdate()
    {
        if (IsOver())
        {
            return;
        }
 
        if (Time.time - m_ShowTime > m_FoTransMit.nextStartInterval)
        {
            m_ShowTime = Time.time;
            GActor _target1 = null;
            GActor _target2 = null;
            Transform _start = null;
            Transform _end = null;
            ulong _hurtTotalValue = 0;
 
            GActorFight _fight = GAMgr.Instance.GetBySID(m_InitInfo.casterServerObjID) as GActorFight;
            float _floodPercent = m_FoTransMit.floodPercent * Constants.F_DELTA;
 
            if (_fight != null)
            {
                if (m_Index < m_HurtClientList.Count)
                {
                    _hurtTotalValue = (ulong)(_floodPercent * m_HurtClientList[m_Index].HurtHP);
 
                    if (m_Index == 0)
                    {
 
                        if (string.IsNullOrEmpty(m_FoTransMit.shootNode))
                        {
                            _start = _fight.MP_Hit;
                        }
                        else
                        {
                            Transform _shootTransform = _fight.Root.GetChildTransformDeeply(m_FoTransMit.shootNode);
                            if (_shootTransform)
                            {
                                _start = _shootTransform;
                            }
                            else
                            {
                                _start = _fight.MP_Hit;
                            }
                        }
 
                        _target2 = GAMgr.Instance.GetByCID(m_HurtClientList[m_Index].clientInstID);
 
                        if (_target2 != null)
                        {
                            _end = _target2.MP_Hit;
                        }
 
                        // Debug.LogFormat("开始对象: {0}, 结束对象: {1}", _hero.ClientInstId, _target2.ClientInstId);
 
                    }
                    else
                    {
                        if (m_Index <= m_HurtClientList.Count - 1)
                        {
                            _target1 = GAMgr.Instance.GetByCID(m_HurtClientList[m_Index - 1].clientInstID);
                            _target2 = GAMgr.Instance.GetByCID(m_HurtClientList[m_Index].clientInstID);
 
                            if (_target1 != null)
                            {
                                _start = _target1.MP_Hit;
                            }
                            if (_target2 != null)
                            {
                                _end = _target2.MP_Hit;
                            }
 
                            // Debug.LogFormat("开始对象: {0}, 结束对象: {1}", _target1.ClientInstId, _target2.ClientInstId);
                        }
                    }
 
                    if (m_FoTransMit.ammoEffectId > 0)
                    {
                        if (BattleEffectPlayRule.Instance.CanPlay(m_InitInfo.casterServerObjID))
                        {
                            SFXController _sfx = SFXPlayUtility.Instance.PlayEffectAsync(m_FoTransMit.ammoEffectId, _fight);
                            if (_sfx)
                            {
                                _sfx.duration = m_FoTransMit.eachLastTime;
                                FoTransmitController _controller = _sfx.AddMissingComponent<FoTransmitController>();
                                _controller.start = _start;
                                _controller.end = _end;
                                _controller.transmit = _sfx;
                                _controller.enabled = true;
                                _sfx.m_OnFinished += OnSFXDisable;
 
                                if (_start)
                                {
                                    _sfx.transform.position = _start.position;
                                }
                                if (_end)
                                {
                                    _sfx.transform.LookAt(_end.position);
                                }
                                if (_start && _end)
                                {
                                    _sfx.transform.localScale = new Vector3(1, 1, Vector3.Distance(_end.position, _start.position));
                                }
 
                                m_CacheAllEffect.Add(_sfx);
                            }
                            //Debug.LogFormat("播放特效 {2} : 开始: {0}, 结束: {1}", _start, _end, m_FoTransMit.ammoEffectId);
                        }
                    }
 
                    if (_target2 != null)
                    {
 
                        if (_hurtTotalValue != 0)
                        {
                            GAStaticDefine.PopHp(PlayerDatas.Instance.hero, _target2, m_HurtClientList[m_Index].AttackType, _hurtTotalValue);
                        }
                    }
 
                    m_Index += 1;
                    //Debug.LogFormat("索引: {0}, 总共: {1}", m_Index, _hurtList.Length);
                }
            }
        }
    }
 
    private void OnSFXDisable(SFXController _controller)
    {
        _controller.m_OnFinished -= OnSFXDisable;
        FoTransmitController _tc = _controller.GetComponent<FoTransmitController>();
        if (_tc)
        {
            _tc.enabled = false;
        }
    }
    protected sealed override void MovingHitted()
    {
    }
    public sealed override bool IsOver()
    {
        return m_HurtClientList == null
            || m_Index > m_HurtClientList.Count - 1
            || GA_Hero.s_MapSwitching;
    }
 
    private void RecycleAllEffect()
    {
        for (int i = m_CacheAllEffect.Count - 1; i >= 0; --i)
        {
            if (m_CacheAllEffect[i] != null)
            {
                FoTransmitController _controller = m_CacheAllEffect[i].GetComponent<FoTransmitController>();
                if (_controller)
                {
                    _controller.enabled = false;
                }
                SFXPlayUtility.Instance.Release(m_CacheAllEffect[i]);
            }
        }
        m_CacheAllEffect.Clear();
    }
 
}