public PedestrianLane(PointF startPoint, PointF endPoint, PointF stoppingPoint, List <PointF> edgePoints, Direction LDF, Direction LDT, Road parentRoad) { this.startPoint = startPoint; this.endPoint = endPoint; this.stoppingPoint = stoppingPoint; this.edges = edgePoints; this.parentRoad = parentRoad; this.endPointsOnScreen = new Dictionary <int, Point>(); this.edgesOnScreen = new List <Point>(); myPath = new GraphicsPath(); if (edges == null) { myPath.AddLine(startPoint, endPoint); } else { if (this.edges.Count == 1) { myPath.AddLine(startPoint, edges.Last()); myPath.AddLine(edges.Last(), endPoint); } else if (this.edges.Count > 1) { myPath.AddLine(startPoint, edges.First()); int counter = 0; foreach (PointF Edge in edges) { if (counter + 1 < edges.Count) { myPath.AddLine(Edge, edges.ElementAt(edges.IndexOf(Edge) + 1)); } counter++; } myPath.AddLine(edges.Last(), endPoint); } else { MyPath.AddLine(startPoint, endPoint); } } Pedestrians = new List <Pedestrian>(); this.laneDirectionTo = LDT; this.laneDirectionFrom = LDF; isInitialLane = true; }
// PointF[] pathPoints; // ----------------------------------------------------------------------------------- // ---------------------------------------Constructors-------------------------------------------- public Lane(PointF startPoint, PointF endPoint, PointF stoppingPoint, List <PointF> edgePoints, Direction LDF, Direction LDT, Road parentRoad) { this.startPoint = startPoint; this.endPoint = endPoint; this.stoppingPoint = stoppingPoint; this.edges = edgePoints; this.parentRoad = parentRoad; this.endPointsOnScreen = new Dictionary <int, Point>(); this.edgesOnScreen = new List <Point>(); if (parentRoad.type == "two-way-h") { if (LDF == Direction.West) { this.endPointsOnScreen.Add(2, new Point(120 + parentRoad.Pb_Background.Location.X, parentRoad.Pb_Background.Location.Y)); } else { this.endPointsOnScreen.Add(2, new Point(80 + parentRoad.Pb_Background.Location.X, 200 + parentRoad.Pb_Background.Location.Y)); } } else if (parentRoad.type == "two-way-v") { if (LDF == Direction.North) { this.endPointsOnScreen.Add(2, new Point(200 + parentRoad.Pb_Background.Location.X, 120 + parentRoad.Pb_Background.Location.Y)); } else { this.endPointsOnScreen.Add(2, new Point(parentRoad.Pb_Background.Location.X, 80 + parentRoad.Pb_Background.Location.Y)); } } myPath = new GraphicsPath(); if (edges == null) { myPath.AddLine(startPoint, endPoint); } else { if (this.edges.Count == 1) { myPath.AddLine(startPoint, edges.Last()); myPath.AddLine(edges.Last(), endPoint); } else if (this.edges.Count > 1) { myPath.AddLine(startPoint, edges.First()); int counter = 0; foreach (PointF Edge in edges) { if (counter + 1 < edges.Count) { myPath.AddLine(Edge, edges.ElementAt(edges.IndexOf(Edge) + 1)); } counter++; } myPath.AddLine(edges.Last(), endPoint); } else { MyPath.AddLine(startPoint, endPoint); } } cars = new List <Car>(); this.laneDirectionTo = LDT; this.laneDirectionFrom = LDF; isInitialLane = true; }