123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Common.Combat.FxAILogic;
- using Fort23.Common;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.Hero;
- using UnityEngine;
- using UnityEngine.Rendering;
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;
- public class GameTimeLineParticleFactory : ITimeLineParticleFactory
- {
- protected List<CombatParticleSystemPool> allCombatParticleSystem =
- new List<CombatParticleSystemPool>();
- protected List<FxAILogicBasic> allFxAiLogicBasic = new List<FxAILogicBasic>();
- protected bool _isUpdateState;
- private List<FxAILogicBasic> _removeFxAiLogicBasic = new List<FxAILogicBasic>();
- public void RemoveFxAILogicBasic(FxAILogicBasic fxAILogicBasic)
- {
- if (_isUpdateState)
- {
- _removeFxAiLogicBasic.Add(fxAILogicBasic);
- }
- else
- {
- allFxAiLogicBasic.Remove(fxAILogicBasic);
- }
- }
- public void CombatUpdate(float time)
- {
- _isUpdateState = true;
- for (int i = 0; i < allFxAiLogicBasic.Count; i++)
- {
- allFxAiLogicBasic[i].CombatUpdate(time);
- }
- _isUpdateState = false;
- for (int i = 0; i < _removeFxAiLogicBasic.Count; i++)
- {
- allFxAiLogicBasic.Remove(_removeFxAiLogicBasic[i]);
- }
- _removeFxAiLogicBasic.Clear();
- for (int i = 0; i < allCombatParticleSystem.Count; i++)
- {
- allCombatParticleSystem[i].CombatUpdate(time);
- }
- }
- public void Dispose()
- {
- allFxAiLogicBasic.Clear();
- }
- public void RecycleFix()
- {
- #if !COMBAT_SERVER
- CombatParticleSystemPool[] pools = allCombatParticleSystem.ToArray();
- if (pools != null)
- {
- List<CombatParticleSystemPool> romvePoll = new List<CombatParticleSystemPool>();
- romvePoll.AddRange(pools);
- for (int i = 0; i < romvePoll.Count; i++)
- {
- if (pools[i] == null)
- {
- continue;
- }
- if (pools[i].gameObject != null)
- {
- pools[i].gameObject.SetActive(false);
- GObjectPool.Instance.Recycle(pools[i]);
- }
- }
- }
- #endif
- allCombatParticleSystem.Clear();
- }
- public void RemoveCombatParticleSystemPool(CombatParticleSystemPool combatParticleSystemPool)
- {
- allCombatParticleSystem.Remove(combatParticleSystemPool);
- }
- public Clock CreateParticle(TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic,
- ILifetCycleHitPoint effectTarget,
- ILifetCycleHitPoint fxTarget, Vector3 startPos, SpecialDotInfo targetSpecialDotInfo,
- Action<IGObjectPoolInterface> callBack)
- {
- Clock clock = CreateParticle(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.fxName, startPos,
- fxTarget,
- false, targetSpecialDotInfo, delegate(ParticleSystemPool combatParticleSystemPool)
- {
- CombatParticleSystemPool pool = combatParticleSystemPool as CombatParticleSystemPool;
- #if !COMBAT_SERVER
- pool.InitCombatParticleSystem();
- #endif
- CombatHeroEntity combatHeroEntity = null;
- if (targetSpecialDotInfo != null)
- {
- combatHeroEntity = targetSpecialDotInfo.heroEntity as CombatHeroEntity;
- // if (!timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isActivityCustomTargetPos)
- // {
- // startPos = targetSpecialDotInfo.GetWorlPos();
- // }
- if (!timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isNotRotate)
- {
- pool.transform.eulerAngles = targetSpecialDotInfo.GetEulerAngles();
- pool.isNotRotion = false;
- }
- else
- {
- pool.isNotRotion = true;
- }
- // if (heroEntity != null)
- // {
- // pool.transform.SetParent(heroEntity.CombatHeroTransform.iGObjectPoolInterface.own.transform);
- // }
- // else
- // {
- // pool.transform.SetParent(targetSpecialDotInfo.targetTran);
- // }
- }
- if (combatHeroEntity != null && timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isLoop)
- {
- combatHeroEntity.heroLoopParticle.Add(pool);
- pool.HeroEntity = combatHeroEntity;
- }
- pool.gameObject.SetActive(false);
- pool.transform.position = startPos;
- if (timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isFollowRootTarget &&
- timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.locationType !=
- FXLocationType.SceneZero)
- {
- if (combatHeroEntity != null)
- {
- pool.transform.SetParent(combatHeroEntity.GetMainHotPoin<CombatHeroHitPoint>()
- .GetSpecialDotInfo("").targetTran);
- }
- pool.transform.localEulerAngles = Vector3.zero;
- }
- else if (timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isFollowTarget &&
- timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.locationType !=
- FXLocationType.SceneZero)
- {
- pool.transform.localEulerAngles = Vector3.zero;
- pool.targetSpecialDotInfo = targetSpecialDotInfo;
- }
- else
- {
- // pool.transform.SetParent(null);
- pool.targetSpecialDotInfo = null;
- }
- FxAILogicBasic fxAILogicBasic = pool.own.GetComponent<FxAILogicBasic>();
- if (fxAILogicBasic != null)
- {
- if (!allFxAiLogicBasic.Contains(fxAILogicBasic))
- {
- allFxAiLogicBasic.Add(fxAILogicBasic);
- }
- fxAILogicBasic.SetAIMonoObj(combatParticleSystemPool);
- fxAILogicBasic.Init(startPos, timeLineEventParticleLogicBasic, effectTarget,
- targetSpecialDotInfo);
- }
- #if !COMBAT_SERVER
- pool.gameObject.SetActive(true);
- #endif
- callBack?.Invoke(combatParticleSystemPool);
- });
- return clock;
- }
- public Clock CreateParticle(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
- SpecialDotInfo targetSpecialDotInfo, Action<ParticleSystemPool> callBack)
- {
- #if !COMBAT_SERVER
- Clock clock = ClockPool.GetClock();
- CTask<CombatParticleSystemPool> task = GObjectPool.Instance.FetchAsync(fxName + ".prefab",
- delegate(CombatParticleSystemPool pool)
- {
- if (pool == null)
- {
- return;
- }
- // if (!isActive)
- // {
- // GObjectPool.Instance.RecycleForDestroy(pool);
- // return;
- // }
- if (!allCombatParticleSystem.Contains(pool))
- {
- allCombatParticleSystem.Add(pool);
- }
- else
- {
- LogTool.Error("添加重复");
- }
- //
- // if (targetSpecialDotInfo != null && targetSpecialDotInfo.rootTrnsform != null)
- // {
- // SortingGroup sortingGroup = targetSpecialDotInfo.rootTrnsform.GetSortingGroup();
- // if (sortingGroup != null)
- // {
- // pool.SetRootSortingGroup(sortingGroup);
- // }
- // else
- // {
- // pool.SetOder(0, "Hero");
- // }
- // }
- // else
- // {
- // pool.SetOder(10000, "Hero");
- // }
- if (isRotate && fxTarget != null)
- {
- SpecialDotInfo specialDotInfo = fxTarget.GetSpecialDotInfo(null);
- if (specialDotInfo != null)
- {
- pool.transform.eulerAngles = specialDotInfo.GetEulerAngles();
- }
- }
- float size = 1;
- // if (fxTarget != null)
- // {
- // CombatHeroEntity combatHeroEntity = fxTarget.IfLifeCycle.This<CombatHeroEntity>();
- // if (combatHeroEntity != null)
- // {
- // HeroGameObjectConfig heroGameObjectConfig =
- // combatHeroEntity.HeroGameObjectConfig;
- // if (heroGameObjectConfig != null)
- // {
- // size = heroGameObjectConfig.size;
- // }
- // }
- // }
- pool.SetSize(size);
- pool.own.transform.position = startPos;
- callBack?.Invoke(pool);
- }, clock);
- return clock;
- #else
- callBack?.Invoke(new CombatParticleSystemPool());
- return null;
- #endif
- }
- }
|