BesselPathGroup.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace Core.Utility
  4. {
  5. public class BesselPathGroup
  6. {
  7. public float lane;
  8. public List<BesselPath> allBesselPath = new List<BesselPath>();
  9. public void AddBesselPath(BesselPath besselPath)
  10. {
  11. allBesselPath.Add(besselPath);
  12. }
  13. public void Start()
  14. {
  15. lane = 0;
  16. for (int i = 0; i < allBesselPath.Count; i++)
  17. {
  18. BesselPath besselPath = allBesselPath[i];
  19. besselPath.SetLengthAtT();
  20. lane += besselPath.allDis;
  21. }
  22. }
  23. public Vector3 CalculatePoint(float t)
  24. {
  25. // BesselPath currBeselPath = null;
  26. float currLane = 0;
  27. for (int i = 0; i < allBesselPath.Count; i++)
  28. {
  29. BesselPath besselPath = allBesselPath[i];
  30. float allLane = currLane;
  31. allLane += besselPath.allDis;
  32. float b = allLane / lane;
  33. if (t <= b)
  34. {
  35. float lasetB = currLane / lane;
  36. b -= lasetB;
  37. t -= lasetB;
  38. float currB = t / b;
  39. return besselPath.CalculatePoint(currB);
  40. }
  41. currLane = allLane;
  42. }
  43. return Vector3.zero;
  44. }
  45. }
  46. }