RouteManager.cs 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Controller.Bicycle;
  2. using UnityEngine;
  3. namespace Routes
  4. {
  5. public class RouteManager : MonoBehaviour
  6. {
  7. public Route[] routes;
  8. public int selectedRoute;
  9. public int visibleLength = 3;
  10. public RbBicycleController bicycle;
  11. public Logging.Base.Logging logging;
  12. public GameObject showOnFinish;
  13. private void Start()
  14. {
  15. for (var i = 0; i < routes.Length; i++)
  16. {
  17. routes[i].gameObject.SetActive(i == selectedRoute);
  18. }
  19. routes[selectedRoute].OnStartEntered += OnOnStartEntered;
  20. routes[selectedRoute].OnFinishPassed +=OnOnFinishPassed;
  21. }
  22. private void OnOnFinishPassed()
  23. {
  24. bicycle.enabled = false;
  25. Instantiate(showOnFinish, bicycle.transform);
  26. Destroy(logging.gameObject);
  27. }
  28. private void OnOnStartEntered()
  29. {
  30. logging.gameObject.SetActive(true);
  31. }
  32. }
  33. }