123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Controller.Bicycle;
- using UnityEngine;
- namespace Routes
- {
- public class RouteManager : MonoBehaviour
- {
- public Route[] routes;
- public int selectedRoute;
- public int visibleLength = 3;
- public RbBicycleController bicycle;
- public Logging.Base.Logging logging;
- public GameObject showOnFinish;
- private GameObject bicycleGameObject;
- private void Start()
- {
- for (var i = 0; i < routes.Length; i++)
- {
- routes[i].gameObject.SetActive(i == selectedRoute);
- }
- routes[selectedRoute].OnStartEntered += OnOnStartEntered;
- routes[selectedRoute].OnFinishPassed += OnOnFinishPassed;
- var startTransform = routes[selectedRoute].start.gameObject.transform;
- var startRotationEuler = startTransform.rotation.eulerAngles;
- bicycleGameObject = bicycle.gameObject;
- bicycleGameObject.transform.SetPositionAndRotation(
- startTransform.position + startTransform.right * 12,
- Quaternion.Euler(startRotationEuler + new Vector3(0, -90, 0)));
- }
- private void OnOnFinishPassed()
- {
- //bicycle.enabled = false;
- Instantiate(showOnFinish, bicycle.transform);
- Destroy(logging.gameObject);
- }
- private void OnOnStartEntered()
- {
- logging.gameObject.SetActive(true);
- }
- }
- }
|