TrafficSystem.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Traffic Simulation
  2. // https://github.com/mchrbn/unity-traffic-simulation
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace TrafficSimulation {
  6. public class TrafficSystem : MonoBehaviour {
  7. public bool hideGuizmos = false;
  8. public float segDetectThresh = 0.1f;
  9. public ArrowDraw arrowDrawType = ArrowDraw.ByLength;
  10. public int arrowCount = 1;
  11. public float arrowDistance = 5;
  12. public float arrowSizeWaypoint = 1;
  13. public float arrowSizeIntersection = 0.5f;
  14. public float waypointSize = 0.5f;
  15. public string[] collisionLayers;
  16. public List<Segment> segments = new List<Segment>();
  17. public List<Intersection> intersections = new List<Intersection>();
  18. public Segment curSegment = null;
  19. public List<Waypoint> GetAllWaypoints() {
  20. List<Waypoint> points = new List<Waypoint>();
  21. foreach (Segment segment in segments) {
  22. points.AddRange(segment.waypoints);
  23. }
  24. return points;
  25. }
  26. public void SaveTrafficSystem(){
  27. Intersection[] its = GameObject.FindObjectsOfType<Intersection>();
  28. foreach(Intersection it in its)
  29. it.SaveIntersectionStatus();
  30. }
  31. public void ResumeTrafficSystem(){
  32. Intersection[] its = GameObject.FindObjectsOfType<Intersection>();
  33. foreach(Intersection it in its)
  34. it.ResumeIntersectionStatus();
  35. }
  36. }
  37. public enum ArrowDraw {
  38. FixedCount, ByLength, Off
  39. }
  40. }