Пример #1
0
 private void setUpcomingTrafficLight(long currTargetId, long prevTargetId)
 {
     if (TrafficLightIndex.TrafficLightsForPos.ContainsKey(currTargetId))
     {
         upcomingTrafficLight = TrafficLightIndex.TrafficLightsForPos[currTargetId].Find(trafficLight => trafficLight.getOtherPos().Id == prevTargetId);
     }
 }
Пример #2
0
    private static TrafficLightLogic GetTrafficLightById(string id)
    {
        TrafficLightLogic trafficLight = null;

        foreach (TrafficLightLogic light in TrafficLights)
        {
            if (light.Id == id)
            {
                trafficLight = light;
                break;
            }
        }
        return(trafficLight);
    }
Пример #3
0
 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;
 }
Пример #4
0
    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);
            }
        }
    }
Пример #5
0
    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);
            }
        }
    }
Пример #6
0
    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;
                }
            }
        }
    }
Пример #7
0
 public static void RemoveTrafficLight(TrafficLightLogic trafficLight)
 {
     TrafficLights.Remove(trafficLight);
 }
Пример #8
0
 public static void AddTrafficLight(TrafficLightLogic trafficLight)
 {
     TrafficLights.Add(trafficLight);
 }
Пример #9
0
 public TrafficLightCollisionObj(TrafficLightLogic trafficLightLogic, string collisionObjType) : base(collisionObjType, TrafficLightCollisionObj.NAME)
 {
     this.TrafficLightLogic = trafficLightLogic;
 }