FxAILogicBasic.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System;
  2. using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
  3. using Fort23.Common;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Combat.CombatTool;
  7. #if !COMBAT_SERVER
  8. using UnityEngine;
  9. #endif
  10. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  11. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;
  12. namespace Common.Combat.FxAILogic
  13. {
  14. public abstract class FxAILogicBasic : MonoBehaviour, IDisposable, ITimelineFxLogic
  15. {
  16. private TimeLineEventParticleLogicBasic _timeLineEventParticleLogicBasic;
  17. private ILifetCycleHitPoint _attTarget;
  18. public ILifetCycleHitPoint AttTarget
  19. {
  20. get { return _attTarget; }
  21. }
  22. public CombatHeroEntity CombatHeroEntity
  23. {
  24. get { return _combatHeroEntity; }
  25. }
  26. private CombatHeroEntity _combatHeroEntity;
  27. public TimeLineEventParticleLogicBasic TimeLineEventParticleLogicBasic
  28. {
  29. get { return _timeLineEventParticleLogicBasic; }
  30. }
  31. public IGObjectPoolInterface ObjectPoolInterface;
  32. public bool isPenetrate;
  33. /// <summary>
  34. /// 开始点
  35. /// </summary>
  36. protected Vector3 startPos;
  37. public Vector3 CurrPos
  38. {
  39. get { return _currPos; }
  40. }
  41. /// <summary>
  42. /// 当前Obj的位置
  43. /// </summary>
  44. protected Vector3 _currPos;
  45. protected Vector3 rotation;
  46. protected SpecialDotInfo specialDotInfo;
  47. protected float currTime;
  48. public TriggerData triggerData;
  49. protected bool isNotCanTriggerGround;
  50. protected bool _isUpdateBasic;
  51. public void Init(Vector3 startPos,
  52. TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic, ILifetCycleHitPoint attTarget,
  53. SpecialDotInfo specialDotInfo = null)
  54. {
  55. _currPos = startPos;
  56. this.startPos = startPos;
  57. this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic;
  58. this._attTarget = attTarget;
  59. _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This<CombatHeroEntity>();
  60. this.specialDotInfo = specialDotInfo;
  61. ITimeLineTriggerEvent trigger =
  62. timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  63. if (trigger != null)
  64. {
  65. trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this,
  66. triggerData);
  67. }
  68. triggerData = timeLineEventParticleLogicBasic.extraData;
  69. triggerData.TrggerObject = this;
  70. _isUpdateBasic = true;
  71. ProInit();
  72. }
  73. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  74. {
  75. this.ObjectPoolInterface = poolInterface;
  76. }
  77. // private void Detection()
  78. // {
  79. // if (_updateCount % 2 != 0)
  80. // {
  81. // return;
  82. // }
  83. //
  84. // ProDetection();
  85. // }
  86. //
  87. // protected virtual void ProDetection()
  88. // {
  89. // }
  90. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  91. SpecialDotInfo targetSpecialDotInfo)
  92. {
  93. if (string.IsNullOrEmpty(fxName))
  94. {
  95. return;
  96. }
  97. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  98. isRotate,
  99. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  100. {
  101. #if !COMBAT_SERVER
  102. // if (ObjectPoolInterface != null&&pool.own!=null)
  103. // {
  104. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  105. // if (colorAlter != null)
  106. // {
  107. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  108. // if (colorAlter2 == null)
  109. // {
  110. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  111. // }
  112. //
  113. // colorAlter2.AlterColor(colorAlter.currValue);
  114. // }
  115. // }
  116. #endif
  117. });
  118. }
  119. public void CombatUpdate(float time)
  120. {
  121. if (!_isUpdateBasic)
  122. {
  123. return;
  124. }
  125. ProCombatUpdate(time);
  126. if (_timeLineEventParticleLogicBasic == null)
  127. {
  128. return;
  129. }
  130. // Detection();
  131. UnityRenderUpdate(time);
  132. }
  133. public void UnityRenderUpdate(float time)
  134. {
  135. ProUnityRenderUpdate(time);
  136. }
  137. public void Dispose()
  138. {
  139. if (_timeLineEventParticleLogicBasic == null)
  140. {
  141. return;
  142. }
  143. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  144. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  145. ProDispose();
  146. // timeLineEventParticleLogicBasic?.Dispose();
  147. ObjectPoolInterface = null;
  148. _timeLineEventParticleLogicBasic = null;
  149. _attTarget = null;
  150. ObjectPoolInterface = null;
  151. // _fxAiDataBasic = null;
  152. _isUpdateBasic = false;
  153. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  154. // CombatFactoryTool.Instance.Recycle(scName, this);
  155. }
  156. protected virtual void ProInit()
  157. {
  158. }
  159. protected virtual void ProCombatUpdate(float time)
  160. {
  161. }
  162. protected virtual void ProUnityRenderUpdate(float time)
  163. {
  164. }
  165. protected virtual void ProDispose()
  166. {
  167. }
  168. }
  169. }