StraightLineShow.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Common.Utility.CombatEvent;
  2. using Core.Utility;
  3. using Fort23.Core;
  4. using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
  5. using UnityEngine;
  6. using Utility.CTween;
  7. namespace GameLogic.Combat.Skill.MagicSkill
  8. {
  9. public class StraightLineShow : MagicAttShowBasic
  10. {
  11. private BesselPath _besselPath;
  12. private float allTime;
  13. private float speed = 15;
  14. private float addTime;
  15. protected override void ProSetInfo()
  16. {
  17. _besselPath = CObjectPool.Instance.Fetch<BesselPath>();
  18. _skillBasic.CombatHeroEntity.GameObject.transform.eulerAngles = Vector3.zero;
  19. Vector3 p1 =
  20. _skillBasic.CombatHeroEntity.GameObject.transform.TransformPoint(new Vector3(-5f, 5f, 5f));
  21. Vector3 p2 = SetTargetPos2();
  22. _besselPath.controlPoints.Add(_skillBasic.CombatHeroEntity.GameObject.transform.position);
  23. _besselPath.controlPoints.Add(p1);
  24. _besselPath.controlPoints.Add(p2);
  25. _besselPath.controlPoints.Add(target.dotPos);
  26. float d = _besselPath.GetLengthAtT(allTime);
  27. addTime = 1.0f / (d / speed);
  28. allTime = 0;
  29. }
  30. protected Vector3 SetTargetPos2()
  31. {
  32. Vector3 p2 = target.GameObject.transform.TransformPoint(new Vector3(-5f, 1f, 5f));
  33. return p2;
  34. }
  35. protected override void ProUpdate(float t)
  36. {
  37. Vector3 p2 = SetTargetPos2();
  38. _besselPath.controlPoints[2] = p2;
  39. _besselPath.controlPoints[3] = target.dotPos;
  40. allTime += t * addTime;
  41. float v = CustomTweenManager.AnimationCurveLibrary.fabaoAtt.Evaluate(allTime);
  42. Vector3 lasetPos = _besselPath.CalculatePoint(v - 0.01f);
  43. Vector3 p = _besselPath.CalculatePoint(v);
  44. _skillBasic.CombatHeroEntity.combatHeroGameObject.SetPosition(p);
  45. Quaternion quaternion = Quaternion.LookRotation((p - lasetPos).normalized);
  46. _skillBasic.CombatHeroEntity.GameObject.transform.rotation =
  47. Quaternion.Lerp(_skillBasic.CombatHeroEntity.GameObject.transform.rotation, quaternion, 0.5f);
  48. if (allTime >= 1)
  49. {
  50. isUpdate = false;
  51. callBack?.Invoke();
  52. }
  53. }
  54. }
  55. }