RbBicycleSlopeSpeedManager.cs 944 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using Controller.Bicycle;
  3. using UnityEngine;
  4. using Wheels;
  5. namespace Phscs
  6. {
  7. [RequireComponent(typeof(RbBicycleController))]
  8. public class RbBicycleSlopeSpeedManager : MonoBehaviour
  9. {
  10. [Header("Game Objects")] public LerpSlopeCollider slopeCollider;
  11. [Header("Linear Adjustment")] [Range(0, 3)]
  12. public float speedFactorUphill;
  13. [Range(0, 3)] public float speedFactorDownhill;
  14. private BikeSpeedBooster speedBooster;
  15. public float GradientDeg { get; private set; }
  16. private void Start()
  17. {
  18. speedBooster = BikeSpeedBooster.Instance;
  19. slopeCollider.OnSlopeChanged += (timestamp, slope) =>
  20. {
  21. speedBooster.OnSlopeChanged(timestamp, slope);
  22. GradientDeg = slope;
  23. };
  24. }
  25. private void FixedUpdate()
  26. {
  27. speedBooster.OnFixedUpdate();
  28. }
  29. }
  30. }