Route.cs 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using Roads;
  4. using UnityEditor;
  5. using UnityEngine;
  6. using UnityEngine.Rendering;
  7. namespace Routes
  8. {
  9. [Serializable]
  10. public struct RouteItem
  11. {
  12. [SerializeReference]
  13. public Turn turn;
  14. public RoadDirection from;
  15. public RoadDirection to;
  16. public void Apply()
  17. {
  18. turn.comingFrom = from;
  19. turn.goingTo = to;
  20. }
  21. public void Clear()
  22. {
  23. turn.comingFrom = RoadDirection.None;
  24. turn.goingTo = RoadDirection.None;
  25. }
  26. }
  27. public class Route : MonoBehaviour
  28. {
  29. public List<RouteItem> items;
  30. public void Clear()
  31. {
  32. items.ForEach(i => i.Clear());
  33. }
  34. public void Show()
  35. {
  36. items.ForEach(i => i.Apply());
  37. }
  38. }
  39. }