1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using Pools;
- using Routes;
- using UnityEngine;
- namespace Roads
- {
- [RequireComponent(typeof(BoxCollider))]
- public class StraightRoadExtras : MonoBehaviour, IRoad
- {
- public GameObject arcPrefab;
- private GameObject arc;
- private bool hasArc;
- public TriggerState ArcState { get; private set; } = TriggerState.Outside;
-
- public float SlopeDeg { get; private set; }
- public float MinY { get; private set; }
- private void Start()
- {
- SlopeDeg = transform.localRotation.eulerAngles.z;
- MinY = GetComponent<BoxCollider>().bounds.center.y;
- }
- public void ShowArc()
- {
- arc = Instantiate(arcPrefab, transform);
- hasArc = arc != null;
- }
- private void OnTriggerEnter(Collider other)
- {
- if (hasArc && other.CompareTag("bike"))
- {
- ArcState = TriggerState.Inside;
- }
- }
- private void OnTriggerExit(Collider other)
- {
- if (hasArc && other.CompareTag("bike"))
- {
- Destroy(arc);
- ArcState = TriggerState.Outside;
- }
- }
- }
- }
|