diff --git a/Assets/Scripts/Config.cs b/Assets/Scripts/Config.cs index 2ec9709..f764b52 100644 --- a/Assets/Scripts/Config.cs +++ b/Assets/Scripts/Config.cs @@ -14,6 +14,7 @@ public float totalTravelTime = 0f; public int totalCars = 0; public RoadNetwork roadNetwork = new RoadNetwork(); + public TrafficLights trafficLights; public void click(Mode mode, int index) { onClick(); diff --git a/Assets/Scripts/Config.cs b/Assets/Scripts/Config.cs index 2ec9709..f764b52 100644 --- a/Assets/Scripts/Config.cs +++ b/Assets/Scripts/Config.cs @@ -14,6 +14,7 @@ public float totalTravelTime = 0f; public int totalCars = 0; public RoadNetwork roadNetwork = new RoadNetwork(); + public TrafficLights trafficLights; public void click(Mode mode, int index) { onClick(); diff --git a/Assets/Scripts/Roads/Roads.cs b/Assets/Scripts/Roads/Roads.cs index 983c56a..1c60c10 100644 --- a/Assets/Scripts/Roads/Roads.cs +++ b/Assets/Scripts/Roads/Roads.cs @@ -97,12 +97,18 @@ } drawMode = DrawMode.DragRoad; customNode.lightPhase++; + customNode.isPassable = customNode.lightPhase == 0 || + customNode.lightPhase == config.trafficLights.lightPhase && + config.trafficLights.mode == TrafficLightMode.Green; } else if (Input.GetAxis("Fire2") != 0.0f) { if (drawMode == DrawMode.DragRoad) { return; } - customNode.lightPhase--; drawMode = DrawMode.DragRoad; + customNode.lightPhase--; + customNode.isPassable = customNode.lightPhase == 0 || + customNode.lightPhase == config.trafficLights.lightPhase && + config.trafficLights.mode == TrafficLightMode.Green; } else { drawMode = DrawMode.None; }