FxAIBeelineBulletLogic.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using Core.Triiger;
  3. using GameLogic.Combat.Hero;
  4. using UnityEngine;
  5. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  6. namespace Common.Combat.FxAILogic
  7. {
  8. public class FxAIBeelineBulletLogic : FxAILogicBasic
  9. {
  10. public float speed;
  11. private IUnRegister UnRegister = null;
  12. private Vector3 endPos;
  13. private Vector3 dir;
  14. protected override void ProInit()
  15. {
  16. UnRegister = gameObject.OnTriggerEnterEvent(OnTriggerEnterEvent);
  17. endPos = AttTarget.GetSpecialDotInfo("hitpos").GetWorlPos();
  18. dir = (endPos - CurrPos).normalized;
  19. gameObject.transform.rotation = Quaternion.LookRotation(dir);
  20. }
  21. protected void OnTriggerEnterEvent(Collider collision)
  22. {
  23. HeroEntityMono heroEntityMono = collision.gameObject.GetComponent<HeroEntityMono>();
  24. if (heroEntityMono == null)
  25. {
  26. return;
  27. }
  28. CombatHeroEntity target = heroEntityMono.combatHeroEntity;
  29. if (target.IsEnemy == CombatHeroEntity.IsEnemy)
  30. {
  31. return;
  32. }
  33. ITimeLineTriggerEvent timeLineTriggerEvent =
  34. TimeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  35. if (timeLineTriggerEvent != null)
  36. {
  37. timeLineTriggerEvent.TimeLineTrigger(TimeLineEventParticleLogicBasic.TimeLineEventLogicGroup.groupName,
  38. target.GetMainHotPoin<ILifetCycleHitPoint>(), this, triggerData);
  39. Dispose();
  40. }
  41. }
  42. protected override void ProCombatUpdate(float time)
  43. {
  44. Vector3 lastPos = _currPos;
  45. Vector3 movePos = dir * speed * time;
  46. _currPos += movePos;
  47. gameObject.transform.position = _currPos;
  48. if (Vector3.SqrMagnitude(_currPos - startPos) > 100)
  49. {
  50. Dispose();
  51. }
  52. }
  53. protected override void ProDispose()
  54. {
  55. if (UnRegister != null)
  56. {
  57. UnRegister.UnRegister();
  58. }
  59. UnRegister = null;
  60. }
  61. }
  62. }