StraightRoadExtras.cs 836 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using Pools;
  3. using Routes;
  4. using UnityEngine;
  5. namespace Roads
  6. {
  7. public class StraightRoadExtras : MonoBehaviour
  8. {
  9. public GameObject arcPrefab;
  10. private GameObject arc;
  11. private bool hasArc;
  12. public TriggerState ArcState { get; private set; } = TriggerState.Outside;
  13. public void ShowArc()
  14. {
  15. arc = Instantiate(arcPrefab, transform);
  16. hasArc = arc != null;
  17. }
  18. private void OnTriggerEnter(Collider other)
  19. {
  20. if (hasArc && other.CompareTag("bike"))
  21. {
  22. ArcState = TriggerState.Inside;
  23. }
  24. }
  25. private void OnTriggerExit(Collider other)
  26. {
  27. if (hasArc && other.CompareTag("bike"))
  28. {
  29. Destroy(arc);
  30. ArcState = TriggerState.Outside;
  31. }
  32. }
  33. }
  34. }