// Start is called before the first frame update void Start() { RoutePartsList = new List <GameObject>(); TextAsset asset = Resources.Load("reittiopas") as TextAsset; Stops = JsonUtility.FromJson <pysakitlist>(asset.text); List <TMP_Dropdown.OptionData> dropDownOption = new List <TMP_Dropdown.OptionData>(); foreach (var item in Stops.pysakit) { dropDownOption.Add(new TMP_Dropdown.OptionData(item)); } StartStation.AddOptions(dropDownOption); EndStation.AddOptions(dropDownOption); }
// Start is called before the first frame update void Start() { CurrentLinjasto = 0; TextAsset asset = Resources.Load("reittiopas") as TextAsset; if (asset != null) { RoadsList = JsonUtility.FromJson <tietlist>(asset.text); pysakitlist = JsonUtility.FromJson <pysakitlist>(asset.text); linjastot = JsonUtility.FromJson <linjastotlist>(asset.text); } //foreach (var item in linjastot.keltainen) //{ // print(item); //} List <string> currentRoute = new List <string>(); GetRoute("E", "F", currentRoute, 0); BestRoute usethisroute = new BestRoute(); usethisroute.Lenght = 1000; //print all routes foreach (var item in PossibleRoutes) { print("complete route:"); Printstr = ""; foreach (var route in item) { Printstr += " -> " + route; } int routelenght = 0; for (int i = 1; i < item.Count; i++) { routelenght += GetLenght(item[i - 1], item[i]); } print(Printstr); print("Lenght: " + routelenght); if (routelenght < usethisroute.Lenght) { usethisroute.Route = item; usethisroute.Lenght = routelenght; } } print("Best route:"); Printstr = ""; foreach (var route in usethisroute.Route) { Printstr += " -> " + route; } print(Printstr); print("Lenght: " + usethisroute.Lenght); for (int i = 1; i < usethisroute.Route.Count; i++) { int line; ////check first the one line being used line = checkCurrentLinjasto(usethisroute.Route[i - 1], usethisroute.Route[i], CurrentLinjasto); usethisroute.RouteColor.Add(line); CurrentLinjasto = line; print("Color: " + usethisroute.RouteColor[i - 1]); } }