//TESTING public void test() { RoadVisualizer.placeRoad(new Edge(new Node(100, 100), new Node(125, 125), RoadTypes.HIGHWAY), "0"); RoadVisualizer.placeRoad(new Edge(new Node(125, 125), new Node(180, 150), RoadTypes.HIGHWAY), "1"); RoadVisualizer.placeRoad(PositionLegalizer.legalizeRoad(new Edge(new Node(180, 150), new Node(200, 250), RoadTypes.HIGHWAY)), "2"); RoadVisualizer.placeRoad(new Edge(new Node(200, 250), new Node(200, 550), RoadTypes.HIGHWAY), "3"); RoadVisualizer.placeRoad(new Edge(new Node(200, 550), new Node(200, 750), RoadTypes.HIGHWAY), "4"); RoadVisualizer.placeRoad(new Edge(new Node(125, 125), new Node(125, 175), RoadTypes.STREET), "5"); RoadVisualizer.placeRoad(new Edge(new Node(125, 175), new Node(80, 225), RoadTypes.STREET), "6"); RoadVisualizer.placeRoad(new Edge(new Node(125, 175), new Node(180, 150), RoadTypes.STREET), "7"); }
public Edge validateRoad(Edge road) { if (CityGeneratorUI.DebugMode) { Debug.Log("Localconstraints, checking: " + road); } // Try to legalize the position Edge newRoad = PositionLegalizer.legalizeRoad(road); if (newRoad == null) { if (CityGeneratorUI.DebugMode) { Debug.Log("Position legalizer could not fix: " + road); } return(null); } else { // Fix intersections newRoad = intersectionChecker.fixRoad(newRoad); if (newRoad == null) { if (CityGeneratorUI.DebugMode) { Debug.Log("Intersection checker could not fix: " + road); } return(null); } //Check if the road has a valid length if (!CoordinateHelper.validRoadLength(newRoad)) { if (CityGeneratorUI.DebugMode) { Debug.Log("Road was fixed but was not long enough: " + road); } return(null); } else { return(newRoad); } } }