FxAIBeelineBulletLogic.cs 2.5 KB

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