public Road(RoadData roaddata, Bezier[] beziers) { this.beziers = beziers; linecolor = roaddata.LineColor; lanelist = new List<RoadLane>(); roadcolor = roaddata.RoadColor; this.roaddata = roaddata; vehiclelist = new List<Vehicle>(); for (int i = 0; i < roaddata.ForwardLaneCount; i++) if (i == roaddata.ForwardLaneCount - 1 && roaddata.ForwardShoulder) addlane(LaneDirection.Forward, LaneType.Shoulder); else addlane(LaneDirection.Forward, LaneType.Normal); for (int i = 0; i < roaddata.BackwardLaneCount; i++) if (i == roaddata.BackwardLaneCount - 1 && roaddata.BackwardShoulder) addlane(LaneDirection.Backward, LaneType.Shoulder); else addlane(LaneDirection.Backward, LaneType.Normal); }
private void makemap() { var speeddictionary = new Dictionary<string, double>(); var crossingdata = new CrossingData(0.15); // Snelheden van Vehicle typen speeddictionary.Add("Bus", 80/3.6); speeddictionary.Add("Car", 120/3.6); speeddictionary.Add("Motorcycle", 120/3.6); speeddictionary.Add("Truck", 80/3.6); speeddictionary.Add("Vehicle", 120/3.6); var roaddata = new RoadData(RoadType.Highway, speeddictionary, Color.Gray, Color.White, 4, 4, true, true, 3.5, 3, 0.15, 9); // Bepaal via welke Lane je waarheen mag zoals beschreven in de PDF voor symmetrische Crossings var connectiondictionary1 = new Dictionary<int, HashSet<RoadLaneIndex>>(); var roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(3, 0), new RoadLaneIndex(3, 1), new RoadLaneIndex(3, 2)}; connectiondictionary1.Add(0, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(2, 0), new RoadLaneIndex(2, 1), new RoadLaneIndex(2, 2)}; connectiondictionary1.Add(1, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(1, 0), new RoadLaneIndex(1, 1), new RoadLaneIndex(1, 2)}; connectiondictionary1.Add(2, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(1, 3)}; connectiondictionary1.Add(3, roadlaneindexhashset); // Leg de Roads neer. if (!buggedmap) { roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-1450, -500, -550, -500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-450, -500, 450, -500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(550, -500, 1500, -500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-1450, 500, -550, 500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-450, 500, 450, 500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(550, 500, 1500, 500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-500, -1500, -500, -550)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-500, -450, -500, 450)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-500, 550, -500, 1500)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(500, -1500, 500, -550)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(500, -450, 500, 450)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(500, 550, 500, 1500)})); roadlist.Add(new Road(roaddata, new Bezier[] { new CubicBezier(-3500, -2500, -3000, -2500, -2500, -2000, -2000, -2000), new CircularBezier(-2000, -2000, -2000, -1500, -1500, -1500), new LinearBezier(-1500, -1500, -1500, -550) })); // 12 roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-1500, -450, -1500, 450)})); roadlist.Add(new Road(roaddata, new Bezier[] { new LinearBezier(-1500, 550, -1500, 1500), new CircularBezier(-1500, 1500, -2000, 1500, -2000, 2000), new QuadraticBezier(-2000, 2000, -2500, 2000, -2500, 1500) })); // Voeg de Crossings toe. crossinglist.Add(new Crossing(-500, -500, crossingdata, new RoadConnection(roadlist[0], connectiondictionary1), new RoadConnection(roadlist[1], connectiondictionary1), new RoadConnection(roadlist[6], connectiondictionary1), new RoadConnection(roadlist[7], connectiondictionary1))); crossinglist.Add(new Crossing(500, -500, crossingdata, new RoadConnection(roadlist[1], connectiondictionary1), new RoadConnection(roadlist[2], connectiondictionary1), new RoadConnection(roadlist[9], connectiondictionary1), new RoadConnection(roadlist[10], connectiondictionary1))); crossinglist.Add(new Crossing(-500, 500, crossingdata, new RoadConnection(roadlist[3], connectiondictionary1), new RoadConnection(roadlist[4], connectiondictionary1), new RoadConnection(roadlist[7], connectiondictionary1), new RoadConnection(roadlist[8], connectiondictionary1))); crossinglist.Add(new Crossing(500, 500, crossingdata, new RoadConnection(roadlist[4], connectiondictionary1), new RoadConnection(roadlist[5], connectiondictionary1), new RoadConnection(roadlist[10], connectiondictionary1), new RoadConnection(roadlist[11], connectiondictionary1))); } else { roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-600, -500, -600, -50)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-600, 50, -600, 250)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-950, 0, -650, 0)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(-550, 0, -50, 0)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(50, 0, 350, 0)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(0, -250, 0, -50)})); roadlist.Add(new Road(roaddata, new Bezier[] {new LinearBezier(0, 50, 0, 600)})); crossinglist.Add(new Crossing(-600, 0, crossingdata, new RoadConnection(roadlist[0], connectiondictionary1), new RoadConnection(roadlist[1], connectiondictionary1), new RoadConnection(roadlist[2], connectiondictionary1), new RoadConnection(roadlist[3], connectiondictionary1))); crossinglist.Add(new Crossing(0, 0, crossingdata, new RoadConnection(roadlist[3], connectiondictionary1), new RoadConnection(roadlist[4], connectiondictionary1), new RoadConnection(roadlist[5], connectiondictionary1), new RoadConnection(roadlist[6], connectiondictionary1))); } if (!buggedmap) { //Bepaal via welke Lane je waarheen mag zoals beschreven in de PDF voor T Crossings. connectiondictionary1 = new Dictionary<int, HashSet<RoadLaneIndex>>(); var connectiondictionary2 = new Dictionary<int, HashSet<RoadLaneIndex>>(); var connectiondictionary3 = new Dictionary<int, HashSet<RoadLaneIndex>>(); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(2, 0), new RoadLaneIndex(2, 1), new RoadLaneIndex(2, 2)}; connectiondictionary1.Add(0, roadlaneindexhashset); connectiondictionary2.Add(0, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(1, 0), new RoadLaneIndex(1, 1)}; connectiondictionary1.Add(1, roadlaneindexhashset); connectiondictionary2.Add(1, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(1, 2)}; connectiondictionary1.Add(2, roadlaneindexhashset); connectiondictionary2.Add(2, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(1, 3)}; connectiondictionary1.Add(3, roadlaneindexhashset); connectiondictionary2.Add(3, roadlaneindexhashset); connectiondictionary3.Add(3, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(2, 0)}; connectiondictionary3.Add(0, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(2, 1), new RoadLaneIndex(2, 2)}; connectiondictionary3.Add(1, roadlaneindexhashset); roadlaneindexhashset = new HashSet<RoadLaneIndex> {new RoadLaneIndex(1, 0), new RoadLaneIndex(1, 1), new RoadLaneIndex(1, 2)}; connectiondictionary3.Add(2, roadlaneindexhashset); crossinglist.Add(new Crossing(-1500, -500, crossingdata, new RoadConnection(roadlist[12], connectiondictionary1), new RoadConnection(roadlist[0], connectiondictionary2), new RoadConnection(roadlist[13], connectiondictionary3))); crossinglist.Add(new Crossing(-1500, 500, crossingdata, new RoadConnection(roadlist[13], connectiondictionary1), new RoadConnection(roadlist[3], connectiondictionary2), new RoadConnection(roadlist[14], connectiondictionary3))); } //bool dreamscametrue = false; //if (dreamscametrue) //{ // roadlist = (List<Road>)Serializer.Deserialize(Global.HomeFolder + "\\Maps\\Default_roadlist.xml", false); // crossinglist = new List<Crossing>(); // foreach (Crossing crossing in (List<Crossing>)Serializer.Deserialize(Global.HomeFolder + "\\Maps\\Default_crossinglist.xml", false)) // { // crossing.DeserializationRepopulation(); // crossinglist.Add(crossing); // } //} // Voeg Buildings toe. #region LegacyBuildingConstruction /* * LEGACY * buildinglist.Add(new Building(Color.Beige, -450, -300, -400, -300, -425, -100, -450, -100)); buildinglist.Add(new Building(Color.Chocolate, -450, -50, -400, -50, -400, 0, -425, 0, -425, -25, -450, -25));\ * */ #endregion foreach ( Building building in (List<Building>) Serializer.Deserialize(Global.HomeFolder + "\\Maps\\Default_buildinglist.xml", false)) { building.DeserializationRepopulation(); buildinglist.Add(building); } }