IEnumerator CheckStartingRoute() { while (true) { if (TrackCircuits.Any(t => t.HasCarPresence && t != TargetTrack)) { break; } yield return(null); } if (!IsShunting) { RouteLights [0].IsClosedByTrain = true; TrafficLightOff(); //for all trains passing through RouteLights [0].Trigger.enabled = false; } else { //if shunting comp goes behind closed signal and go back RouteLights [1].Trigger.enabled = false; } // enter route AllTCInUseOn(); Unit.IsInUse = true; EventManager.PathChanged(); StartCoroutine(CheckPassingRoute()); }
public void InstantiateRoute( ) { TargetTrack = TrackCircuits.Last(); SetAllSwitchesStraight(); SetAllSwitchesTurn(); AllTCInRouteOn(); TrafficLightOn(); StartCoroutine(CheckStartingRoute()); }
public bool CheckTrainRoute() { if (TrackCircuits.All(t => !t.IsInRoute && !t.HasCarPresence)) { print("Checked - Not Danger"); return(true); } else { print("Checked - Danger"); return(false); } }
IEnumerator CheckPassingRoute() { StopCoroutine(CheckStartingRoute()); while (TrackCircuits.Any(t => t != TargetTrack && t.HasCarPresence)) { yield return(new WaitForSeconds(0.5f)); } if (!IsShunting) { RouteLights [0].Trigger.enabled = true; RouteLights [0].IsClosedByTrain = false; } else { RouteLights [1].Trigger.enabled = true; } Unit.IsInUse = false; Route.Instance.DestroyRoute(RouteNumber); }