123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
- using CombatLibrary.CombatLibrary.CombatCore.Utility;
- using Fort23.Core;
- using Fort23.UTool;
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
- #if !COMBAT_SERVER
- using Fort23.Mono;
- using GameLogic.Combat.CombatTool;
- using UnityEngine;
- using UnityEngine.Rendering;
- using Utility;
- #endif
- namespace Fort23.Common
- {
- /// <summary>
- /// 战斗用的,其他地方不要用
- /// </summary>
- public class CombatParticleSystemPool : ParticleSystemPool
- {
- public CombatHeroEntity HeroEntity;
- public float UpdateTime;
- public int guid;
- public SpecialDotInfo targetSpecialDotInfo;
- public bool isNotRotion;
- public int activeCount;
- public int remvoeCount;
- public float UpdateFrequency = (float)0.031;
- private float _currUpdateTime;
- public CombatParticleSystemPool()
- {
- }
- #if !COMBAT_SERVER
- public void InitCombatParticleSystem()
- {
- }
- public ParticleSystemSize ParticleSystemSize
- {
- get
- {
- if (_particleSystemSize == null)
- {
- _particleSystemSize = own.GetComponent<ParticleSystemSize>();
- }
- return _particleSystemSize;
- }
- }
- private ParticleSystemSize _particleSystemSize;
- public Map<ParticleSystem, int> particleOrder = new Map<ParticleSystem, int>();
- public Map<RenderSetting, int> renderSettingOrder = new Map<RenderSetting, int>();
- private int _lastOder;
- private string _lastLayerName;
- public SortingGroup RootSortingGroup;
- public void SetRootSortingGroup(SortingGroup sortingGroup)
- {
- SetOder(sortingGroup.sortingOrder, sortingGroup.sortingLayerName);
- this.RootSortingGroup = sortingGroup;
- }
- public override void DormancyObj()
- {
- CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveCombatParticleSystemPool(this);
- if (HeroEntity != null)
- {
- HeroEntity.heroLoopParticle.Remove(this);
- }
- HeroEntity = null;
- base.DormancyObj();
- }
- public void SetOder(int oder, string layerName)
- {
- RootSortingGroup = null;
- // if (own != null)
- // {
- // ShowLayer showLayer = own.GetComponent<ShowLayer>();
- // if (showLayer != null)
- // {
- // if (showLayer.showLayerType == ShowLayer.ShowLayerType.Bottom)
- // {
- // oder = -3000;
- // }
- // else if (showLayer.showLayerType == ShowLayer.ShowLayerType.Top)
- // {
- // oder = 20000;
- // }
- // }
- // }
- _lastOder = oder;
- _lastLayerName = layerName;
- ParticleSystem[] Particles = m_particles;
- if (Particles != null)
- {
- for (int i = 0; i < Particles.Length; i++)
- {
- Renderer renderer = Particles[i].gameObject.GetComponent<Renderer>();
- if (renderer != null)
- {
- if (particleOrder.ContainsKey(Particles[i]))
- {
- renderer.sortingOrder = particleOrder[Particles[i]] + oder;
- }
- else
- {
- particleOrder.Add(Particles[i], renderer.sortingOrder);
- renderer.sortingOrder = renderer.sortingOrder + oder;
- }
- renderer.sortingLayerName = layerName;
- }
- }
- }
- if (RenderSetting != null)
- {
- for (int i = 0; i < RenderSetting.Length; i++)
- {
- RenderSetting renderSetting = RenderSetting[i];
- if (renderSettingOrder.ContainsKey(renderSetting))
- {
- renderSetting.SetOrder(renderSettingOrder[renderSetting] + oder, layerName);
- }
- else
- {
- renderSettingOrder.Add(renderSetting, renderSetting.order);
- renderSetting.SetOrder(renderSetting.order + oder, layerName);
- }
- }
- }
- }
- public void SetSize(float size)
- {
- if (ParticleSystemSize == null)
- {
- return;
- }
- own.gameObject.transform.localScale =
- Vector3.one + Vector3.one * ParticleSystemSize.cardinality * (size - 1) +
- Vector3.one * ParticleSystemSize.offValue;
- }
- protected override void ProActiveObj()
- {
- activeCount++;
- GameObjectDestroyPool.Instance.RomoveDestroyObject(own);
- base.ProActiveObj();
- }
- public override async CTask DelayHide()
- {
- if (_hideShowEndFx != null)
- {
- // TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(_hideShowEndFx.hideFxName, new Vector3(_pos), null, false,
- // null, delegate(CombatParticleSystemPool pool)
- // {
- // pool.transform.position = gameObject.transform.position;
- // pool.transform.eulerAngles = gameObject.transform.eulerAngles;
- // if (pool != null)
- // {
- // pool.SetOder(_lastOder, _lastLayerName);
- // }
- // });
- }
- await base.DelayHide();
- }
- protected override void ProDormancyObj()
- {
- base.ProDormancyObj();
- RootSortingGroup = null;
- }
- protected override void ProOnDestroy()
- {
- base.ProOnDestroy();
- }
- public int initLogicFrame { get; set; }
- public int initRenderFrame { get; set; }
- public void UnityRenderUpdate(float deltaTime)
- {
- if (transform == null)
- {
- return;
- }
- _currUpdateTime += deltaTime;
- if (_currUpdateTime < UpdateFrequency)
- {
- return;
- }
- if (targetSpecialDotInfo != null)
- {
- transform.position = targetSpecialDotInfo.targetTran.position;
- transform.eulerAngles = targetSpecialDotInfo.targetTran.eulerAngles;
- }
- deltaTime = _currUpdateTime;
- _currUpdateTime = 0;
- if (RootSortingGroup != null)
- {
- if (!RootSortingGroup.sortingLayerName.Equals(_lastLayerName) ||
- RootSortingGroup.sortingOrder != _lastOder)
- {
- SortingGroup sortingGroup = RootSortingGroup;
- SetOder(sortingGroup.sortingOrder, sortingGroup.sortingLayerName);
- RootSortingGroup = sortingGroup;
- }
- }
- UpdateTime += deltaTime;
- float speed = 1;
- Play(speed, deltaTime);
- }
- private void Play(float speed, float deltaTime)
- {
- if (Particles != null)
- {
- for (int i = 0; i < Particles.Length; i++)
- {
- if (Particles[i] == null)
- {
- continue;
- }
- ParticleSystem.MainModule mainMode = Particles[i].main;
- mainMode.simulationSpeed = speed;
- }
- }
- if (Animators != null)
- {
- for (int i = 0; i < Animators.Length; i++)
- {
- if (Animators[i] == null)
- {
- continue;
- }
- Animators[i].speed = speed;
- }
- }
- // if (ska != null)
- // {
- // for (int i = 0; i < ska.Length; i++)
- // {
- // ska[i].Update(speed * deltaTime.value);
- // }
- // }
- }
- public void UnityRenderUpdateFinish()
- {
- }
- public void CombatUpdate(float deltaTime)
- {
- UnityRenderUpdate(deltaTime);
- }
- #else
- public void CombatUpdate(float time)
- {
- UpdateTime += time;
- }
- public int initLogicFrame { get; set; }
- public int initRenderFrame { get; set; }
- public void UnityRenderUpdate(float time)
- {
-
- }
- public void UnityRenderUpdateFinish()
- {
-
- }
- #endif
- }
- }
|