/// <summary> /// Constructor where the intra crossing connections are made /// </summary> /// <param name="crossingId"></param> public Crossing_A(int crossingId) : base(crossingId) { lanes = new List<TrafficLane>(); tLanes = new List<TrafficLane>(); Light lightNORTH = new Light(false); Light lightEAST = new Light(false); Light lightSOUTH = new Light(false); Light lightWEST = new Light(false); for (int i = 0; i < 4; i++) { lanes.Add(new TrafficLane(i, false, (Direction)i, null, tLanes, this)); tLanes = new List<TrafficLane>(); } //Adding the list of lanes that a certain lane can go to, as well as creating the lanes. //For South tLanes.Add(lanes.ElementAt(3)); lanes.Add(new TrafficLane(4, true, Direction.SOUTH, lightSOUTH, tLanes, this)); tLanes = new List<TrafficLane>(); tLanes.AddRange((new TrafficLane[] { lanes.ElementAt(1), lanes.ElementAt(2) }).ToList<TrafficLane>()); lanes.Add(new TrafficLane(5, true, Direction.SOUTH, lightSOUTH, tLanes, this)); tLanes = new List<TrafficLane>(); //For West tLanes.Add(lanes.ElementAt(0)); lanes.Add(new TrafficLane(6, true, Direction.WEST, lightWEST, tLanes, this)); tLanes = new List<TrafficLane>(); tLanes.AddRange(new TrafficLane[] { lanes.ElementAt(2), lanes.ElementAt(3) }); lanes.Add(new TrafficLane(7, true, Direction.WEST, lightWEST, tLanes, this)); tLanes = new List<TrafficLane>(); //For North tLanes.Add(lanes.ElementAt(1)); lanes.Add(new TrafficLane(8, true, Direction.NORTH, lightNORTH, tLanes, this)); tLanes = new List<TrafficLane>(); tLanes.AddRange(new TrafficLane[] { lanes.ElementAt(0), lanes.ElementAt(3) }); lanes.Add(new TrafficLane(9, true, Direction.NORTH, lightNORTH, tLanes, this)); tLanes = new List<TrafficLane>(); //For East tLanes.Add(lanes.ElementAt(2)); lanes.Add(new TrafficLane(10, true, Direction.EAST, lightEAST, tLanes, this)); tLanes = new List<TrafficLane>(); tLanes.AddRange(new TrafficLane[] { lanes.ElementAt(0), lanes.ElementAt(1) }); lanes.Add(new TrafficLane(11, true, Direction.EAST, lightEAST, tLanes, this)); tLanes = new List<TrafficLane>(); base.Lanes.AddRange(lanes); }
/// <summary> /// Constructor of the traffic lane /// </summary> /// <param name="iD"></param> /// <param name="toFromCross"></param> /// <param name="direction"></param> /// <param name="trafficLight"></param> /// <param name="connLanes"></param> /// <param name="parent"></param> public TrafficLane(int iD, bool toFromCross, Direction direction, Light trafficLight, List<TrafficLane> connLanes, Crossing parent) : base(iD) { this.ID = iD; this.ToFromCross = toFromCross; this.Direction = direction; this.Lanes = connLanes; this.parent = parent; this.TrafficLight = trafficLight; Cars = new List<Car>(); this.initPoints(); }
/// <param name="crossingId">The Id of the crossing</param> /// <param name="position"></param> public Crossing_B(int crossingId) : base(crossingId) { lanes = new List<TrafficLane>(); tLanes = new List<TrafficLane>(); Light lightNORTH = new Light(false); Light lightEAST = new Light(false); Light lightSOUTH = new Light(false); Light lightWEST = new Light(false); for (int i = 0; i < 4; i++) { lanes.Add(new TrafficLane(i, false, (Direction)i, null, tLanes, this)); tLanes = new List<TrafficLane>(); } //Adding the list of lanes that a certain lane can go to, as well as creating the lanes. //For South tLanes.Add(lanes.ElementAt(2)); lanes.Add(new TrafficLane(4, true, Direction.SOUTH, lightSOUTH, tLanes, this)); tLanes = new List<TrafficLane>(); //For West tLanes.AddRange(new TrafficLane[] { lanes.ElementAt(0), lanes.ElementAt(3) }); lanes.Add(new TrafficLane(5, true, Direction.WEST, lightWEST, tLanes, this)); tLanes = new List<TrafficLane>(); tLanes.Add(lanes.ElementAt(2)); lanes.Add(new TrafficLane(6, true, Direction.WEST, lightWEST, tLanes, this)); tLanes = new List<TrafficLane>(); //For North tLanes.Add(lanes.ElementAt(0)); lanes.Add(new TrafficLane(7, true, Direction.NORTH, lightNORTH, tLanes, this)); tLanes = new List<TrafficLane>(); //For East tLanes.AddRange(new TrafficLane[] { lanes.ElementAt(1), lanes.ElementAt(2) }); lanes.Add(new TrafficLane(8, true, Direction.EAST, lightEAST, tLanes, this)); tLanes = new List<TrafficLane>(); tLanes.Add(lanes.ElementAt(0)); lanes.Add(new TrafficLane(9, true, Direction.EAST, lightEAST, tLanes, this)); tLanes = new List<TrafficLane>(); base.Lanes.AddRange(lanes); //Adding the list of pedestrians pedestrians = new List<Pedestrian>(); //Adding the pedestrian lane list and the pedestrian lights pLanes = new List<PedestrianLane>(); //top lane PedestrianLight pLight = new PedestrianLight(false, false); pLanes.Add(new PedestrianLane(1, CalculatePedestrianLanePoints(1), pLight, this)); //bottom lane pLight = new PedestrianLight(false, false); pLanes.Add(new PedestrianLane(2, CalculatePedestrianLanePoints(2), pLight, this)); }