| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 | using System.Collections;using System.Collections.Generic;using Common.Utility.CombatTimer;using Fort23.Core;#if !COMBAT_SERVERusing Fort23.Core;#endifusing Fort23.UTool;using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;#if !COMBAT_SERVERusing UnityEngine;#endifnamespace UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic{    public class TimeLineEventParticleLogicBasic : TimeLineEventLogicBasic    {        // private Timer timer;        private BetterList<Clock> loadTask = new BetterList<Clock>();        // private BetterList<string> long = new BetterList<Clock>();        public BetterList<ParticleSystemPool> loopFx = new BetterList<ParticleSystemPool>();        public BetterList<ParticleSystemPool> _allLoadFx = new BetterList<ParticleSystemPool>();        public BetterList<ILifetCycleHitPoint> _loopTarget = new BetterList<ILifetCycleHitPoint>();        private CombatTimer _combatTimer;        private int _loadCount;        public TimeLinePlayFxSerializtion timeLinePlayFxSerializtion        {            get { return mTimeLineAssetSerialization as TimeLinePlayFxSerializtion; }        }        protected override void ProDormancyObj()        {            loopFx.Clear();            _allLoadFx.Clear();            _loopTarget.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<ILifetCycleHitPoint> 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++)            {                for (int j = 0; j < _loopTarget.Count; j++)                {                    _loopTarget[j].RemoveLoopFx(pool[i]);                }                GObjectPool.Instance.Recycle(pool[i]);            }            _loopTarget.Clear();            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();            _loopTarget.Clear();        }        private void ExecuteFxTarget(BetterList<ILifetCycleHitPoint> 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<ILifetCycleHitPoint>(true);                        break;                    case FXLocationType.Target:                        fxTarget = lifeCycle;                        break;                    case FXLocationType.CustomTarget:                        fxTarget = lifeCycle;                        break;                    case FXLocationType.SceneZero:                        fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(false);                        startPos = TimeLineEventLogicGroup.SceneWorldPos();                        break;                    case FXLocationType.OneselfSpecialDot:                        fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(false);                        break;                    case FXLocationType.TargetSpecialDot:                        fxTarget = lifeCycle;                        break;                }                if (fxTarget != null)                {                    if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.hitPointGroupName))                    {                        ILifetCycleHitPoint newHitPoint =                            fxTarget.IfLifeCycle.GetILifetCycleHitPoint<ILifetCycleHitPoint>(                                timeLinePlayFxSerializtion.hitPointGroupName, true, true);                        targetSpecialDotInfo =                            newHitPoint.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName);                    }                    else                    {                        targetSpecialDotInfo =                            fxTarget.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName);                    }                }                if (timeLinePlayFxSerializtion.isUseRandom)                {                    if (targetSpecialDotInfo != null)                    {                        startPos = targetSpecialDotInfo.GetWorlPos();                    }                    float x = timeLinePlayFxSerializtion.GetRandom(timeLinePlayFxSerializtion.xoff.x,                        timeLinePlayFxSerializtion.xoff.y);                    float y = timeLinePlayFxSerializtion.GetRandom(timeLinePlayFxSerializtion.yoff.x,                        timeLinePlayFxSerializtion.yoff.y);                    float z = timeLinePlayFxSerializtion.GetRandom(timeLinePlayFxSerializtion.zoff.x,                        timeLinePlayFxSerializtion.zoff.y);                    startPos += new Vector3(x, y, z);                    targetSpecialDotInfo = null;                }                else 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);                }                if (timeLinePlayFxSerializtion.isLoop && timeLinePlayFxSerializtion.loopAlone)                {                    if (fxTarget != null)                    {                        bool isFix = fxTarget.IsLoopFx(timeLinePlayFxSerializtion.fxName);                        if (isFix)                        {                            index++;                            ExecuteFxTarget(combatTarget, index);                            return;                        }                    }                }                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);            for (int i = 0; i < _loopTarget.Count; i++)            {                _loopTarget[i].RemoveLoopFx(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.fxName = timeLinePlayFxSerializtion.fxName;                            pool.OnEndFx = ParticleSystemPoolEndFx;                            if (timeLinePlayFxSerializtion.isLoop)                            {                                loopFx.Add(pool);                                if (fxTarget != null)                                {                                    _loopTarget.Add(fxTarget);                                    fxTarget.AddLoopFx(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 (timeLinePlayFxSerializtion.isRoat)                            {                                pool.own.transform.eulerAngles = customizePos[timeLinePlayFxSerializtion.roatIndex];                            }                        }                    });                if (clock != null)                {                    loadTask.Add(clock);                }            }        }    }}
 |