using UnityEngine; using System.Collections.Generic; using Snxxz.UI; public class FoTransmit : FlyObject { private int m_Index; private SoFoTransmit m_FoTransMit; private float m_ShowTime; private List m_CacheAllEffect = new List(); 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 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; int _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 = (int)(_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.PlayBattleEffect(m_FoTransMit.ammoEffectId, _fight); if (_sfx) { _sfx.duration = m_FoTransMit.eachLastTime; FoTransmitController _controller = _sfx.AddMissingComponent(); _controller.start = _start; _controller.end = _end; _controller.transmit = _sfx; _controller.enabled = true; _sfx.m_OnFinished += OnSFXDisable; m_CacheAllEffect.Add(_sfx); } //Debug.LogFormat("播放特效: 开始: {0}, 结束: {1}", _start, _end); } } 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(); 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; } private void RecycleAllEffect() { for (int i = m_CacheAllEffect.Count - 1; i >= 0; --i) { if (m_CacheAllEffect[i] != null) { FoTransmitController _controller = m_CacheAllEffect[i].GetComponent(); if (_controller) { _controller.enabled = false; } SFXPlayUtility.Instance.Release(m_CacheAllEffect[i]); } } m_CacheAllEffect.Clear(); } }