RouteManager.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 GameObject bicycleGameObject;
  14. private void Start()
  15. {
  16. for (var i = 0; i < routes.Length; i++)
  17. {
  18. routes[i].gameObject.SetActive(i == selectedRoute);
  19. }
  20. routes[selectedRoute].OnStartEntered += OnOnStartEntered;
  21. routes[selectedRoute].OnFinishPassed += OnOnFinishPassed;
  22. var startTransform = routes[selectedRoute].start.gameObject.transform;
  23. var startRotationEuler = startTransform.rotation.eulerAngles;
  24. bicycleGameObject = bicycle.gameObject;
  25. bicycleGameObject.transform.SetPositionAndRotation(
  26. startTransform.position + startTransform.right * 12,
  27. Quaternion.Euler(startRotationEuler + new Vector3(0, -90, 0)));
  28. }
  29. private void OnOnFinishPassed()
  30. {
  31. //bicycle.enabled = false;
  32. Instantiate(showOnFinish, bicycle.transform);
  33. Destroy(logging.gameObject);
  34. }
  35. private void OnOnStartEntered()
  36. {
  37. logging.gameObject.SetActive(true);
  38. }
  39. }
  40. }