FxAILogicBasic.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 float delayTime;
  22. [Header("多目标时延迟")] public float multipleTargetDelayTime;
  23. [Header("碰撞时的特效")] public string hitFxName;
  24. [Header("碰撞音效")] public string hitAudioName;
  25. public ILifetCycleHitPoint AttTarget
  26. {
  27. get { return _attTarget; }
  28. }
  29. public CombatHeroEntity CombatHeroEntity
  30. {
  31. get { return _combatHeroEntity; }
  32. }
  33. private CombatHeroEntity _combatHeroEntity;
  34. public TimeLineEventParticleLogicBasic TimeLineEventParticleLogicBasic
  35. {
  36. get { return _timeLineEventParticleLogicBasic; }
  37. }
  38. public IGObjectPoolInterface ObjectPoolInterface;
  39. public bool isPenetrate;
  40. [Header("是否使用自定义目标结束点")] public bool isUseCustomTargetEndPos;
  41. [Header("结束点的下标")] public int customTargetEndPosIndex;
  42. /// <summary>
  43. /// 开始点
  44. /// </summary>
  45. protected Vector3 startPos;
  46. public float size=1;
  47. public Vector3 CurrPos
  48. {
  49. get { return _currPos; }
  50. }
  51. /// <summary>
  52. /// 当前Obj的位置
  53. /// </summary>
  54. protected Vector3 _currPos;
  55. protected Vector3 rotation;
  56. protected SpecialDotInfo specialDotInfo;
  57. protected float currTime;
  58. public TriggerData triggerData;
  59. protected bool isNotCanTriggerGround;
  60. protected bool _isUpdateBasic;
  61. private float _currDelayTime;
  62. private float _currAllDelayTime;
  63. public void Init(Vector3 startPos,
  64. TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic, ILifetCycleHitPoint attTarget,
  65. SpecialDotInfo specialDotInfo = null)
  66. {
  67. if (timeLineEventParticleLogicBasic.castEntity == null)
  68. {
  69. Dispose();
  70. return;
  71. }
  72. size = 1;
  73. _currAllDelayTime= delayTime+timeLineEventParticleLogicBasic.indexCount*multipleTargetDelayTime;
  74. _currDelayTime = 0;
  75. _currPos = startPos;
  76. this.startPos = startPos;
  77. this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic;
  78. this._attTarget = attTarget;
  79. _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This<CombatHeroEntity>();
  80. this.specialDotInfo = specialDotInfo;
  81. ITimeLineTriggerEvent trigger =
  82. timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  83. if (trigger != null)
  84. {
  85. trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this,
  86. triggerData);
  87. SkillBasic skillBasic = trigger as SkillBasic;
  88. SkillFeaturesData = skillBasic.GetSkillFeaturesData();
  89. }
  90. triggerData = timeLineEventParticleLogicBasic.extraData;
  91. triggerData.TrggerObject = this;
  92. currTime = 0;
  93. _isUpdateBasic = true;
  94. ObjectPoolInterface.own.transform.localScale = Vector3.one * size;
  95. ProInit();
  96. }
  97. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  98. {
  99. this.ObjectPoolInterface = poolInterface;
  100. }
  101. // private void Detection()
  102. // {
  103. // if (_updateCount % 2 != 0)
  104. // {
  105. // return;
  106. // }
  107. //
  108. // ProDetection();
  109. // }
  110. //
  111. // protected virtual void ProDetection()
  112. // {
  113. // }
  114. public void PlayHit()
  115. {
  116. FinishHit(CurrPos,hitFxName);
  117. }
  118. protected void FinishHit(Vector3 pos, string hitFxName)
  119. {
  120. if (!string.IsNullOrEmpty(hitFxName))
  121. {
  122. CombatController.currActiveCombat.GameTimeLineParticleFactory.CreateParticle(hitFxName,
  123. pos, null, false, null, null);
  124. }
  125. }
  126. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  127. SpecialDotInfo targetSpecialDotInfo)
  128. {
  129. if (string.IsNullOrEmpty(fxName))
  130. {
  131. return;
  132. }
  133. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  134. isRotate,
  135. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  136. {
  137. #if !COMBAT_SERVER
  138. // if (ObjectPoolInterface != null&&pool.own!=null)
  139. // {
  140. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  141. // if (colorAlter != null)
  142. // {
  143. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  144. // if (colorAlter2 == null)
  145. // {
  146. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  147. // }
  148. //
  149. // colorAlter2.AlterColor(colorAlter.currValue);
  150. // }
  151. // }
  152. #endif
  153. });
  154. }
  155. public void CombatUpdate(float time)
  156. {
  157. if (!_isUpdateBasic)
  158. {
  159. return;
  160. }
  161. _currDelayTime+=time;
  162. if (_currDelayTime < _currAllDelayTime)
  163. {
  164. return;
  165. }
  166. ProCombatUpdate(time);
  167. if (_timeLineEventParticleLogicBasic == null)
  168. {
  169. return;
  170. }
  171. // Detection();
  172. UnityRenderUpdate(time);
  173. }
  174. public void UnityRenderUpdate(float time)
  175. {
  176. ProUnityRenderUpdate(time);
  177. }
  178. public void Dispose()
  179. {
  180. if (_timeLineEventParticleLogicBasic == null)
  181. {
  182. return;
  183. }
  184. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  185. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  186. ProDispose();
  187. // timeLineEventParticleLogicBasic?.Dispose();
  188. ObjectPoolInterface = null;
  189. _timeLineEventParticleLogicBasic = null;
  190. _attTarget = null;
  191. ObjectPoolInterface = null;
  192. // _fxAiDataBasic = null;
  193. _isUpdateBasic = false;
  194. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  195. // CombatFactoryTool.Instance.Recycle(scName, this);
  196. }
  197. protected virtual void ProInit()
  198. {
  199. }
  200. protected virtual void ProCombatUpdate(float time)
  201. {
  202. }
  203. protected virtual void ProUnityRenderUpdate(float time)
  204. {
  205. }
  206. protected virtual void ProDispose()
  207. {
  208. }
  209. }
  210. }