FxAILogicBasic.cs 6.7 KB

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