public override void Update() { if (createRoads) { var pp = peds; var rr = roads; var hh = highways; if (currentIndex < roadMaker.osm.ways.Count()) { //roadMaker.MakeRoad(currentIndex); SimulationManager.instance.AddAction(roadMaker.MakeRoad(currentIndex, pp, rr, hh)); currentIndex += 1; } if (currentIndex < roadMaker.osm.ways.Count()) { //roadMaker.MakeRoad(currentIndex); SimulationManager.instance.AddAction(roadMaker.MakeRoad(currentIndex, pp, rr, hh)); currentIndex += 1; } if (currentIndex < roadMaker.osm.ways.Count()) { //roadMaker.MakeRoad(currentIndex); SimulationManager.instance.AddAction(roadMaker.MakeRoad(currentIndex, pp, rr, hh)); currentIndex += 1; var instance = Singleton <NetManager> .instance; errorLabel.text = String.Format("Making road {0} out of {1}. Nodes: {2}. Segments: {3}", currentIndex, roadMaker.osm.ways.Count(), instance.m_nodeCount, instance.m_segmentCount); } } if (roadMaker != null && currentIndex == roadMaker.osm.ways.Count()) { errorLabel.text = "Done."; createRoads = false; } base.Update(); }
public override void Update() { Boolean reachedTheEnd = false; if (createRoads && !pauseCreateRoads) { for (int i = 0; i < currentMakeSpeed; i++) { if (currentRoadTypeIndex < roadCheckbox.Count) { OSMRoadTypes rt = roadCheckbox.Keys.ElementAt(currentRoadTypeIndex); int way_count = roadMaker.osm.ways[rt].Count(); if (roadCheckbox[rt].text == CHECKBOX_CHECKED && way_count > 0 && currentIndex < way_count) { SimulationManager.instance.AddAction(roadMaker.MakeRoad(currentIndex, rt)); currentIndex++; var instance = Singleton <NetManager> .instance; makeErrorLabel.text = String.Format("RoadType {0} / {1}; {2} {3} / {4}. Nodes: {5}. Segments: {6}", currentRoadTypeIndex, roadMaker.osm.ways.Count(), rt.ToString(), currentIndex, way_count, instance.m_nodeCount, instance.m_segmentCount); } else { // end of current roadtype if (currentIndex > 0) { setCheckboxBuilt(roadCheckbox[rt], roadCheckboxLabel[rt]); } currentRoadTypeIndex++; currentIndex = 0; } } else { reachedTheEnd = true; i = currentMakeSpeed; // break; } } } if (reachedTheEnd) { var instance = Singleton <NetManager> .instance; int currentNodeCount = instance.m_nodeCount; String s = "You can still add different road-types."; if (currentNodeCount >= maxNodes) { s = "Engine limit reached! You cannot build any more roads!" + Environment.NewLine + "REMOVE A BUNCH OF ROADS TO MAKE THE MAP PLAYABLE!"; makeErrorLabel.textColor = COLOR_ERROR; } else { makeErrorLabel.textColor = COLOR_SUCCESS; } makeErrorLabel.text += Environment.NewLine + "Done. " + s; createRoads = false; reachedTheEnd = false; currentIndex = 0; currentRoadTypeIndex = 0; updateLimits(); } base.Update(); }