private static bool ParseTowns(NodeStruct node, FileLoader fileLoader) { byte type; NodeStruct nodeTown = fileLoader.GetChildNode(node, out type); while (nodeTown != null) { if (type != (byte)OtbmNodeTypes.Town) { return(false); } MemoryStream props; if (!fileLoader.GetProps(nodeTown, out props)) { return(false); } uint townId = props.ReadUInt32(); if (!Towns.ContainsKey(townId)) { Towns.Add(townId, new Town { TownId = townId }); } Town town = Towns[townId]; town.TownName = props.GetString(); town.TemplePosition = new Position(props.ReadUInt16(), props.ReadUInt16(), (byte)props.ReadByte()); nodeTown = fileLoader.GetNextNode(nodeTown, out type); } return(true); }
public void LoadCurrents(AbsolutePlace place) { var countries = namazApi.GetCountries(); countries.ForEach(c => Countries.Add(c)); if (!string.IsNullOrWhiteSpace(place.Country?.UlkeID) && Countries.Any()) { var selectedCnt = Countries.FirstOrDefault(c => c.UlkeID == place.Country?.UlkeID); SelectedCountry = selectedCnt; var cities = namazApi.GetCities(selectedCnt.UlkeID); cities.ForEach(c => Cities.Add(c)); if (!string.IsNullOrWhiteSpace(place.City?.SehirID)) { var selectedCity = Cities.FirstOrDefault(c => c.SehirID == place.City?.SehirID); SelectedCity = selectedCity; var towns = namazApi.GetTowns(selectedCity.SehirID); towns.ForEach(i => Towns.Add(i)); if (!string.IsNullOrWhiteSpace(place.Town?.IlceID)) { var selectedTown = Towns.FirstOrDefault(t => t.IlceID == place.Town?.IlceID); SelectedTown = SelectedTown; } else { var cityCenter = towns.FirstOrDefault(t => t.IlceAdi == selectedCity.SehirAdi); SelectedTown = cityCenter; } } } }
void Update() { Towns.Clear(); var list = townsService.GetAsync().Result; foreach (var n in list) { Towns.Add(n); } MessengerInstance.Send(new ObservableCollection <TownsModel>()); }
void Reload() { Towns.Clear(); var townsService = new TownsService(); var townsList = townsService.GetAsync().Result; foreach (var n in townsList) { Towns.Add(n.TownName); } }
/// <summary> /// Default constructor for the environment /// </summary> public GoldMineEnvironment() { Towns.Add(new Town(5, 5)); Towns.Add(new Town(7, 19)); Towns.Add(new Town(15, 9)); GoldMines.Add(new GoldMine(1, 1)); GoldMines.Add(new GoldMine(10, 8)); GoldMines.Add(new GoldMine(19, 18)); GoldMines.Add(new GoldMine(12, 15)); }
/// <summary> /// Returns town object in the map /// </summary> /// <param name="townName">Name of the town</param> /// <param name="createIfNotFound">If town not found in the map, setting it true will create it and then return. Setting it to false when town not found will throw exception.</param> /// <returns></returns> public Town GetTown(string townName, bool createIfNotFound = false) { var town = Towns.FirstOrDefault(n => n.Name == townName); if (town == null) { if (createIfNotFound) { town = new Town { Name = townName }; Towns.Add(town); } else { throw new ValidationException($"Cannot find town with name '{townName}' in the map."); } } return(town); }
/// <summary> /// Добавить город /// </summary> /// <param name="Name">Название города</param> /// <param name="coord">Координаты города</param> /// <param name="Id">ID города</param> /// <param name="town">Список объектов города</param> public static void AddTown(string Name, Coords coord, int Id, List <TownObject> town = null) { Towns.Add(new Town(Name, coord, Id, town)); }
private async void GetAutoCompleteStrings() { var engFirstNamesTask = _apiClient.AutoCompletes_GetEnglishFirstNamesAsync(); var engFatherNamesTask = _apiClient.AutoCompletes_GetEnglishFatherNamesAsync(); var engLastNamesTask = _apiClient.AutoCompletes_GetEnglishLastNamesAsync(); var ArabicFirstNamesTask = _apiClient.AutoCompletes_GetFirstNamesAsync(); var ArabicFatherNamesTask = _apiClient.AutoCompletes_GetFatherNamesAsync(); var ArabicLastNamesTask = _apiClient.AutoCompletes_GetLastNamesAsync(); var BirthPlacesTask = _apiClient.AutoCompletes_GetOrphansPlacesOfBirthAsync(); var SicknessNamesTask = _apiClient.AutoCompletes_GetSicknessNamesAsync(); var MedicensNamesTask = _apiClient.AutoCompletes_GetMedicensAsync(); var EducationReasonsTask = _apiClient.AutoCompletes_GetEducationReasonsAsync(); var EducationSchoolsTask = _apiClient.AutoCompletes_GetEducationSchoolsAsync(); var EducationStagesTask = _apiClient.AutoCompletes_GetEducationStagesAsync(); var CitiesTask = _apiClient.AutoCompletes_GetCitiesAsync(); var TownsTask = _apiClient.AutoCompletes_GetTownsAsync(); var StreetsTask = _apiClient.AutoCompletes_GetStreetsAsync(); var CountriesTask = _apiClient.AutoCompletes_GetCountriesAsync(); var engFirstList = await engFirstNamesTask; foreach (var firstN in engFirstList) { if (!EnglishNameStrings.Contains(firstN) && firstN != null && firstN.Length > 0) { EnglishNameStrings.Add(firstN); } } var engFatherList = await engFatherNamesTask; foreach (var FatherN in engFatherList) { if (!EnglishNameStrings.Contains(FatherN) && FatherN != null && FatherN.Length > 0) { EnglishNameStrings.Add(FatherN); } } var emgLastList = await engLastNamesTask; foreach (var lastN in emgLastList) { if (!EnglishNameStrings.Contains(lastN) && lastN != null && lastN.Length > 0) { EnglishNameStrings.Add(lastN); } } var FirstList = await ArabicFirstNamesTask; foreach (var firstN in FirstList) { if (!ArabicNameStrings.Contains(firstN) && firstN != null && firstN.Length > 0) { ArabicNameStrings.Add(firstN); } } var FatherList = await ArabicFatherNamesTask; foreach (var FatherN in FatherList) { if (!ArabicNameStrings.Contains(FatherN) && FatherN != null && FatherN.Length > 0) { ArabicNameStrings.Add(FatherN); } } var LastList = await ArabicLastNamesTask; foreach (var lastN in LastList) { if (!ArabicNameStrings.Contains(lastN) && lastN != null && lastN.Length > 0) { ArabicNameStrings.Add(lastN); } } NamesLoaded = true; var SicknessList = await SicknessNamesTask; foreach (var sickness in SicknessList) { if (sickness == null) { continue; } var sickNs = sickness.Split(new char[] { ';' }); foreach (var sickname in sickNs) { if (!SicknessNames.Contains(sickname) && sickname != null && sickname.Length > 0) { SicknessNames.Add(sickname); } } } var MedicenList = await MedicensNamesTask; foreach (var medicensString in MedicenList) { if (medicensString == null) { continue; } var medicensArray = medicensString.Split(new char[] { ';' }); foreach (var medicen in medicensArray) { if (!MedicenNames.Contains(medicen) && medicen != null && medicen.Length > 0) { MedicenNames.Add(medicen); } } } HealthLoaded = true; var EducationReasonsList = await EducationReasonsTask; foreach (var reason in EducationReasonsList) { if (!EducationReasons.Contains(reason) && reason != null && reason.Length > 0) { EducationReasons.Add(reason); } } var EducationSchoolsList = await EducationSchoolsTask; foreach (var school in EducationSchoolsList) { if (!EducationSchools.Contains(school) && school != null && school.Length > 0) { EducationSchools.Add(school); } } var EducationStagesList = await EducationStagesTask; foreach (var stage in EducationStagesList) { if (!EducationStages.Contains(stage) && stage != null && stage.Length > 0) { EducationStages.Add(stage); } } EducationLoaded = true; var BirthPlacesList = await BirthPlacesTask; foreach (var birthplace in BirthPlacesList) { if (!BirthPlaces.Contains(birthplace) && birthplace != null && birthplace.Length > 0) { BirthPlaces.Add(birthplace); } } OrphanDataLoaded = true; var countriesList = await CountriesTask; foreach (var country in countriesList) { if (!Countries.Contains(country) && country != null && country.Length > 0) { Countries.Add(country); } } var citiesList = await CitiesTask; foreach (var city in citiesList) { if (!Cities.Contains(city) && city != null && city.Length > 0) { Cities.Add(city); } } var townsList = await TownsTask; foreach (var town in townsList) { if (!Towns.Contains(town) && town != null && town.Length > 0) { Towns.Add(town); } } var streetsList = await StreetsTask; foreach (var street in streetsList) { if (!Streets.Contains(street) && street != null && street.Length > 0) { Streets.Add(street); } } AddressLoaded = true; DataLoaded?.Invoke(this, new EventArgs()); }