StraightLineShow.cs 2.5 KB

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