FxAILogicBasic.cs 9.7 KB

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