/// <summary> /// Reads the cities data from a packed string. /// </summary> void ReadCitiesPackedString(string s) { string[] cityList = s.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); int cityCount = cityList.Length; cities = new List <City> (cityCount); for (int k = 0; k < cityCount; k++) { string[] cityInfo = cityList [k].Split(new char[] { '$' }); string country = cityInfo [2]; int countryIndex = GetCountryIndex(country); if (countryIndex >= 0) { string name = cityInfo [0]; string province = cityInfo [1]; int population = int.Parse(cityInfo [3]); float x = float.Parse(cityInfo [4]) / MAP_PRECISION; float y = float.Parse(cityInfo [5]) / MAP_PRECISION; float z = float.Parse(cityInfo [6]) / MAP_PRECISION; CITY_CLASS cityClass = (CITY_CLASS)int.Parse(cityInfo[7]); City city = new City(name, province, countryIndex, population, new Vector3(x, y, z), cityClass); cities.Add(city); } } }
public void CitySelect() { if (cityIndex < 0 || cityIndex > map.cities.Count) { return; } // If no country is selected (the city could be at sea) select it City city = map.cities[cityIndex]; int cityCountryIndex = city.countryIndex; if (cityCountryIndex < 0) { SetInfoMsg("City's country not found in this country file."); } if (countryIndex != cityCountryIndex && cityCountryIndex >= 0) { ClearSelection(); countryIndex = cityCountryIndex; countryRegionIndex = map.countries[countryIndex].mainRegionIndex; CountryRegionSelect(); } // Just in case makes GUICountryIndex selects appropiate value in the combobox GUICityName = city.name; GUICityPopulation = city.population.ToString(); GUICityClass = city.cityClass; SyncGUICitySelection(); if (cityIndex >= 0) { GUICityNewName = city.name; CityHighlightSelection(); } }
void ReadCitiesPackedString() { string cityCatalogFileName = "WPMF/Geodata/cities10"; TextAsset ta = Resources.Load <TextAsset> (cityCatalogFileName); string s = ta.text; string[] cityList = s.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); int cityCount = cityList.Length; cities = new List <City> (cityCount); for (int k = 0; k < cityCount; k++) { string[] cityInfo = cityList [k].Split(new char[] { '$' }); string country = cityInfo [2]; int countryIndex = GetCountryIndex(country); if (countryIndex >= 0) { string name = cityInfo [0]; string province = cityInfo [1]; int population = int.Parse(cityInfo [3]); float x = float.Parse(cityInfo [4], CultureInfo.InvariantCulture); float y = float.Parse(cityInfo [5], CultureInfo.InvariantCulture); CITY_CLASS cityClass = (CITY_CLASS)int.Parse(cityInfo[6], CultureInfo.InvariantCulture); City city = new City(name, province, countryIndex, population, new Vector2(x, y), cityClass); cities.Add(city); } } }
public void ClearCitySelection() { map.HideCityHighlights(); cityIndex = -1; GUICityName = ""; GUICityIndex = -1; GUICityNewName = ""; GUICityClass = CITY_CLASS.CITY; }
public MapCity(string name, int provinceIndex, int countryIndex, int population, Vector2 location, CITY_CLASS cityClass) { this.name = name; this.provinceIndex = provinceIndex; this.countryIndex = countryIndex; this.population = population; this.unity2DLocation = location; this.cityClass = cityClass; }
public City(string name, string province, int countryIndex, int population, Vector3 location, CITY_CLASS cityClass) { this.name = name; this.province = province; this.countryIndex = countryIndex; this.population = population; this.unitySphereLocation = location; this.cityClass = cityClass; }
public City(string name, string province, int countryIndex, int population, Vector2 location, CITY_CLASS cityClass, int uniqueId) { this.name = name; this.province = province; this.countryIndex = countryIndex; this.population = population; this.unity2DLocation = location; this.cityClass = cityClass; this.uniqueId = uniqueId; this.attrib = new JSONObject(); }
/// <summary> /// Loads cities information from a string /// </summary> public void SetCityGeoData(string s) { lastCityLookupCount = -1; string[] cityList = s.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); int cityCount = cityList.Length; _cities = new City[cityCount]; char[] separatorCities = new char[] { '$' }; int cityIndex = 0; int unknownCountryIndex = -1; for (int k = 0; k < cityCount; k++) { string[] cityInfo = cityList[k].Split(separatorCities); string country = cityInfo[2]; int countryIndex = GetCountryIndex(country); if (countryIndex < 0) { if (unknownCountryIndex < 0) { Country uc = new Country("Unknown", "None", 9999999); unknownCountryIndex = CountryAdd(uc); } countryIndex = unknownCountryIndex; } if (countryIndex >= 0) { string name = cityInfo[0]; string province = cityInfo[1]; int population = int.Parse(cityInfo[3], Misc.InvariantCulture); float x = float.Parse(cityInfo[4], Misc.InvariantCulture); float y = float.Parse(cityInfo[5], Misc.InvariantCulture); CITY_CLASS cityClass = (CITY_CLASS)int.Parse(cityInfo[6], Misc.InvariantCulture); int uniqueId; if (cityInfo.Length >= 8) { uniqueId = int.Parse(cityInfo[7], Misc.InvariantCulture); } else { uniqueId = GetUniqueId(new List <IExtendableAttribute>(_cities)); } if (cityClass == CITY_CLASS.COUNTRY_CAPITAL) { _countries [countryIndex].capitalCityIndex = cityIndex; } City city = new City(name, province, countryIndex, population, new Vector3(x, y), cityClass, uniqueId); _cities[k] = city; cityIndex++; } } }
/// <summary> /// Reads the cities data from a packed string. /// </summary> void ReadCitiesPackedString(string s) { if (_countries == null) { Init(); if (_cities != null) { return; } } string[] cityList = s.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); int cityCount = cityList.Length; cities = new List <City> (cityCount); int citiesCount = 0; for (int k = 0; k < cityCount; k++) { string[] cityInfo = cityList [k].Split(new char[] { '$' }); string country = cityInfo [2]; int countryIndex = GetCountryIndex(country); if (countryIndex >= 0) { string name = cityInfo [0]; string province = cityInfo [1]; int population = int.Parse(cityInfo [3]); float x = float.Parse(cityInfo [4], Misc.InvariantCulture) / MAP_PRECISION; float y = float.Parse(cityInfo [5], Misc.InvariantCulture) / MAP_PRECISION; float z = float.Parse(cityInfo [6], Misc.InvariantCulture) / MAP_PRECISION; CITY_CLASS cityClass = (CITY_CLASS)int.Parse(cityInfo [7]); City city = new City(name, province, countryIndex, population, new Vector3(x, y, z), cityClass); _cities.Add(city); if (cityClass == CITY_CLASS.COUNTRY_CAPITAL) { _countries [countryIndex].cityCapitalIndex = citiesCount; } citiesCount++; } } }