public override void Build(City c) { MergePoint m1 = new MergePoint(); CityNode nw1 = wTop = new MergeNode(x - 40, y - 80, m1, "nw1"); CityNode ne1 = eTop = new CityNode(x + 40, y - 80, "ne1"); CityPath p1 = ne1.Connect(nw1, CityPathType.privates); m1.priority = p1; MergePoint m2 = new MergePoint(); CityNode nw2 = wLeft = new MergeNode(x - 80, y + 40, m2, "nw2"); CityNode ne2 = eLeft = new CityNode(x - 80, y - 40, "ne2"); CityPath p2 = ne2.Connect(nw2, CityPathType.privates); m2.priority = p2; MergePoint m3 = new MergePoint(); CityNode nw3 = wBottom = new MergeNode(x + 40, y + 80, m3, "nw3"); CityNode ne3 = eBottom = new CityNode(x - 40, y + 80, "ne3"); CityPath p3 = ne3.Connect(nw3, CityPathType.privates); m3.priority = p3; MergePoint m4 = new MergePoint(); CityNode nw4 = wRight = new MergeNode(x + 80, y - 40, m4, "nw4"); CityNode ne4 = eRight = new CityNode(x + 80, y + 40, "ne4"); CityPath p4 = ne4.Connect(nw4, CityPathType.privates); m4.priority = p4; nw1.Connect(ne2, CityPathType.privates, 40); nw2.Connect(ne3, CityPathType.privates, 40); nw3.Connect(ne4, CityPathType.privates, 40); nw4.Connect(ne1, CityPathType.privates, 40); pTopLeft = new CityNode(x - 100, y - 100); pTopRight = new CityNode(x + 100, y - 100); pBottomLeft = new CityNode(x - 100, y + 100); pBottomRight = new CityNode(x + 100, y + 100); pTopLeft.Connect(pTopRight, CityPathType.pedestrians); pTopLeft.Connect(pBottomLeft, CityPathType.pedestrians); pTopRight.Connect(pTopLeft, CityPathType.pedestrians); pTopRight.Connect(pBottomRight, CityPathType.pedestrians); pBottomLeft.Connect(pBottomRight, CityPathType.pedestrians); pBottomLeft.Connect(pTopLeft, CityPathType.pedestrians); pBottomRight.Connect(pBottomLeft, CityPathType.pedestrians); pBottomRight.Connect(pTopRight, CityPathType.pedestrians); c.nodes.Add(pTopLeft); c.nodes.Add(pTopRight); c.nodes.Add(pBottomLeft); c.nodes.Add(pBottomRight); c.nodes.Add(nw1); c.nodes.Add(ne1); c.nodes.Add(nw2); c.nodes.Add(ne2); c.nodes.Add(nw3); c.nodes.Add(ne3); c.nodes.Add(nw4); c.nodes.Add(ne4); }
public override void Build(City c) { if (this.n1 is BuilderAllWayStopNode) { BuilderAllWayStopNode n1 = this.n1 as BuilderAllWayStopNode; n1.Connect(this, out s1, out e1, out p11, out p12); } if (this.n1 is BuilderTrafficCircleNode) { BuilderTrafficCircleNode n1 = this.n1 as BuilderTrafficCircleNode; n1.Connect(this, out s1, out e1, out p11, out p12); } if (this.n1 is BuilderDeadEndNode) { BuilderDeadEndNode n1 = this.n1 as BuilderDeadEndNode; n1.Connect(this, out s1, out e1, out p11, out p12); } if (this.n2 is BuilderAllWayStopNode) { BuilderAllWayStopNode n2 = this.n2 as BuilderAllWayStopNode; n2.Connect(this, out s2, out e2, out p21, out p22); } if (this.n2 is BuilderTrafficCircleNode) { BuilderTrafficCircleNode n2 = this.n2 as BuilderTrafficCircleNode; n2.Connect(this, out s2, out e2, out p21, out p22); } if (this.n2 is BuilderDeadEndNode) { BuilderDeadEndNode n2 = this.n2 as BuilderDeadEndNode; n2.Connect(this, out s2, out e2, out p21, out p22); } double dist = Util.Distance(s1.x, s1.y, e2.x, e2.y); int parkCount = (int)(dist / PARKING_LENGTH); double dir = Util.GetLookatDir(s1.x, s1.y, e2.x, e2.y); CityNode last = s1; CityNode lastPark = p11; for (int i = 1; i <= parkCount; i++) { int x = s1.x + (int)(i * PARKING_LENGTH * Math.Cos(dir)); int y = s1.y + (int)(i * PARKING_LENGTH * Math.Sin(dir)); MergeNode exit = new MergeNode(x, y, new MergePoint()); x -= (int)(PARKING_LENGTH / 2 * Math.Cos(dir)); x += (int)(20 * Math.Cos(dir + Math.PI / 2)); y -= (int)(PARKING_LENGTH / 2 * Math.Sin(dir)); y += (int)(20 * Math.Sin(dir + Math.PI / 2)); ParkingNode park = new ParkingNode(x, y); CityPath priority = last.Connect(exit, CityPathType.privates); last.Connect(park, CityPathType.privates); park.Connect(exit, CityPathType.privates); lastPark.Connect(park, CityPathType.pedestrians); park.Connect(lastPark, CityPathType.pedestrians); c.nodes.Add(exit); c.nodes.Add(park); (exit.intersection as MergePoint).priority = priority; last = exit; lastPark = park; } last.Connect(e2, CityPathType.privates); lastPark.Connect(p22, CityPathType.pedestrians); p22.Connect(lastPark, CityPathType.pedestrians); dist = Util.Distance(s2.x, s2.y, e1.x, e1.y); parkCount = (int)(dist / PARKING_LENGTH); dir = Util.GetLookatDir(s2.x, s2.y, e1.x, e1.y); last = s2; lastPark = p21; for (int i = 1; i <= parkCount; i++) { int x = s2.x + (int)(i * PARKING_LENGTH * Math.Cos(dir)); int y = s2.y + (int)(i * PARKING_LENGTH * Math.Sin(dir)); CityNode exit = new CityNode(x, y); x -= (int)(PARKING_LENGTH / 2 * Math.Cos(dir)); x += (int)(20 * Math.Cos(dir + Math.PI / 2)); y -= (int)(PARKING_LENGTH / 2 * Math.Sin(dir)); y += (int)(20 * Math.Sin(dir + Math.PI / 2)); ParkingNode park = new ParkingNode(x, y); last.Connect(exit, CityPathType.privates); last.Connect(park, CityPathType.privates); park.Connect(exit, CityPathType.privates); lastPark.Connect(park, CityPathType.pedestrians); park.Connect(lastPark, CityPathType.pedestrians); c.nodes.Add(exit); c.nodes.Add(park); last = exit; lastPark = park; } last.Connect(e1, CityPathType.privates); lastPark.Connect(p12, CityPathType.pedestrians); p12.Connect(lastPark, CityPathType.pedestrians); }