using System.Collections; using System.Collections.Generic; using Common.Utility.CombatTimer; using Fort23.Core; #if !COMBAT_SERVER using Fort23.Core; #endif using Fort23.UTool; using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface; #if !COMBAT_SERVER using UnityEngine; #endif namespace UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic { public class TimeLineEventParticleLogicBasic : TimeLineEventLogicBasic { // private Timer timer; private BetterList loadTask = new BetterList(); // private BetterList long = new BetterList(); public BetterList loopFx = new BetterList(); public BetterList _allLoadFx = new BetterList(); private CombatTimer _combatTimer; private int _loadCount; public TimeLinePlayFxSerializtion timeLinePlayFxSerializtion { get { return mTimeLineAssetSerialization as TimeLinePlayFxSerializtion; } } protected override void ProDormancyObj() { loopFx.Clear(); _allLoadFx.Clear(); loadTask.Clear(); CombatTimerManager.Instance.RemoveTimer(_combatTimer); _combatTimer = null; } protected override void ProSetCombatInfo() { } protected override void ProEnter() { // ITimeLineTriggerEvent trigger = _targetEntity as ITimeLineTriggerEvent; // if (trigger != null) { BetterList timeLineEntities = GetSkillTarget(); ExecuteFxTarget(timeLineEntities, 0); } } protected override void ProLeave() { } protected override void ProTimeUpdate() { } protected override void ProBreakTimeLine() { for (int i = 0; i < loadTask.Count; i++) { loadTask[i].Dispose(); } CombatTimerManager.Instance.RemoveTimer(_combatTimer); _combatTimer = null; CloseLoopFx(); loadTask.Clear(); } public override bool IsFinish() { return _allLoadFx.Count <= 0 && _loadCount <= 0; } public void CloseLoopFx() { if (loopFx.Count <= 0) { return; } ParticleSystemPool[] pool = loopFx.ToArray(); for (int i = 0; i < pool.Length; i++) { GObjectPool.Instance.Recycle(pool[i]); } loopFx.Clear(); } public void CloseAllFx() { if (_allLoadFx.Count <= 0) { return; } ParticleSystemPool[] pool = _allLoadFx.ToArray(); for (int i = 0; i < pool.Length; i++) { GObjectPool.Instance.Recycle(pool[i]); } _allLoadFx.Clear(); } protected override void ProDispose() { for (int i = 0; i < loadTask.Count; i++) { loadTask[i].Dispose(); } CombatTimerManager.Instance.RemoveTimer(_combatTimer); _combatTimer = null; loadTask.Clear(); if (currTarget != null) { currTarget.Dispose(); } currTarget = null; CloseAllFx(); loopFx.Clear(); _allLoadFx.Clear(); } private void ExecuteFxTarget(BetterList combatTarget, int index) { if (combatTarget.Count <= index) { return; } ILifetCycleHitPoint lifeCycle = combatTarget[index]; if (lifeCycle == null) { // LogTool.Log("一个空的目标"); index++; ExecuteFxTarget(combatTarget, index); return; } if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.fxName)) { ILifetCycleHitPoint fxTarget = null; Vector3 startPos = Vector3.one; SpecialDotInfo targetSpecialDotInfo = null; switch (timeLinePlayFxSerializtion.locationType) { case FXLocationType.Oneself: fxTarget = _castEntity.GetMainHotPoin(true); break; case FXLocationType.Target: fxTarget = lifeCycle; break; case FXLocationType.CustomTarget: fxTarget = lifeCycle; break; case FXLocationType.SceneZero: fxTarget = _castEntity.GetMainHotPoin(false); startPos = TimeLineEventLogicGroup.SceneWorldPos(); break; case FXLocationType.OneselfSpecialDot: fxTarget = _castEntity.GetMainHotPoin(false); break; case FXLocationType.TargetSpecialDot: fxTarget = lifeCycle; break; } if (fxTarget != null) { if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.hitPointGroupName)) { ILifetCycleHitPoint newHitPoint = fxTarget.IfLifeCycle.GetILifetCycleHitPoint( timeLinePlayFxSerializtion.hitPointGroupName, true, true); targetSpecialDotInfo = newHitPoint.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName); } else { targetSpecialDotInfo = fxTarget.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName); } } if (timeLinePlayFxSerializtion.isActivityCustomTargetPos && customizePos != null && customizePos.Length > timeLinePlayFxSerializtion.CustomTargetPosIndex) { startPos = customizePos[timeLinePlayFxSerializtion.CustomTargetPosIndex]; targetSpecialDotInfo = null; } else if (targetSpecialDotInfo != null && timeLinePlayFxSerializtion.locationType != FXLocationType.SceneZero) { startPos = targetSpecialDotInfo.GetWorlPos(); } if (timeLinePlayFxSerializtion.isGround) { startPos = new Vector3(startPos.x, (float)0.7f); } LoadFx(lifeCycle, fxTarget, startPos, targetSpecialDotInfo); } index++; if (timeLinePlayFxSerializtion.intervalTime > 0) { _combatTimer = CombatTimerManager.Instance.AddTimer( (float)timeLinePlayFxSerializtion.intervalTime * index, delegate { }); ExecuteFxTarget(combatTarget, index); } else { ExecuteFxTarget(combatTarget, index); } } protected void ParticleSystemPoolEndFx(ParticleSystemPool particleSystemPool) { loopFx.Remove(particleSystemPool); _allLoadFx.Remove(particleSystemPool); } protected void LoadFx(ILifetCycleHitPoint effectTarget, ILifetCycleHitPoint fxTarget, Vector3 startPos, SpecialDotInfo targetSpecialDotInfo) { ITimeLineParticleFactory iTimeLineParticleFactory = TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory; if (iTimeLineParticleFactory != null) { _loadCount++; Clock clock = iTimeLineParticleFactory.CreateParticle(this, effectTarget, fxTarget, startPos, targetSpecialDotInfo, delegate(IGObjectPoolInterface systemPool) { _loadCount--; ParticleSystemPool pool = systemPool as ParticleSystemPool; if (pool != null) { if (IsDis) { GObjectPool.Instance.Recycle(pool); return; } pool.OnEndFx = ParticleSystemPoolEndFx; if (timeLinePlayFxSerializtion.isLoop) { loopFx.Add(pool); } _allLoadFx.Add(pool); if (timeLinePlayFxSerializtion.isAttSpeed) { ITimeLineParticlePlaySpeed timeLineParticlePlaySpeed = _castEntity as ITimeLineParticlePlaySpeed; #if !COMBAT_SERVER pool.palySpeed = timeLineParticlePlaySpeed.GetCurrPlaySpeed(timeLinePlayFxSerializtion); #endif } else { #if !COMBAT_SERVER pool.palySpeed = (float)1; #endif } _timeLineEventLogicGroup.OnInitParticleSystemPoolCallBack?.Invoke(pool); } }); if (clock != null) { loadTask.Add(clock); } } } } }