private void setUpcomingTrafficLight(long currTargetId, long prevTargetId) { if (TrafficLightIndex.TrafficLightsForPos.ContainsKey(currTargetId)) { upcomingTrafficLight = TrafficLightIndex.TrafficLightsForPos[currTargetId].Find(trafficLight => trafficLight.getOtherPos().Id == prevTargetId); } }
private static TrafficLightLogic GetTrafficLightById(string id) { TrafficLightLogic trafficLight = null; foreach (TrafficLightLogic light in TrafficLights) { if (light.Id == id) { trafficLight = light; break; } } return(trafficLight); }
private DrivePath(DrivePath drivePath) { this.startVector = drivePath.startVector; this.endVector = drivePath.endVector; this.startId = drivePath.startId; this.endId = drivePath.endId; this.fullLength = drivePath.fullLength; this.breakFactor = drivePath.breakFactor; this.originalBreakFactor = drivePath.originalBreakFactor; this.wayWidthFactor = drivePath.wayWidthFactor; this.blinkDirection = drivePath.blinkDirection; this.blinkStart = drivePath.blinkStart; this.breakStart = drivePath.breakStart; this.upcomingTrafficLight = drivePath.upcomingTrafficLight; this.isBacking = drivePath.isBacking; }
private static void ApplyTimeOnTrafficLight(TrafficLightLogic trafficLight, float time) { trafficLight.setTimeBetweenSwitches(time); Dictionary <RelationState, List <TrafficLightLogic> > trafficLightEntry = TrafficLightRelations [trafficLight]; if (trafficLightEntry.ContainsKey(RelationState.SAME_DIRECTION)) { foreach (TrafficLightLogic sameDirectionLight in trafficLightEntry[RelationState.SAME_DIRECTION]) { sameDirectionLight.setTimeBetweenSwitches(time); } foreach (TrafficLightLogic otherDirectionLight in trafficLightEntry[RelationState.CROSSING_DIRECTION]) { otherDirectionLight.setTimeBetweenSwitches(time); } } }
private static void ApplyStateOnTrafficLight(TrafficLightLogic trafficLight, TrafficLightLogic.State state) { TrafficLightLogic.State otherState = state == TrafficLightLogic.State.GREEN ? TrafficLightLogic.State.RED : TrafficLightLogic.State.GREEN; trafficLight.setState(state); Dictionary <RelationState, List <TrafficLightLogic> > trafficLightEntry = TrafficLightRelations [trafficLight]; if (trafficLightEntry.ContainsKey(RelationState.SAME_DIRECTION)) { foreach (TrafficLightLogic sameDirectionLight in trafficLightEntry[RelationState.SAME_DIRECTION]) { sameDirectionLight.setState(state); } foreach (TrafficLightLogic otherDirectionLight in trafficLightEntry[RelationState.CROSSING_DIRECTION]) { otherDirectionLight.setState(otherState); } } }
public static void ApplyConfig(XmlNode objectNode) { string id = objectNode.Attributes.GetNamedItem("id").Value; TrafficLightLogic trafficLight = GetTrafficLightById(id); if (trafficLight) { foreach (XmlNode propertyNode in objectNode.ChildNodes) { switch (propertyNode.Name) { case "time": float time = float.Parse(propertyNode.InnerText); ApplyTimeOnTrafficLight(trafficLight, time); break; case "state": TrafficLightLogic.State state = propertyNode.InnerText == "RED" ? TrafficLightLogic.State.RED : TrafficLightLogic.State.GREEN; ApplyStateOnTrafficLight(trafficLight, state); break; } } } }
public static void RemoveTrafficLight(TrafficLightLogic trafficLight) { TrafficLights.Remove(trafficLight); }
public static void AddTrafficLight(TrafficLightLogic trafficLight) { TrafficLights.Add(trafficLight); }
public TrafficLightCollisionObj(TrafficLightLogic trafficLightLogic, string collisionObjType) : base(collisionObjType, TrafficLightCollisionObj.NAME) { this.TrafficLightLogic = trafficLightLogic; }