FxAILogicBasic.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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.Hero;
  9. using GameLogic.Combat.Skill;
  10. #if !COMBAT_SERVER
  11. using UnityEngine;
  12. #endif
  13. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  14. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;
  15. namespace Common.Combat.FxAILogic
  16. {
  17. public abstract class FxAILogicBasic : MonoBehaviour, IDisposable, ITimelineFxLogic, ITriggerEntity
  18. {
  19. [Header("移动的根节点,默认是root")] public GameObject moveTarget;
  20. private TimeLineEventParticleLogicBasic _timeLineEventParticleLogicBasic;
  21. private ILifetCycleHitPoint _attTarget;
  22. public SkillFeaturesData SkillFeaturesData;
  23. [Header("延迟时间发射")] public float delayTime;
  24. [Header("多目标时延迟")] public float multipleTargetDelayTime;
  25. [Header("碰撞时的特效")] public string hitFxName;
  26. [Header("碰撞音效")] public string hitAudioName;
  27. [Header("对碰时播放的特效")] public string pengZhuangHitFxName;
  28. public BarrierTriggerData BarrierTriggerData;
  29. /// <summary>
  30. /// 额外移动速度 <0 减速 >0加速
  31. /// </summary>
  32. [HideInInspector] public float extraMoveSpeed;
  33. /// <summary>
  34. /// 不能移动
  35. /// </summary>
  36. public bool isNotMove;
  37. public ILifetCycleHitPoint AttTarget
  38. {
  39. get { return _attTarget; }
  40. }
  41. public CombatHeroEntity CombatHeroEntity
  42. {
  43. get { return _combatHeroEntity; }
  44. }
  45. private CombatHeroEntity _combatHeroEntity;
  46. public TimeLineEventParticleLogicBasic TimeLineEventParticleLogicBasic
  47. {
  48. get { return _timeLineEventParticleLogicBasic; }
  49. }
  50. public IGObjectPoolInterface ObjectPoolInterface;
  51. [Header("是否可以穿透")] public bool isPenetrate;
  52. [Header("是否使用自定义目标结束点")] public bool isUseCustomTargetEndPos;
  53. [Header("结束点的下标")] public int customTargetEndPosIndex;
  54. /// <summary>
  55. /// 开始点
  56. /// </summary>
  57. protected Vector3 startPos;
  58. public float size = 1;
  59. public Vector3 CurrPos
  60. {
  61. get { return _currPos; }
  62. }
  63. /// <summary>
  64. /// 当前Obj的位置
  65. /// </summary>
  66. protected Vector3 _currPos;
  67. protected Vector3 rotation;
  68. protected SpecialDotInfo specialDotInfo;
  69. protected float currTime;
  70. public TriggerData triggerData;
  71. protected bool isNotCanTriggerGround;
  72. protected bool _isUpdateBasic;
  73. private float _currDelayTime;
  74. private float _currAllDelayTime;
  75. public bool isInit = false;
  76. public void Init(Vector3 startPos,
  77. TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic, ILifetCycleHitPoint attTarget,
  78. SpecialDotInfo specialDotInfo = null)
  79. {
  80. if (timeLineEventParticleLogicBasic.castEntity == null)
  81. {
  82. Dispose();
  83. return;
  84. }
  85. if (moveTarget == null)
  86. {
  87. moveTarget = ObjectPoolInterface.own;
  88. }
  89. ObjectPoolInterface.own.SetActive(false);
  90. BarrierTriggerData = new BarrierTriggerData();
  91. isNotMove = false;
  92. extraMoveSpeed = 0;
  93. size = 1;
  94. _currAllDelayTime = delayTime + timeLineEventParticleLogicBasic.indexCount * multipleTargetDelayTime;
  95. _currDelayTime = 0;
  96. _currPos = startPos;
  97. this.startPos = startPos;
  98. this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic;
  99. this._attTarget = attTarget;
  100. _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This<CombatHeroEntity>();
  101. this.specialDotInfo = specialDotInfo;
  102. ITimeLineTriggerEvent trigger =
  103. timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  104. if (trigger != null)
  105. {
  106. trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this,
  107. triggerData);
  108. SkillBasic skillBasic = trigger as SkillBasic;
  109. SkillFeaturesData = skillBasic.GetSkillFeaturesData();
  110. SkillFeaturesData.FxAILogicBasic = this;
  111. }
  112. triggerData = timeLineEventParticleLogicBasic.extraData;
  113. triggerData.TrggerObject = this;
  114. currTime = 0;
  115. _isUpdateBasic = true;
  116. ObjectPoolInterface.own.transform.localScale = Vector3.one * size;
  117. ProInit();
  118. isInit = true;
  119. ObjectPoolInterface.own.SetActive(true);
  120. }
  121. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  122. {
  123. this.ObjectPoolInterface = poolInterface;
  124. }
  125. /// <summary>
  126. /// 扣除技能强度
  127. /// </summary>
  128. public void DeductSkillStrength(long hp)
  129. {
  130. }
  131. // private void Detection()
  132. // {
  133. // if (_updateCount % 2 != 0)
  134. // {
  135. // return;
  136. // }
  137. //
  138. // ProDetection();
  139. // }
  140. //
  141. // protected virtual void ProDetection()
  142. // {
  143. // }
  144. public void PlayHit()
  145. {
  146. FinishHit(CurrPos, hitFxName);
  147. }
  148. public void PlayPengZhuangHit()
  149. {
  150. FinishHit(CurrPos, pengZhuangHitFxName);
  151. }
  152. protected void FinishHit(Vector3 pos, string hitFxName)
  153. {
  154. if (!string.IsNullOrEmpty(hitFxName))
  155. {
  156. CombatController.currActiveCombat.GameTimeLineParticleFactory.CreateParticle(hitFxName,
  157. pos, null, false, null, null);
  158. }
  159. }
  160. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  161. SpecialDotInfo targetSpecialDotInfo)
  162. {
  163. if (string.IsNullOrEmpty(fxName))
  164. {
  165. return;
  166. }
  167. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  168. isRotate,
  169. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  170. {
  171. #if !COMBAT_SERVER
  172. // if (ObjectPoolInterface != null&&pool.own!=null)
  173. // {
  174. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  175. // if (colorAlter != null)
  176. // {
  177. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  178. // if (colorAlter2 == null)
  179. // {
  180. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  181. // }
  182. //
  183. // colorAlter2.AlterColor(colorAlter.currValue);
  184. // }
  185. // }
  186. #endif
  187. });
  188. }
  189. public virtual void CombatUpdate(float time)
  190. {
  191. if (!_isUpdateBasic)
  192. {
  193. return;
  194. }
  195. _currDelayTime += time;
  196. if (_currDelayTime < _currAllDelayTime)
  197. {
  198. return;
  199. }
  200. ProCombatUpdate(time);
  201. if (_timeLineEventParticleLogicBasic == null)
  202. {
  203. return;
  204. }
  205. // Detection();
  206. UnityRenderUpdate(time);
  207. }
  208. public void UnityRenderUpdate(float time)
  209. {
  210. ProUnityRenderUpdate(time);
  211. }
  212. public void Dispose()
  213. {
  214. if (_timeLineEventParticleLogicBasic == null)
  215. {
  216. return;
  217. }
  218. isInit = false;
  219. isNotMove = false;
  220. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  221. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  222. ProDispose();
  223. // timeLineEventParticleLogicBasic?.Dispose();
  224. ObjectPoolInterface = null;
  225. _timeLineEventParticleLogicBasic = null;
  226. _attTarget = null;
  227. ObjectPoolInterface = null;
  228. // _fxAiDataBasic = null;
  229. _isUpdateBasic = false;
  230. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  231. // CombatFactoryTool.Instance.Recycle(scName, this);
  232. }
  233. protected virtual void ProInit()
  234. {
  235. }
  236. protected virtual void ProCombatUpdate(float time)
  237. {
  238. }
  239. protected virtual void ProUnityRenderUpdate(float time)
  240. {
  241. }
  242. protected virtual void ProDispose()
  243. {
  244. }
  245. }
  246. }