private static Tuple <string, string> GetCityAndCountryName(CityLocation cityLocation) { var city = string.Empty; var country = cityLocation.Country; if (!string.IsNullOrWhiteSpace(cityLocation.City)) { city = cityLocation.City; } else if (!string.IsNullOrWhiteSpace(cityLocation.AreaLevel2)) { city = cityLocation.AreaLevel2; } else if (!string.IsNullOrWhiteSpace(cityLocation.AreaLevel1)) { city = cityLocation.AreaLevel1; } else { city = country; } if (string.IsNullOrWhiteSpace(country)) { country = city; } return(new Tuple <string, string>(city, country)); }
/// <summary>Method used to activate all of the city UI, like merchants, inns, etc.</summary> /// <param name="city_">Reference to the CityLocation component that's being referenced</param> private void VisitCity(CityLocation city_) { //Activating the UI and the background UI blocker this.cityUI.cityPanelObject.SetActive(true); this.dungeonUI.dungeonPanelObject.SetActive(false); this.holyShrineUI.holyShrinePanelObject.SetActive(false); this.cursedShrineUI.cursedShrinePanelObject.SetActive(false); this.ambushUI.ambushPanelObject.SetActive(false); this.lootUI.lootPanelObject.SetActive(false); this.questUI.questPanelObject.SetActive(false); this.uiBlocker.SetActive(true); this.cityUI.nameplate.text = city_.locationName; //Setting only the inn's button to visible this.cityUI.innButton.enabled = true; this.cityUI.blacksmithButton.enabled = false; this.cityUI.merchantButton.enabled = false; this.cityUI.townHallButton.enabled = false; this.cityUI.stagecoachButton.enabled = false; //Displaying the inn menu this.cityUI.innObj.gameObject.SetActive(true); this.cityUI.innObj.OpenInnMenu(); this.cityUI.blacksmithObj.SetActive(false); this.cityUI.merchantObj.SetActive(false); this.cityUI.townHallObj.SetActive(false); this.cityUI.stagecoachObj.SetActive(false); }
private void SearchSpotsNear() { var deviceLocation = appStore.GetState().DeviceData?.LocationState.Value; if (deviceLocation == null) { return; } var distance = 25; var types = new List <PlaceType> { PlaceType.DIY, PlaceType.Skatepark, PlaceType.Skatespot }; var location = new CityLocation { Longitude = deviceLocation.Longitude, Latitude = deviceLocation.Latitude }; var criteria = new Criteria(types, location, distance); if (criteria == null) { return; } //TODO: Start downloading spots list. }
public CityLocation UpdateObject(CityLocation citylocation, ICountryLocationService _countrylocationService) { if (!isValid(_validator.VUpdateObject(citylocation, this, _countrylocationService))) { citylocation = _repository.UpdateObject(citylocation); } return(citylocation); }
public CityLocation VAbbrevation(CityLocation citylocation) { if (String.IsNullOrEmpty(citylocation.Abbrevation) || citylocation.Abbrevation.Trim() == "") { citylocation.Errors.Add("Abbrevation", "Tidak boleh kosong"); } return(citylocation); }
public void FindCurLocation() { try { this.curloc = CityLocation.GetCity(); } catch (Exception e) { this.noInternet = true; } }
public CityLocation CreateObject(CityLocation citylocation, ICountryLocationService _countrylocationService) { citylocation.Errors = new Dictionary <String, String>(); if (!isValid(_validator.VCreateObject(citylocation, this, _countrylocationService))) { citylocation.MasterCode = _repository.GetLastMasterCode(citylocation.OfficeId) + 1; citylocation = _repository.CreateObject(citylocation); } return(citylocation); }
public static CityLoc CastToCityLoc(CityLocation cityLocation) { var loc = new CityLoc(); loc.ShortName = cityLocation.CityLocShortName; loc.FullName = cityLocation.CityLocFullName; loc.CityLocationType = (CityLocationTypes)cityLocation.CityLocType; loc.CityLocationPoint.Lat = cityLocation.CityLocLat.ToString(); loc.CityLocationPoint.Lng = cityLocation.CityLocLng.ToString(); return(loc); }
public CityLocation VName(CityLocation citylocation, ICityLocationService _citylocationService) { if (String.IsNullOrEmpty(citylocation.Name) || citylocation.Name.Trim() == "") { citylocation.Errors.Add("Name", "Tidak boleh kosong"); } else if (_citylocationService.IsNameDuplicated(citylocation)) { citylocation.Errors.Add("Name", "Tidak boleh diduplikasi"); } return(citylocation); }
public Airport VCityLocation(Airport airport, ICityLocationService _citylocationservice) { CityLocation citylocation = _citylocationservice.GetObjectById(airport.CityLocationId); if (citylocation == null) { airport.Errors.Add("City", "Tidak boleh kosong"); } else if (VOffice(airport.OfficeId, citylocation.OfficeId)) { airport.Errors.Add("City", "Invalid City"); } return(airport); }
public CityLocation VCountryLocation(CityLocation citylocation, ICountryLocationService _countrylocationservice) { CountryLocation countrylocation = _countrylocationservice.GetObjectById(citylocation.CountryLocationId); if (countrylocation == null) { citylocation.Errors.Add("Country", "Tidak boleh kosong"); } else if (!VOffice(citylocation.OfficeId, countrylocation.OfficeId)) { citylocation.Errors.Add("Country", "Invalid Country"); } return(citylocation); }
public Contact VCity(Contact contact, ICityLocationService _citylocationService) { CityLocation citylocation = _citylocationService.GetObjectById(contact.CityId); if (citylocation == null) { contact.Errors.Add("City", "Tidak boleh kosong"); } else if (!VOffice(citylocation.OfficeId, contact.OfficeId)) { citylocation.Errors.Add("Country", "Invalid Country"); } return(contact); }
public CityLocation VObject(CityLocation citylocation, ICityLocationService _citylocationService) { CityLocation oldcitylocation = _citylocationService.GetObjectById(citylocation.Id); if (oldcitylocation == null) { citylocation.Errors.Add("Generic", "Invalid Data For Update"); } else if (!VOffice(citylocation.OfficeId, oldcitylocation.OfficeId)) { citylocation.Errors.Add("Generic", "Invalid Data For Update"); } return(citylocation); }
public async Task <IActionResult> Index(string city, string country) { var location = new CityLocation { City = city ?? "Phoenix, AZ", Country = country }; var currentConditions = await m_weatherService.GetCurrentConditionsAsync(location); return(View(new WeatherViewModel { City = currentConditions.City, Temperature = currentConditions.Temperature, Description = currentConditions.Description, })); }
public void TestGetWeather() { String apikey = "547974e171d5152e1889f080d28b1b0f"; OpenMapDataService.setApiKey(apikey); Location location = new CityLocation("Tel Aviv"); IWeatherDataService weather = new MockOpenMapDataService(); WeatherData data = weather.GetWeatherData(location); Assert.AreEqual(18.30, data.temp, 0.01); Assert.AreEqual(location, data.location); Assert.AreEqual(WeatherUnits.Celsius, data.unit); Assert.AreEqual(1.80, data.windSpeed, 0.01); }
public void TestGetWeatherForcast() { String apikey = "547974e171d5152e1889f080d28b1b0f"; OpenMapDataService.setApiKey(apikey); Location location = new CityLocation("Tel Aviv"); IWeatherDataService weather = new MockOpenMapDataService(); List <WeatherData> data = weather.GetWeatherForcast(location); Assert.AreEqual(2, data.Count); Assert.AreEqual(19.28, data[0].temp, 0.01); Assert.AreEqual(location, data[0].location); Assert.AreEqual(WeatherUnits.Celsius, data[0].unit); Assert.AreEqual(1.96, data[0].windSpeed, 0.01); }
public CityLocation VCreateObject(CityLocation citylocation, ICityLocationService _citylocationService, ICountryLocationService _countrylocationservice) { VName(citylocation, _citylocationService); if (!isValid(citylocation)) { return(citylocation); } VAbbrevation(citylocation); if (!isValid(citylocation)) { return(citylocation); } VCountryLocation(citylocation, _countrylocationservice); if (!isValid(citylocation)) { return(citylocation); } return(citylocation); }
public static void InitData() { string fileNamev4 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/GeoLite2-City-CSV_20171107/GeoLite2-City-Blocks-IPv4.csv"); string fileNamev6 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/GeoLite2-City-CSV_20171107/GeoLite2-City-Blocks-IPv6.csv"); string fileNamecloc = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/GeoLite2-City-CSV_20171107/GeoLite2-City-Locations-en.csv"); int idx = 0; if (_cityv4 == null || _cityv4.Count == 0) { _cityv4 = new List <CityIpV4>(); foreach (var line in File.ReadLines(fileNamev4)) { if (idx == 0) { idx++; continue; } _cityv4.Add(CityIpV4.FromCsv(line)); } //_cityv4 = File.ReadAllLines(fileNamev4) // .Skip(1) // .Select(v => CityIpV4.FromCsv(v)) // .ToList(); } idx = 0; if (_cityv6 == null || _cityv6.Count == 0) { _cityv6 = new List <CityIpV6>(); foreach (var line in File.ReadLines(fileNamev6)) { if (idx == 0) { idx++; continue; } _cityv6.Add(CityIpV6.FromCsv(line)); } //_cityv6 = File.ReadAllLines(fileNamev6) // .Skip(1) // .Select(v => CityIpV6.FromCsv(v)) // .ToList(); } idx = 0; if (_cityloc == null || _cityloc.Count == 0) { _cityloc = new List <CityLocation>(); foreach (var line in File.ReadLines(fileNamecloc)) { if (idx == 0) { idx++; continue; } _cityloc.Add(CityLocation.FromCsv(line)); } //_cityloc = File.ReadAllLines(fileNamecloc) // .Skip(1) // .Select(v => CityLocation.FromCsv(v)) // .ToList(); } }
public NewGameAction(GameInstance instance, ulong playerId) : base("New Game", "Welcome to Discordia, please choose an option. " + "You may restart a menu with the restart button. " + "Once you have selected all options you will be given the continue button.", null, null) { GameObject playerBody = new GameObject("", "", new PhysicalMeta(), newCharacter, playerId); string[] attribNames = new string[] { "Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma" }; // --- [ Class selection frame ] --- setClass.Frame = new Frame ( "Pick a class.", "Pick one of the following classes:", new List <GameAction>() { new CreateSpecificClassAction <ClassFighter>("Fighter", "The path of Might", null), //TODO: Make an IDescribible which has GetName(), and GetDesc() new CreateSpecificClassAction <ClassMage>("Mage", "The path of Knowledge", null), // this will clear up significant save bloat among other things. new CreateSpecificClassAction <ClassRogue>("Rogue", "The path of Shadows", null) } ); setClass.PreFramePopped += () => { foreach (CreateClassAction a in setClass.Frame.Actions) { if (a.Class != null) { newCharacter.Class = a.Class; break; } } int[] vals = GetAttributeAmounts(); for (int i = 0; i < attribNames.Length; i++) { setAttributes.Frame.Actions[i].Name = String.Format("{0} : [{1}]", attribNames[i], vals[i]); } }; // --- [ Attribute allocation frame ] --- setAttributes.PreFramePushed += () => { setAttributes.Frame.Desc = GetAttributeCountString(); int[] vals = GetAttributeAmounts(); for (int i = 0; i < attribNames.Length; i++) { setAttributes.Frame.Actions[i].Name = String.Format("{0} : [{1}]", attribNames[i], vals[i]); } }; setAttributes.Frame = new Frame ( "Distribute Attributes", "", new List <GameAction>() { new ImproveSpecificAttributeAction <StrengthAttribute>( attribNames[0], "The physical manifestation of will.", null, () => newCharacter.Class ), new ImproveSpecificAttributeAction <DexterityAttribute>( attribNames[1], "The nible control of flesh.", null, () => newCharacter.Class ), new ImproveSpecificAttributeAction <ConstitutionAttribute>( attribNames[2], "The endurance of the shell.", null, () => newCharacter.Class ), new ImproveSpecificAttributeAction <IntelligenceAttribute>( attribNames[3], "The fortress of thought", null, () => newCharacter.Class ), new ImproveSpecificAttributeAction <WisdomAttribute>( attribNames[4], "The accumulative experience of life.", null, () => newCharacter.Class ), new ImproveSpecificAttributeAction <CharismaAttribute>( attribNames[5], "The connection to other minds.", null, () => newCharacter.Class ) }, true, () => newCharacter.Class.AttributePoints > 0 ); // Grab all cities from the first planet, first continent CityLocation[] cities = instance.GetLocations <CityLocation>(instance.GetFromIndexAtTopLevel <LocationConceptual>(0).SubLocations[0]); List <SelectSpecificLocationAction <CityLocation> > selectCityActions = new List <SelectSpecificLocationAction <CityLocation> >(); selectedCity = null; foreach (CityLocation c in cities) { selectCityActions.Add(new SelectSpecificLocationAction <CityLocation>(c.Name, c.Desc, null, c, (l) => selectedCity = l as CityLocation)); } // --- [ Background Frame ] --- setBackground.Frame = new Frame( "Background", "Select a place of origin.", new List <GameAction>(selectCityActions) ); bool restart = false; // --- [ Restart Frame ] --- restartProcess.Frame = new Frame( "Restart?", "Would you like to restart? You will lose all progress.", new List <GameAction>(new AcceptDeclineActionPair( (b) => restart = b, (b) => restart = b ).ActionPair) ); restartProcess.PreFramePopped += () => { if (restart) { RestartPushing(); } else { instance.AddGameObject(playerBody); newCharacter.PossessGameObject(playerBody); } }; // --- [ Init pushed frame array ] --- PushedFrames = new FrameMeta[] { //setClass, //setAttributes, setBackground, restartProcess }; }
public bool isValid(CityLocation obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
//Function called from EnterTileLocation to display the correct city UI private void DisplayCityUI(CityLocation city_) { this.playerTileLocation.TravelToLocation(); this.cityUICanvas.SetActive(true); //Looping through each of the vendors in the city foreach (Vendor cityVendor in city_.cityVendors) { //Activating the correct vendor UI based on this vendor's type switch (cityVendor.type) { case VendorTypes.GenderalStore: if (!this.generalStoreUI.enabled) { this.generalStoreUI.enabled = true; this.generalStoreName.text = cityVendor.buildingName; } break; case VendorTypes.Blacksmith: if (!this.blacksmithUI.enabled) { this.blacksmithUI.enabled = true; this.blacksmithName.text = cityVendor.buildingName; } break; case VendorTypes.Tavern: if (!this.tavernUI.enabled) { this.tavernUI.enabled = true; this.tavernName.text = cityVendor.buildingName; } break; case VendorTypes.MageTower: if (!this.mageTowerUI.enabled) { this.mageTowerUI.enabled = true; this.mageTowerName.text = cityVendor.buildingName; } break; case VendorTypes.Church: if (!this.churchUI.enabled) { this.churchUI.enabled = true; this.churchName.text = cityVendor.buildingName; } break; case VendorTypes.DarkTemple: if (!this.darkTempleUI.enabled) { this.darkTempleUI.enabled = true; this.darkTempleName.text = cityVendor.buildingName; } break; case VendorTypes.Castle: if (!this.castleUI.enabled) { this.castleUI.enabled = true; this.castleName.text = cityVendor.buildingName; } break; } } }
public bool IsNameDuplicated(CityLocation citylocation) { return(_repository.IsNameDuplicated(citylocation)); }
JsonResult GetIpv4(string inip, string ip) { App_Start.GeoipContext.InitData(); CityLocation ty = null; CityIpV4 ty1 = new CityIpV4(); IPAddress incomingIp = IPAddress.Parse(ip); DateTime strt = DateTime.UtcNow; var lst = App_Start.GeoipContext._cityv4.FindAll(t => t.network.StartsWith(ip)); if (lst.Count == 0) { var srch = ip.Remove(ip.LastIndexOf('.') + 1); lst = App_Start.GeoipContext._cityv4.FindAll(t => t.network.StartsWith(srch)); } if (lst.Count == 0) { var srch = ip.Split('.')[0] + "." + ip.Split('.')[1]; lst = App_Start.GeoipContext._cityv4.FindAll(t => t.network.StartsWith(srch)); } if (lst.Count == 0) { var srch = ip.Split('.')[0]; lst = App_Start.GeoipContext._cityv4.FindAll(t => t.network.StartsWith(srch)); } if (lst.Count == 0) { lst = App_Start.GeoipContext._cityv4; } foreach (var row in lst) { IPNetwork network = IPNetwork.Parse(row.network); if (IPNetwork.Contains(network, incomingIp)) { Console.WriteLine(row.postal_code); ty1 = row; ty = App_Start.GeoipContext._cityloc.Find(t => t.geoname_id == row.geoname_id); if (ty != null) { Console.WriteLine(ty.ToString()); } continue; } } DateTime end = DateTime.UtcNow; if (ty == null) { return(Json(new { Inip = inip, Message = "No data found" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Inip = inip, Network = ty1, Address = ty, Start = strt.ToString(), End = end.ToString(), type = "IPv4" }, JsonRequestBehavior.AllowGet)); } }
public CityLocation SoftDeleteObject(CityLocation citylocation) { citylocation = _repository.SoftDeleteObject(citylocation); return(citylocation); }
//Function called externally from UI buttons to display the vendor screen public void DisplayVendor(int typeOfVendor_) { //Reference to the vendor that we're going to display Vendor vendorToDisplay = null; //Getting the vendor type enum from the int given (since unity can't have enums as variables in UnityEvents) VendorTypes vendorToVisit = VendorTypes.GenderalStore; switch (typeOfVendor_) { case 0: vendorToVisit = VendorTypes.GenderalStore; break; case 1: vendorToVisit = VendorTypes.Blacksmith; break; case 2: vendorToVisit = VendorTypes.Tavern; break; case 3: vendorToVisit = VendorTypes.MageTower; break; case 4: vendorToVisit = VendorTypes.Church; break; case 5: vendorToVisit = VendorTypes.DarkTemple; break; case 6: vendorToVisit = VendorTypes.Castle; break; default: vendorToVisit = VendorTypes.GenderalStore; break; } //Looping through each of the vendors on this location CityLocation city = this.playerTileLocation as CityLocation; foreach (Vendor v in city.cityVendors) { //If the current vendor's type matches the one we're looking for, it's the one we display if (v.type == vendorToVisit) { vendorToDisplay = v; break; } } //If the city doesn't have that type of vendor, nothing happens (this SHOULDN'T happen, but just in case) if (vendorToDisplay == null) { return; } //Telling the vendor panel UI which vendor we're displaying VendorPanelUI.globalReference.vendorToDisplay = vendorToDisplay; //Turning the vendor canvas object on this.vendorUICanvas.SetActive(true); }