/* @"<response> <version>0.1</version> <current_observation> <display_location> <city>Moscow</city> </display_location> <temp_c>-2</temp_c> <relative_humidity>93%</relative_humidity> <pressure_mb>1016</pressure_mb> </current_observation> </response>"; */ public override Weather Parse(string str) { try { var xdoc = XDocument.Parse(str); var ver = xdoc.XPathSelectValue("/response/version/text()"); if (ver != "0.1") { throw new FormatException("Version incompatibility (not equal 0.1)"); } var weather = new Weather(); var rootPrefix = "/response/current_observation"; var tempStr = xdoc.XPathSelectValue(rootPrefix + "/temp_c/text()"); weather.TemperatureC = float.Parse(tempStr); var humidityStr = xdoc.XPathSelectValue(rootPrefix + "/relative_humidity/text()"); humidityStr = humidityStr.Replace("%", ""); weather.HumidityPct = float.Parse(humidityStr) / 100; var presStr = xdoc.XPathSelectValue(rootPrefix + "/pressure_mb/text()"); weather.PressureMB = float.Parse(presStr); return weather; } catch (Exception e) { throw new ParseException("Wunderground service response parse error", e); } }
private static int CalcScore(IPlayerState state, Weather weather, int maxCard) { // winter -> drummer -> spring // winter makes everything worth 1 // spring makes the global largest card worth +3 // sum the normal cards & apply winter var score = state.Desk .Where(card => !card.IsSpecial && card.HasValue) .Sum(card => weather == Weather.Winter ? 1 : card.Value); if (IsDebugEnabled) log.Debug("Value card sum: " + score); // drummer if (state.Desk.FirstOrDefault(c => c.Kind == CardType.Drummer) != null) { score *= 2; if (IsDebugEnabled) log.Debug("With drummer: " + score); } // spring if (weather == Weather.Spring) { // apply spring var maxCardNum = state.Desk .Where(card => !card.IsSpecial && card.HasValue && card.Value == maxCard) .Count(); score += maxCardNum * 3; if (IsDebugEnabled) { log.Debug("Found {0} cards with maxValue {1}", maxCardNum, maxCard); log.Debug("With spring: " + score); } } // special value cards (modifiers do not apply) score += state.Desk.Where(c => c.IsSpecial && c.HasValue).Sum(c => c.Value); if (IsDebugEnabled) { log.Debug("With specials: " + score); log.Debug("Scoring done."); } return score; }
// Use this for initialization void Start () { waterZones = GameObject.FindGameObjectsWithTag("InteractableWater"); currentWeather = Weather.CLEAR; day = true; skybox = RenderSettings.skybox; skybox.SetFloat("_DayToNight", 0f); skybox.SetFloat("_RainToSnow", 0f); skybox.SetFloat("_NormalToRainSnow", 0f); skybox.SetFloat("_RainSnowToSpecial", 0f); mainLight = FindObjectOfType<Light>(); foreach (Material m in materials) { m.SetFloat("_Snow", 0f); } rain = GameObject.Find("PS_Rain"); snow = GameObject.Find("PS_Snowflakes"); other = GameObject.Find("PS_weather"); rain.SetActive(false); snow.SetActive(false); other.SetActive(false); tM = FindObjectOfType<TrackManager>(); SetAurore(false); }
public WeatherReply(WeatherQuery query, Weather weather, DateTime replyTime, Exception exception = null) { Query = query; Weather = weather; ReplyTime = replyTime; Exception = exception; }
public Ball(Game game, Weather weather) : base(game) { //size = texture.Width; Size = 15; Shot = false; Pass = false; FreeKick = true; //set the initial position and acceleration Reset(); //bound box rectangle Rectangle = new Rectangle((int)Position.X, (int)Position.Y, Size, Size); //current player who has the ball CurrentPlayer = null; switch (weather) { case Weather.sunny: frictionFactor = 0.9f; break; case Weather.rainy: frictionFactor = 2.0f; break; } }
public override Weather Parse(string str) { try { var serializer = new XmlSerializer(typeof(OpenWeatherMapResponse)); OpenWeatherMapResponse owmResponse; using (var strReader = new StringReader(str)) { owmResponse = (OpenWeatherMapResponse)serializer.Deserialize(strReader); } if (owmResponse.Humidity.unit != "%" && owmResponse.Pressure.unit != "hPa" && owmResponse.Temperature.unit != "metric") { throw new FormatException("Value invalid unit"); } var weather = new Weather() { HumidityPct = owmResponse.Humidity.value / 100, TemperatureC = owmResponse.Temperature.value, PressureMB = owmResponse.Pressure.value, }; return weather; } catch (Exception e) { throw new ParseException("OpenWeatherMap service response parse error", e); } }
public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds ) { for ( int i = 0; i < m_Facets.Length; ++i ) { Rectangle2D area = new Rectangle2D(); bool isValid = false; for ( int j = 0; j < 10; ++j ) { area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height ); if ( !CheckWeatherConflict( m_Facets[i], null, area ) ) isValid = true; if ( isValid ) break; } if ( !isValid ) continue; Weather w = new Weather( m_Facets[i], new Rectangle2D[]{ area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) ); w.m_Bounds = bounds; w.m_MoveSpeed = moveSpeed; } }
private readonly PokemonOutward[] pokemons; //onBoardOnly #endregion Fields #region Constructors /// <summary> /// 为了节约流量,只在用户第一次进入房间的时候给出teams/pms/weather信息 /// </summary> internal Turn(TeamOutward[] teams, PokemonOutward[] pms, Weather weather) { Teams = teams; pokemons = pms; Weather = weather; Events = new List<GameEvent>(); }
public WeatherData(WeatherData data) { mType = data.mType; mTemp = data.mTemp; mLength = data.mLength; mWeight = data.mWeight; }
public List<Weather> getAllWithTags() { try { List<Weather> weathers = new List<Weather>(); ISession session = cluster.Connect("maltmusic"); String todo = ("select * from weathertags"); PreparedStatement ps = session.Prepare(todo); BoundStatement bs = ps.Bind(); // Execute Query RowSet rows = session.Execute(bs); foreach (Row row in rows) { Guid tid = (Guid) row["track_id"]; List<String> theSet = (List<String>)row["tags"]; Weather toadd = new Weather(tid, theSet); weathers.Add(toadd); } return weathers; } catch (Exception e) { Console.WriteLine("Broken returning weather tags " + e); return null; } }
public SettingsMenu(Weather weather, ScreenManager screenManager) { this.weather = weather; this.screenManager = screenManager; btnBack = new Button("Buttons", new Vector2(600, 400), new Rectangle(0, 120 * 6, 250, 120), false, false); btnChangeWeather = new Button("Buttons", new Vector2(200, 200), new Rectangle(250, 120 * 1, 250, 120), false, false); btnChangePlayer = new Button("Buttons", new Vector2(200, 400), new Rectangle(250, 120 * 0, 250, 120), false, false); LoadContent(); }
public WeatherMenu(ScreenManager screenManager, Weather weather) { this.screenManager = screenManager; this.weather = weather; btnBack = new Button("Buttons", new Vector2(600, 400), new Rectangle(0, 120 * 6, 250, 120), false, false); btnSunny = new Button("Buttons", new Vector2(200, 100), new Rectangle(250, 120 * 2, 250, 120), false, false); btnCloudy = new Button("Buttons", new Vector2(500, 100), new Rectangle(250, 120 * 3, 250, 120), false, false); btnRainy = new Button("Buttons", new Vector2(200, 300), new Rectangle(250, 120 * 4, 250, 120), false, false); }
public bool CanGetForecast() { Weather weather = new Weather(); string xmlData = weather.GetForecast(ZipCode); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlData); XmlNode errorMessageNode = xmlDoc.SelectSingleNode("/errorMessage"); bool hasError = (errorMessageNode != null); return !hasError; }
public static RandomEvent Create(int day, Weather weather) { if (weather == Weather.Cloudy) return CloudyEvent(); if (weather == Weather.HotAndDry) return HotAndDryEvent(); return SunnyEvent(day); }
public static void endOfTurn() { if (weather != Weather.normal) { weatherDur--; if (weatherDur <= 0) { weather = Weather.normal; } } }
public Board(GameSettings settings) { mode = settings.Mode; weather = Data.Weather.Normal; terrain = settings.Terrain; pokemons = new OnboardPokemon[settings.TeamCount, settings.XBound]; Pokemons = new List<OnboardPokemon>(); BoardConditions = new ConditionsDictionary(); FieldConditions = new ConditionsDictionary[settings.TeamCount]; for (int i = 0; i < settings.TeamCount; i++) FieldConditions[i] = new ConditionsDictionary(); }
public Form1() { CL = new List<City>(); var converter = new XmlSerializer(typeof(List<City>)); var file = File.OpenText(".\\Cityes"); CL = (List<City>)converter.Deserialize(file); file.Close(); W = new Weather(); button1 = new Button(); InitializeComponent(); Voice = new System.Speech.Synthesis.SpeechSynthesizer(); this.Voice.SpeakCompleted += new System.EventHandler<System.Speech.Synthesis.SpeakCompletedEventArgs>(Comp); }
public void SetWeather(Weather w) { currentWeather = w; secondsPassed = 0; if (weather) Destroy (weather); if (w == Weather.Sunny) Sunny (); else if (w == Weather.Rainy) Rainy (); else if (w == Weather.Cloudy) Cloudy (); }
void Awake() { { if (weather == null) { DontDestroyOnLoad(gameObject); weather = this; } else if (weather != this) { Destroy(gameObject); } } weatherVectorSpritePairs = new Hashtable(); weatherVectorSpritePairs.Add(new Vector2(-2, 2), acidRain); weatherVectorSpritePairs.Add(new Vector2(-1, 2), heavyMist); weatherVectorSpritePairs.Add(new Vector2(0, 2), scorching); weatherVectorSpritePairs.Add(new Vector2(1, 2), drought); weatherVectorSpritePairs.Add(new Vector2(2, 2), sandstorm); weatherVectorSpritePairs.Add(new Vector2(-2, 1), hurricane); weatherVectorSpritePairs.Add(new Vector2(-1, 1), warmRain); weatherVectorSpritePairs.Add(new Vector2(0, 1), warm); weatherVectorSpritePairs.Add(new Vector2(1, 1), heatWave); weatherVectorSpritePairs.Add(new Vector2(2, 1), arid); weatherVectorSpritePairs.Add(new Vector2(-2, 0), downpour); weatherVectorSpritePairs.Add(new Vector2(-1, 0), rain); weatherVectorSpritePairs.Add(new Vector2(0, 0), neutral); weatherVectorSpritePairs.Add(new Vector2(1, 0), dry); weatherVectorSpritePairs.Add(new Vector2(2, 0), desert); weatherVectorSpritePairs.Add(new Vector2(-2, -1), hail); weatherVectorSpritePairs.Add(new Vector2(-1, -1), snow); weatherVectorSpritePairs.Add(new Vector2(0, -1), cooler); weatherVectorSpritePairs.Add(new Vector2(1, -1), frosting); weatherVectorSpritePairs.Add(new Vector2(2, -1), icing); weatherVectorSpritePairs.Add(new Vector2(-2, -2), blizzard); weatherVectorSpritePairs.Add(new Vector2(-1, -2), snowStorm); weatherVectorSpritePairs.Add(new Vector2(-0, -2), freezing); weatherVectorSpritePairs.Add(new Vector2(1, -2), frozen); weatherVectorSpritePairs.Add(new Vector2(2, -2), iceStorm); }
private string ParseResult(Weather weather) { if(weather.current_observation != null) { CurrentObservation o = weather.current_observation; DisplayLocation d = o.display_location; string result = string.Format("Weather for {0}{1}: {2}, {3}", d.full, (d.zip != null ? " (" + d.zip + ")" : ""), o.weather, o.temperature_string); result += string.Format("; feels like {0}. {1} winds. {2} humidity", o.feelslike_string, o.wind_string, o.relative_humidity); if(o.precip_today_metric != null) { result += string.Format("; {0} precipitation today", o.precip_today_string); } return string.Format("{0}. {1}\n{2}", result, o.observation_time, o.forecast_url); } return null; }
internal BoardOutward(GameSettings settings) { this.settings = settings; teams = new ObservableCollection<PokemonOutward>[settings.TeamCount]; Teams = new ReadOnlyObservableCollection<PokemonOutward>[settings.TeamCount]; pokemons = new List<PokemonOutward>(); weather = Data.Weather.Normal; Terrain = settings.Terrain; var empty = new PokemonOutward[settings.XBound]; for (int i = 0; i < settings.TeamCount; i++) { teams[i] = new ObservableCollection<PokemonOutward>(empty); Teams[i] = new ReadOnlyObservableCollection<PokemonOutward>(teams[i]); } listeners = new List<IBoardEvent>(); }
public ScreenManager(ContentManager content, GraphicsDeviceManager graphics) { // TODO: Construct any child components here serverHandler = new ServerHandler(); weather = new Weather(); mainScene = new MainScene(content, graphics); loadingScreen = new LoadingScreen(); mainMenu = new MainMenu(content.Load<SpriteFont>("Fonts\\menufont")); highScores = new HighScores(serverHandler); settingsMenu = new SettingsMenu(weather, this); pauseMenu = new PauseMenu(); deadScreen = new DeadScreen(this); weatherMenu = new WeatherMenu(this, weather); CurrentWeather = weather.WeatherForecast; }
public Weather GetCityWeather(string city) { WebUtility.UrlEncode(city); string requestUrl = string.Format(url, city, apiKey); string response = WebHelper.GetResponseString(requestUrl); Weather result = null; try { WeatherResponse weatherResponse = JsonConvert.DeserializeObject<WeatherResponse>(response); result = new Weather() { City = weatherResponse.Name, Description = weatherResponse.Weather.First().Description, Temperature = weatherResponse.Main.Temp }; } catch { } return result; }
public ExpandableDataAdapter( Weather.WeatherData newWeather) : base() { WeatherData = newWeather; var dailyWeather = new List<Weather.ServerWeather> (); foreach (var daily in newWeather.data.weather) { dailyWeather.Add (daily); } DailyWeather = dailyWeather; var hourlyWeather = new List<Weather.HourlyWeather> (); foreach (var daily in DailyWeather) { foreach (var hourly in daily.hourly) { hourlyWeather.Add (hourly); } } HourlyWeather = hourlyWeather; }
public void Parse(string source) { var data = JsonObject.Parse(source); var sys = data.GetNamedObject("sys"); var main = data.GetNamedObject("main"); var weather = data.GetNamedArray("weather"); var sunriseValue = sys.GetNamedNumber("sunrise", 0); Sunrise = UnixTimeStampToDateTime(sunriseValue).TimeOfDay; var sunsetValue = sys.GetNamedNumber("sunset", 0); Sunset = UnixTimeStampToDateTime(sunsetValue).TimeOfDay; var situationValue = weather.First().GetObject().GetNamedValue("id"); Weather = new OpenWeatherMapWeatherSituationParser().Parse(situationValue); Temperature = (float) main.GetNamedNumber("temp", 0); Humidity = (float) main.GetNamedNumber("humidity", 0); }
protected WeatherInfo GetForecast(int days, int zipCode) { Weather[] forecast = new Weather[days]; Random rand = new Random(zipCode + DateTime.Today.DayOfYear); for (int i = 0; i < days; i++) { Weather weather = (Weather)(rand.Next() % 4); forecast[i] = weather; } WeatherInfo weatherInfo = new WeatherInfo { Forecast = forecast, Observatory = OperationContext.Current.EndpointDispatcher.ChannelDispatcher.Listener.Uri.AbsoluteUri }; // Uncomment it to verify load balancing // System.Threading.Thread.Sleep(3 * 1000); return weatherInfo; }
public WeatherFactory() { Weathers = new List<Weather>(); WeatherZoneFactory = new WeatherZoneFactory(); WeatherProbabilityFactory = new WeatherProbabilityFactory(); Uri uri = new Uri(Constants.WeatherDataPath, UriKind.Relative); XElement applicationXml; StreamResourceInfo xmlStream = Application.GetResourceStream(uri); applicationXml = XElement.Load(xmlStream.Stream); var data = from wz in applicationXml.Descendants("Weather") select wz; Weather weather = null; foreach (var d in data) { weather = new Weather(); weather.WeatherId = (Int32)d.Element("WeatherId"); weather.WeatherDescription = (String)d.Element("WeatherDescription"); Weathers.Add(weather); } }
public Match(Game game, Team homeTeam, Team awayTeam, CameraType cameraType, Difficulty difficulty, Weather weather, int duration, bool player2Cpu) : base(game) { CameraType = cameraType; Difficulty = difficulty; Weather = weather; Duration = duration; HomeTeam = homeTeam; AwayTeam = awayTeam; AwayTeam.IsHomeTeam = false; Player1Index = 0; Player2Index = 0; Player2Cpu = player2Cpu; Scenario = new Scenario2D(Game); Scenario2DPainter = new Scenario2DPainter(Game.GraphicsDevice, Scenario); timer = -1; Pause = false; DisplayRadar = true; hold = true; KickOff = true; KickOffStart = true; HomeTeamStart = true; FreeKickStart = false; TmpTeam = null; Ball = new Ball(game, Weather); Field = new Field(game); Panel = new Panel(game); //passing MaxPassSpeed = 800; MaxErrorAngle = 15; PerfectPassFactor = 2.8f; Rand = new Random(); Audience = new Song[3]; }
public void AdjustWeather(Weather weather){ this.weather = weather; switch (this.weather) { case Weather.Sun: weatherTex.mainTexture = Resources.Load<Texture>("Weather/Sun"); break; case Weather.Snow: weatherTex.mainTexture = Resources.Load<Texture>("Weather/Snow"); break; case Weather.Night: weatherTex.mainTexture = Resources.Load<Texture>("Weather/Night"); break; case Weather.LightRain: weatherTex.mainTexture = Resources.Load<Texture>("Weather/LightRain"); break; case Weather.Cloudy: weatherTex.mainTexture = Resources.Load<Texture>("Weather/Cloudy"); break; case Weather.ThunderRain: weatherTex.mainTexture = Resources.Load<Texture>("Weather/ThunderRain"); break; } }
public Customer(Weather weather, float price, Player player, Stand stand) { if (player.PlayerName != "Tad from Prep School" && stand.location != "The Hamptons") { this.weatherDemand = weather.DemandLevel; if (price <= levelOneBuyPrice) { buyChance = (levelOneBuyChance); } else if (price <= levelTwoBuyPrice) { buyChance = (levelTwoBuyChance); } else if (price <= levelThreeBuyPrice) { buyChance = (levelThreeBuyChance); } else if (price <= levelFourBuyPrice) { buyChance = (levelFourBuyChance); } else if (price <= levelFiveBuyPrice) { buyChance = (levelFiveBuyChance); } else { buyChance = (defaultBuyChance); } } else { buyChance = guaranteedBuy; } }
void ChangeWeather() { float par; if (numWeather == 0) { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } else { switch (minute) { case 0: { if (numWeather == 1) { par = Random.Range(0.0f, 1.0f); if (par < 0.1f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } else if (numWeather >= 2) { par = Random.Range(0.0f, 1.0f); if (par < 0.2f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } break; } case 1: { if (numWeather == 1) { par = Random.Range(0.0f, 1.0f); if (par < 0.15f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } else if (numWeather >= 2) { par = Random.Range(0.0f, 1.0f); if (par < 0.3f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } break; } case 2: { if (numWeather == 1) { par = Random.Range(0.0f, 1.0f); if (par < 0.25f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } else if (numWeather >= 2) { par = Random.Range(0.0f, 1.0f); if (par < 0.4f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } break; } case 3: { if (numWeather == 1) { par = Random.Range(0.0f, 1.0f); if (par < 0.4f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } else if (numWeather >= 2) { par = Random.Range(0.0f, 1.0f); if (par < 0.5f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } break; } case 4: { par = Random.Range(0.0f, 1.0f); if (par < 0.6f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } break; } default: { if (numWeather == 1) { par = Random.Range(0.0f, 1.0f); if (par < 0.7f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } else if (numWeather == 2) { par = Random.Range(0.0f, 1.0f); if (par < 0.75f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } else if (numWeather == 3) { par = Random.Range(0.0f, 1.0f); if (par < 0.8f) { CullWeatherType(); } else { NowWeather = Weather.SUN; nowWeathers = PlayerCharacterController.WeatherState.Sunny; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; } } break; } } } ActiveWeather(); }
double IELoadCode.P4(AbstractWire conductor, Weather weather, LoadType loadType, double L) { return(this.αE(weather.BasicWindSpeed) * weather.WindPress * this.μsc(conductor.Diameter, weather.IceThickness) * (conductor.Diameter + 2 * weather.IceThickness) * this.B1(weather.IceThickness)); }
/// <summary> /// Handles presses of the "ok" button /// Attempts to retrieve the indicated soil description and put it in place of the original soil. /// Closes the dialog if successful /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="e">Event arguments</param> private void BtnOk_Clicked(object sender, EventArgs e) { try { if (!CheckValue(entryLatitude) || !CheckValue(entryLongitude)) { return; } if (String.IsNullOrWhiteSpace(entryFilePath.Text)) { ShowMessage(MessageType.Warning, "You must provide a file name for saving the weather data", "No file path"); BtnBrowse_Clicked(this, null); return; } string newWeatherPath = null; WaitCursor = true; try { if (radioSiloDataDrill.Active) { newWeatherPath = GetDataDrill(); } else if (radioSiloPatchPoint.Active) { newWeatherPath = GetPatchPoint(); } else if (radioNASA.Active) { newWeatherPath = GetNasaChirps(); } } finally { WaitCursor = false; } if (string.IsNullOrWhiteSpace(newWeatherPath)) { ShowMessage(MessageType.Error, "Unable to obtain data for this site", "Error"); } else { if (dest is Weather) { // If there is an existing Weather model (and there usually will be), is it better to replace // the model, or modify the FullFileName of the original? IPresenter currentPresenter = explorerPresenter.CurrentPresenter; if (currentPresenter is MetDataPresenter) { (currentPresenter as MetDataPresenter).OnBrowse(newWeatherPath); } else { explorerPresenter.CommandHistory.Add(new UserInterface.Commands.ChangeProperty(dest, "FullFileName", newWeatherPath)); } } else if (dest is Simulation) { Weather newWeather = new Weather(); newWeather.FullFileName = newWeatherPath; var command = new AddModelCommand(replaceNode, newWeather, explorerPresenter.GetNodeDescription); explorerPresenter.CommandHistory.Add(command, true); } } dialog1.Dispose(); } catch (Exception err) { ShowMessage(MessageType.Error, err.Message, "Error"); } }
public async Task <IActionResult> Weather(string zip) { Weather weather = await wd.GetWeather(zip); return(View(weather)); }
private static Modifier Move(DefContext def) { var der = def.Defender; var atk = def.AtkContext; var move = atk.Move.Id; Modifier m = 0x1000; switch (move) { case Ms.FUSION_FLARE: //558 { var b = der.Controller.Board; b.SetTurnCondition(Cs.Fusion); var o = b.GetCondition(Cs.LastMove); if (o != null && o.Move.Id == Ms.FUSION_BOLT && b.HasCondition(Cs.Fusion)) { m = 0x2000; } } break; case Ms.FUSION_BOLT: //559 { var b = der.Controller.Board; b.SetTurnCondition(Cs.Fusion); var o = b.GetCondition(Cs.LastMove); if (o != null && o.Move.Id == Ms.FUSION_FLARE && b.HasCondition(Cs.Fusion)) { m = 0x2000; } } break; case Ms.FACADE: //263 if (atk.Attacker.State != PokemonState.Normal && atk.Attacker.State != PokemonState.FRZ) { m = 0x2000; } break; case Ms.BRINE: //362 if (der.Hp << 1 <= der.Pokemon.MaxHp) { m = 0x2000; } break; case Ms.VENOSHOCK: //474 if (atk.Attacker.State == PokemonState.PSN && atk.Attacker.State == PokemonState.BadlyPSN) { m = 0x2000; } break; case Ms.RETALIATE: //514 if (atk.Attacker.Field.GetCondition <int>(Cs.FaintTurn) == der.Controller.TurnNumber - 1) { m = 0x2000; } break; } if (atk.HasCondition(Cs.MeFirst)) { m *= 0x1800; } switch (move) { case Ms.SOLAR_BEAM: Weather w = def.Defender.Controller.Weather; if (w != Weather.IntenseSunlight && w != Weather.Normal) { m *= 0x800; } break; case Ms.EARTHQUAKE: case Ms.BULLDOZE: case Ms.MAGNITUDE: if (der.Controller.Board.HasCondition(Cs.GrassyTerrain)) { m *= 0x800; } break; } return(m); }
public RLFeatures(Weather weather, DayOfWeek day) { Weather = weather; DayOfWeek = day; }
public MainPage() { InitializeComponent(); BindingContext = new Weather(); }
public void Render(double deltaTime) { Weather weather = map.Env.Weather; if (weather == Weather.Sunny) { return; } if (heightmap == null) { InitHeightmap(); } gfx.BindTexture(weather == Weather.Rainy ? RainTexId : SnowTexId); Vector3 camPos = game.CurrentCameraPos; Vector3I pos = Vector3I.Floor(camPos); bool moved = pos != lastPos; lastPos = pos; WorldEnv env = game.World.Env; float speed = (weather == Weather.Rainy ? 1.0f : 0.2f) * env.WeatherSpeed; float vOffset = (float)game.accumulator * speed; rainAcc += deltaTime; bool particles = weather == Weather.Rainy; int index = 0; FastColour col = game.World.Env.Sunlight; VertexP3fT2fC4b v = default(VertexP3fT2fC4b); for (int dx = -extent; dx <= extent; dx++) { for (int dz = -extent; dz <= extent; dz++) { int x = pos.X + dx, z = pos.Z + dz; float y = RainHeight(x, z); float height = Math.Max(game.World.Height, pos.Y + 64) - y; if (height <= 0) { continue; } if (particles && (rainAcc >= 0.25 || moved)) { game.ParticleManager.AddRainParticle(new Vector3(x, y, z)); } float alpha = AlphaAt(dx * dx + dz * dz); Utils.Clamp(ref alpha, 0, 0xFF); col.A = (byte)alpha; // NOTE: Making vertex is inlined since this is called millions of times. v.Colour = col.Pack(); float worldV = vOffset + (z & 1) / 2f - (x & 0x0F) / 16f; float v1 = y / 6f + worldV, v2 = (y + height) / 6f + worldV; v.X = x; v.Y = y; v.Z = z; v.U = 0; v.V = v1; vertices[index++] = v; // (x, y, z) (0, v1) v.Y = y + height; v.V = v2; vertices[index++] = v; // (x, y + height, z) (0, v2) v.X = x + 1; v.Z = z + 1; v.U = 1; vertices[index++] = v; // (x + 1, y + height, z + 1) (1, v2) v.Y = y; v.V = v1; vertices[index++] = v; // (x + 1, y, z + 1) (1, v1) v.Z = z; vertices[index++] = v; // (x + 1, y, z) (1, v1) v.Y = y + height; v.V = v2; vertices[index++] = v; // (x + 1, y + height, z) (1, v2) v.X = x; v.Z = z + 1; v.U = 0; vertices[index++] = v; // (x, y + height, z + 1) (0, v2) v.Y = y; v.V = v1; vertices[index++] = v; // (x y, z + 1) (0, v1) } } if (particles && (rainAcc >= 0.25 || moved)) { rainAcc = 0; } if (index == 0) { return; } gfx.AlphaTest = false; gfx.DepthWrite = false; gfx.AlphaArgBlend = true; gfx.SetBatchFormat(VertexFormat.P3fT2fC4b); gfx.UpdateDynamicIndexedVb(DrawMode.Triangles, vb, vertices, index); gfx.AlphaArgBlend = false; gfx.AlphaTest = true; gfx.DepthWrite = true; }
public IgorGruzdevModel(Aircraft aircraft, Vector3 initialVelocity, Weather weather, float resistance, IgorGruzdevModelData data) : base(aircraft, initialVelocity) { _data = data; _weather = weather; _resistanceCoefficient = resistance; }
public GameState(Global game, GraphicsDevice graphicsDevice, ContentManager content, InventoryState inventory, MouseState mouseState, ShopState shop) : base(game, graphicsDevice, content) { this.chickenCount = 0; this.cowCount = 0; font = _content.Load <SpriteFont>("defaultFont"); this.chickenSprites = new List <Texture2D>(); this.cowSprites = new List <Texture2D>(); this.mouseState = mouseState; this.inventory = inventory; this.shop = shop; this.weather = new Weather(); this.rainTexture = content.Load <Texture2D>("rain"); this.buttonTexture = content.Load <Texture2D>("Button"); buttonFont = content.Load <SpriteFont>("defaultFont"); this.farmTileTexture = content.Load <Texture2D>("dirt"); farm2 = content.Load <Texture2D>("Sprites/dirt2"); farmTiles = new List <FarmTile>(); Tiles = new List <FarmTile>(); slotTexture = content.Load <Texture2D>("ItemSlot"); //animal sprites littleCow = content.Load <Texture2D>("cow"); walkingCow = content.Load <Texture2D>("Sprites/cow_walk_right"); littleChicken = content.Load <Texture2D>("chicken"); walkingChicken = content.Load <Texture2D>("Sprites/chicken_walk_left"); deadChicken = content.Load <Texture2D>("Sprites/deadChicken"); this.buttonSfx = content.Load <SoundEffect>("Sound/selectionClick"); this.buttonSound = buttonSfx.CreateInstance(); this.currHum = 40; this.currSun = 30; this.currTemp = 15; this.currRain = true; this.timeTillNextWeatherUpdate = new TimeSpan(0, 0, 10); this.timeTillNextRain = new TimeSpan(0, 2, 0); this.rainSfx = content.Load <SoundEffect>("Sound/rain"); this.rainSound = rainSfx.CreateInstance(); this.rainSound.IsLooped = true; if (currRain == true) { rainSound.Play(); } else { rainSound.Stop(); } var farmTile01 = new FarmTile(farm2, new Vector2(400, 100), 1, content, this);//fencetile for (int i = 0; i < 9; i++) { farmTiles.Add(new FarmTile(farmTileTexture, new Vector2(-100, -100), 1, content, this)); Tiles.Add(new FarmTile(farmTileTexture, new Vector2(-100, -100), 1, content, this)); } for (int i = 0; i < (int)Math.Ceiling(((float)farmTiles.Count / 3)); i++) { for (int j = 0; j < 3; j++) { if (i * 3 + j < farmTiles.Count) { farmTiles[i * 3 + j].Position = new Vector2(j * 60, i * 55 + 40); farmTiles[i * 3 + j].Click += farmTile_Click; } } } for (int i = 0; i < 9; i++) { chickenSprites.Add(littleChicken); cowSprites.Add(littleCow); } var menuButton = new Button(buttonTexture, buttonFont, new Vector2(5, 435), 1) { Text = "Menu", }; menuButton.Click += menuButton_Click; var inventoryButton = new Button(buttonTexture, buttonFont, new Vector2(320, 435), 1) { Text = "Inventory", }; inventoryButton.Click += inventoryButton_Click; var shopButton = new Button(buttonTexture, buttonFont, new Vector2(635, 435), 1) { Text = "Shop", }; shopButton.Click += shopButton_Click; components = new List <Entity>() { farmTile01,//fenceTile farmTiles[0], farmTiles[1], farmTiles[2], farmTiles[3], farmTiles[4], farmTiles[5], farmTiles[6], farmTiles[7], farmTiles[8], Tiles[0], Tiles[1], Tiles[2], Tiles[3], Tiles[4], Tiles[5], Tiles[6], Tiles[7], Tiles[8], menuButton, inventoryButton, shopButton, }; }
protected override float GetWeatherStatusEffects(GameObject toObj) { return(Weather.GetVisionModifier(GlobalSettings.GetCurrentWeatherIndex())); }
// Use this for initialization void Start() { drone = GameObject.Find("ThermalDrone").GetComponent <Drone>() as Drone; weather = GameObject.Find("Weather").GetComponent <Weather>() as Weather; }
/* * * * * */ public static Weather CreateWeather(GameTime time, ICity location) { Weather w = new Weather(); Rand r = new Rand(); if (location.TimeZone == 1) { switch (time.GetMonth()) { case 1: w.Temperature = r.Next(-30, 8); break; case 2: w.Temperature = r.Next(-35, 8); break; case 3: w.Temperature = r.Next(-20, 17); break; case 4: w.Temperature = r.Next(2, 20); break; case 5: w.Temperature = r.Next(7, 25); break; case 6: w.Temperature = r.Next(15, 35); break; case 7: w.Temperature = r.Next(20, 40); break; case 8: w.Temperature = r.Next(20, 35); break; case 9: w.Temperature = r.Next(10, 30); break; case 10: w.Temperature = r.Next(2, 20); break; case 11: w.Temperature = r.Next(-20, 10); break; case 12: w.Temperature = r.Next(-30, 8); break; default: w.Temperature = 0; break; } w.MonthId = time.GetMonth(); w.Condition = r.Next(0, 1); } return(w); }
public override void Load() { base.Load(); ItemHold.Clear(); Hotkeys = new HotkeysManager(); Macros = new MacroManager(); // ######################################################### // [FILE_FIX] // TODO: this code is a workaround to port old macros to the new xml system. if (ProfileManager.CurrentProfile.Macros != null) { for (int i = 0; i < ProfileManager.CurrentProfile.Macros.Length; i++) { Macros.PushToBack(ProfileManager.CurrentProfile.Macros[i]); } Macros.Save(); ProfileManager.CurrentProfile.Macros = null; } // ######################################################### Macros.Load(); InfoBars = new InfoBarManager(); InfoBars.Load(); _healthLinesManager = new HealthLinesManager(); // ## BEGIN - END ## // _UOClassicCombatLines = new UOClassicCombatLines(); _textureManager = new TextureManager(); // ## BEGIN - END ## // Weather = new Weather(); WorldViewportGump viewport = new WorldViewportGump(this); UIManager.Add(viewport); if (!ProfileManager.CurrentProfile.TopbarGumpIsDisabled) { TopBarGump.Create(); } CommandManager.Initialize(); NetClient.Socket.Disconnected += SocketOnDisconnected; MessageManager.MessageReceived += ChatOnMessageReceived; UIManager.ContainerScale = ProfileManager.CurrentProfile.ContainersScale / 100f; SDL.SDL_SetWindowMinimumSize(Client.Game.Window.Handle, 640, 480); if (ProfileManager.CurrentProfile.WindowBorderless) { Client.Game.SetWindowBorderless(true); } else if (Settings.GlobalSettings.IsWindowMaximized) { Client.Game.MaximizeWindow(); } else if (Settings.GlobalSettings.WindowSize.HasValue) { int w = Settings.GlobalSettings.WindowSize.Value.X; int h = Settings.GlobalSettings.WindowSize.Value.Y; w = Math.Max(640, w); h = Math.Max(480, h); Client.Game.SetWindowSize(w, h); } // ## BEGIN - END ## // if (ProfileManager.CurrentProfile.UOClassicCombatSelf) { UIManager.Add(new UOClassicCombatSelf { X = ProfileManager.CurrentProfile.UOClassicCombatSelfLocation.X, Y = ProfileManager.CurrentProfile.UOClassicCombatSelfLocation.Y }); } if (ProfileManager.CurrentProfile.UOClassicCombatBuffbar) { UIManager.Add(new UOClassicCombatBuffbar { X = ProfileManager.CurrentProfile.UOClassicCombatBuffbarLocation.X, Y = ProfileManager.CurrentProfile.UOClassicCombatBuffbarLocation.Y }); } if (ProfileManager.CurrentProfile.UOClassicCombatLines) { UIManager.Add(new UOClassicCombatLines { X = ProfileManager.CurrentProfile.UOClassicCombatLinesLocation.X, Y = ProfileManager.CurrentProfile.UOClassicCombatLinesLocation.Y }); } if (ProfileManager.CurrentProfile.UOClassicCombatAL) { UIManager.Add(new UOClassicCombatAL { X = ProfileManager.CurrentProfile.UOClassicCombatALLocation.X, Y = ProfileManager.CurrentProfile.UOClassicCombatALLocation.Y }); } if (ProfileManager.CurrentProfile.BandageGump) { UIManager.Add(new BandageGump()); } // ## BEGIN - END ## // CircleOfTransparency.Create(ProfileManager.CurrentProfile.CircleOfTransparencyRadius); Plugin.OnConnected(); // ## BEGIN - END ## // ModulesManager.Load(); // ## BEGIN - END ## // Camera.SetZoomValues ( new[] { .5f, .6f, .7f, .8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f } ); Camera.Zoom = ProfileManager.CurrentProfile.DefaultScale; }
public void SetWeather(Weather weather) { Add(new SetWeather(weather)); }
public override ModelDTO Create() { string message; Weather weather = DataLoad.GetWeatherFromXML(ResourceAddress, out message); WeatherDTO weatherDTO = new WeatherDTO(); weatherDTO.City = weather.Sname; weatherDTO.currentDate = DateTime.Now; // для получения описания полей класса модели из источника WeatherItemDescription description = new WeatherItemDescription(); string value; foreach (Forecast forecast in weather.forecasts) { WeatherDTO.ForecastDTO item = new WeatherDTO.ForecastDTO(); // дата прогноза DateTime dateTime = forecast.GetDateTime(); item.Date = dateTime.ToString("dd MMMM yyyy", new CultureInfo("ru")); // день недели item.DayOfWeek = dateTime.ToString("dddd", new CultureInfo("ru")); // время суток description.tod.TryGetValue(forecast.Tod, out value); item.TimesOfDay = value; //заблаговременность прогноза в часах item.Predict = forecast.Predict; // атмосферные явления Phenomena phenomena = new Phenomena(); // атмосферные явления - облачность description.cloudiness.TryGetValue(forecast.phenomena.Cloudiness, out value); phenomena.Cloudiness = value; // атмосферные явления - тип осадков description.precipitation.TryGetValue(forecast.phenomena.Precipitation, out value); phenomena.Precipitation = value; // атмосферные явления - если они есть. if (forecast.phenomena.Precipitation != "10") { // интенсивность осадков. description.rpower.TryGetValue(forecast.phenomena.Rpower, out value); phenomena.Rpower = value; // вероятность грозы. description.rpower.TryGetValue(forecast.phenomena.Rpower, out value); phenomena.Rpower = value; } item.Phenomena = phenomena; string pressureStr = forecast.pressure.ToString(); item.Pressure = pressureStr.Substring(12); item.Temperature = forecast.temperature.Min + " - " + forecast.temperature.Max + "C"; item.Wind = "ветер " + forecast.wind.Min + "-" + forecast.wind.Max + " м/с" + forecast.wind.Direction; item.Relwet = "влажность " + forecast.relwet.Min + "-" + forecast.relwet.Max + " %"; item.Heat = forecast.heat.Min + " - " + forecast.heat.Max + "C"; weatherDTO.forecastsDTO.Add(item); } return(weatherDTO); }
public WeatherData(Weather type) { mType = type; }
// Called when the weather changes in the zone this script is associated with. public virtual void OnChange(Weather weather, WeatherState state, float grade) { }
public async Task <Response <List <Song> > > GetSongsByFilter(Genre genre, Location location, Weather weather, Mood mood) { return(await RequestHandler.ExecuteRequestAsync(async() => { return await _songService.GetFilteredSongs(new State() { Weather = weather, Location = location, Mood = mood }, genre); })); }
public static string ToString(Weather weather) { return(WeatherText[weather]); }
public ApiResonseBuilder UseWeatherAsPayload(Weather weather) { Weather = weather; return(this); }
private async Task GetWeatherData() { WeatherException wEx = null; bool loadedSavedData = false; try { weather = await wm.GetWeather(location); } catch (WeatherException weatherEx) { wEx = weatherEx; weather = null; } catch (Exception ex) { Logger.WriteLine(LoggerLevel.Error, ex, "WeatherDataLoader: error getting weather data"); weather = null; } // Load old data if available and we can't get new data if (weather == null) { loadedSavedData = await LoadSavedWeatherData(true); } else if (weather != null) { // Handle upgrades if (String.IsNullOrEmpty(location.name) || String.IsNullOrEmpty(location.tz_long)) { location.name = weather.location.name; location.tz_long = weather.location.tz_long; #if !__ANDROID_WEAR__ await Settings.UpdateLocation(location); #else Settings.SaveHomeData(location); #endif } if (location.latitude == 0 && location.longitude == 0) { location.latitude = double.Parse(weather.location.latitude); location.longitude = double.Parse(weather.location.longitude); #if !__ANDROID_WEAR__ await Settings.UpdateLocation(location); #else Settings.SaveHomeData(location); #endif } await SaveWeatherData(); } // Throw exception if we're unable to get any weather data if (weather == null && wEx != null) { throw wEx; } else if (weather == null && wEx == null) { throw new WeatherException(WeatherUtils.ErrorStatus.NoWeather); } else if (weather != null && wEx != null && loadedSavedData) { throw wEx; } }
public virtual void OnUpdate(Weather obj, uint diff) { }
/// <summary> /// Reset the watch / timeline /// </summary> /// <returns></returns> public async Task <bool> Wipe() { try { if (await _pc.IsBackgroundTaskRunning()) { _Log.Add("Stop current activities"); _pc.StopBackgroundTask(PebbleConnector.Initiator.Manual); await _pc.WaitBackgroundTaskStopped(5); } await Connect(); String Message; //Get current watch face ID //WatchFaceMessage _wfm = new WatchFaceMessage(); Guid CurrentWatchFace = _pc.Pebble.CurrentWatchFace; //await _pc.Pebble.RequestWatchFaceMessageAsync(_wfm); WatchItem CurrentWatchFaceItem = _pc.WatchItems.Get(CurrentWatchFace); System.Diagnostics.Debug.WriteLine(String.Format("Current watch face: {0}", CurrentWatchFace)); if (CurrentWatchFaceItem != null) { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFaceItem.Name)); } else { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFace)); } _pc.StartReceivingMessages(); _pc.Pebble._protocol.MessageReceived += AppMessageReceived; //Set the watch face byte[] TicTocByte = new byte[16] { 0x8F, 0x3C, 0x86, 0x86, 0x31, 0xA1, 0x4F, 0x5F, 0x91, 0xF5, 0x01, 0x60, 0x0C, 0x9B, 0xDC, 0x59 }; Guid TicTocGuid = new Guid(TicTocByte); if (CurrentWatchFace != Guid.Empty && CurrentWatchFace != TicTocGuid) { WatchFaceSelectMessage _wsm = new WatchFaceSelectMessage(CurrentWatchFace, TicTocGuid); await _pc.Pebble.WriteMessageAsync(_wsm); System.Diagnostics.Debug.WriteLine(String.Format("TicToc Watch fase set as current")); } StandardV3Message _SV3M; for (int i = 1; i <= 9; i++) { _SV3M = new StandardV3Message(_pc.Pebble.GetNextMessageIdentifier(), (byte)i); await _pc.Pebble._protocol.WriteMessage(_SV3M); await WaitForMessage(_SV3M.Identifier); } /*Message = "00:04:b1:db:05:d0:11:01"; * await _pc.WriteMessage(Message); * await WaitForMessage("d0:11"); * * Message = "00:04:b1:db:05:65:54:02"; * await _pc.WriteMessage(Message); * await WaitForMessage("65:54"); * * Message = "00:04:b1:db:05:8c:b5:03"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b5"); * * Message = "00:04:b1:db:05:8c:b6:04"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b6"); * * Message = "00:04:b1:db:05:8c:b7:05"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b7"); * * Message = "00:04:b1:db:05:8c:b8:06"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b8"); * * Message = "00:04:b1:db:05:8c:b9:07"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b9"); * * Message = "00:04:b1:db:05:8c:ba:08"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:ba"); * * Message = "00:04:b1:db:05:8c:b0:09"; * await _pc.WriteMessage(Message); * await WaitForMessage("8c:b0");*/ _Log.Add("Pebble Time wiped."); System.Diagnostics.Debug.WriteLine("Pebble Time wiped."); foreach (var item in _pc.Pebble.WatchItems) { WatchItemAddMessage _waam = new WatchItemAddMessage(_pc.Pebble.GetNextMessageIdentifier(), item); await _pc.Pebble._protocol.WriteMessage(_waam); await WaitForMessage(_waam.Transaction); switch (item.Type) { case WatchItemType.WatchFace: _Log.Add(String.Format("Watch face {0} added.", item.Name)); System.Diagnostics.Debug.WriteLine(String.Format("Watch face {0} added.", item.Name)); break; case WatchItemType.WatchApp: _Log.Add(String.Format("Watch app {0} added.", item.Name)); System.Diagnostics.Debug.WriteLine(String.Format("Watch app {0} added.", item.Name)); break; } } _Log.Add("Watch items restored"); System.Diagnostics.Debug.WriteLine("Watch items restored"); //Clear caches Weather.ClearCache(); await Calender.ClearCache(); _Log.Add("Cache cleared on phone"); System.Diagnostics.Debug.WriteLine("Cache cleared on phone"); //Update timeline await _TimeLineSynchronizer.Synchronize(); //Set the watch face if (CurrentWatchFace != Guid.Empty && CurrentWatchFace != TicTocGuid) { WatchFaceSelectMessage _wsm = new WatchFaceSelectMessage(TicTocGuid, CurrentWatchFace); await _pc.Pebble.WriteMessageAsync(_wsm); _Log.Add(String.Format("Selected watch face: {0}", CurrentWatchFace)); if (CurrentWatchFaceItem != null) { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFaceItem.Name)); } else { _Log.Add(String.Format("Current watch face: {0}", CurrentWatchFace)); } System.Diagnostics.Debug.WriteLine(String.Format("Selected watch face: {0}", CurrentWatchFace)); _pc.Pebble.ItemSend += Pebble_ItemSend; } else { Disconnect(); } return(true); } catch (Exception exp) { System.Diagnostics.Debug.WriteLine(String.Format("Wipe exception: {0}", exp.Message)); Disconnect(); } return(false); }
public void InvokeWeather(string mess) { Message = mess; Weather?.Invoke(Message); }
private static async Task <bool> SendToSignalR(IAsyncCollector <SignalRMessage> signalRMessages, ILogger log, DateTimeOffset readAtUtc, double temperature, Weather weather) { try { await signalRMessages.AddAsync( new SignalRMessage { Target = "notifyCurrentWeatherUpdated", Arguments = new object[] { new { city = City, timestampWest = DateTimeOffsetHelper.ConvertToWest(readAtUtc), temperature, weatherId = weather.id, weatherDescription = weather.description, weatherIcon = weather.icon } } }); return(true); } catch (Exception e) { log.LogError(e, "Error when sending current weather to signalr"); return(false); } }
private static bool AddToTableStorage(ICollector <CurrentWeatherReport> tableBinding, ILogger log, double temperature, Weather weather, DateTimeOffset readAtUtc) { try { tableBinding.Add( new CurrentWeatherReport { PartitionKey = City, RowKey = readAtUtc.ToRowKey(), Temperature = temperature, ReadAtUtc = readAtUtc, WeatherId = weather.id, WeatherDescription = weather.description, WeatherIcon = weather.icon } ); } catch (Exception e) { log.LogError(e, "Error when storing current weather in table"); return(false); } return(true); }
bool EntWeather(int num) { switch (num) { case 0: { if (weatherflg[0]) { NowWeather = Weather.RAIN; nowWeathers = PlayerCharacterController.WeatherState.Rain; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; return(true); } else { return(false); } } case 1: { if (weatherflg[1]) { NowWeather = Weather.FOG; nowWeathers = PlayerCharacterController.WeatherState.Fog; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; return(true); } else { return(false); } } case 2: { if (weatherflg[2]) { NowWeather = Weather.WIND; nowWeathers = PlayerCharacterController.WeatherState.Wind; GameObject we; we = GameObject.Find("PlayerCharacter"); we.GetComponent <PlayerCharacterController>().weatherState = nowWeathers; return(true); } else { return(false); } } default: { return(false); } } }
public override void Construct() { AutoSizeColumns = true; IsRootTray = true; ItemSource = new Gui.Widget[] { new HorizontalMenuTray.MenuItem { Text = "CHEAT MODE", }, new HorizontalMenuTray.MenuItem { Text = "DEBUG", ExpansionChild = new HorizontalMenuTray.Tray { ItemSize = new Point(200, 20), ItemSource = Debugger.EnumerateSwitches().Select(s => new HorizontalMenuTray.CheckboxMenuItem { Text = Debugger.GetNicelyFormattedName(s.Name), InitialState = s.State, SetCallback = s.Set }) } }, new HorizontalMenuTray.MenuItem { Text = "DEBUG SAVE", OnClick = (sender, args) => { // Turn off binary compressed saves and save a nice straight json save for debugging purposes. // Todo: Why isn't World managing this paused state itself? bool paused = Master.World.Paused; var previousSetting = DwarfGame.COMPRESSED_BINARY_SAVES; DwarfGame.COMPRESSED_BINARY_SAVES = false; Master.World.Save( String.Format("{0}_{1}_DEBUG", Overworld.Name, Master.World.GameID), (success, exception) => { Master.World.MakeAnnouncement(success ? "Debug save created.": "Debug save failed - " + exception.Message); DwarfGame.COMPRESSED_BINARY_SAVES = previousSetting; Master.World.Paused = paused; }); } }, new HorizontalMenuTray.MenuItem { Text = "BUILD", ExpansionChild = new HorizontalMenuTray.Tray { ItemSource = RoomLibrary.GetRoomTypes().Select(r => new HorizontalMenuTray.MenuItem { Text = r, OnClick = (sender, args) => ActivateGodTool("Build/" + r) }) } }, new HorizontalMenuTray.MenuItem { Text = "SPAWN", ExpansionChild = new HorizontalMenuTray.Tray { Columns = 5, ItemSource = EntityFactory.EnumerateEntityTypes().Where(s => !s.Contains("Resource") || !ResourceLibrary.GetResourceByName(s.Substring(0, s.Length - " Resource".Length)).Generated).OrderBy(s => s).Select(s => new HorizontalMenuTray.MenuItem { Text = s, OnClick = (sender, args) => ActivateGodTool("Spawn/" + s) }) } }, new HorizontalMenuTray.MenuItem { Text = "PLACE BLOCK", ExpansionChild = new HorizontalMenuTray.Tray { Columns = 3, ItemSource = VoxelLibrary.GetTypes() .Where(t => t.Name != "_empty" && t.Name != "water") .OrderBy(s => s.Name) .Select(s => new HorizontalMenuTray.MenuItem { Text = s.Name, OnClick = (sender, args) => ActivateGodTool("Place/" + s.Name) }) } }, new HorizontalMenuTray.MenuItem { Text = "DELETE BLOCK", OnClick = (sender, args) => ActivateGodTool("Delete Block") }, new HorizontalMenuTray.MenuItem { Text = "KILL BLOCK", OnClick = (sender, args) => ActivateGodTool("Kill Block") }, new HorizontalMenuTray.MenuItem { Text = "PLACE GRASS", ExpansionChild = new HorizontalMenuTray.Tray { Columns = 3, ItemSource = GrassLibrary.TypeList .OrderBy(s => s.Name) .Select(s => new HorizontalMenuTray.MenuItem { Text = s.Name, OnClick = (sender, args) => ActivateGodTool("Grass/" + s.Name) }) } }, //new HorizontalMenuTray.MenuItem //{ // Text = "PLACE DECAL", // ExpansionChild = new HorizontalMenuTray.Tray // { // Columns = 3, // ItemSource = DecalLibrary.TypeList // .OrderBy(s => s.Name) // .Select(s => // new HorizontalMenuTray.MenuItem // { // Text = s.Name, // OnClick = (sender, args) => ActivateGodTool("Decal/" + s.Name) // }) // } //}, new HorizontalMenuTray.MenuItem { Text = "PLACE RAIL", ExpansionChild = new HorizontalMenuTray.Tray { Columns = 1, ItemSource = new HorizontalMenuTray.MenuItem[] { new HorizontalMenuTray.MenuItem { Text = "RAW PIECES", ExpansionChild = new HorizontalMenuTray.Tray { Columns = 2, ItemSize = new Point(200, 20), ItemSource = Rail.RailLibrary.EnumeratePieces().Select(p => new HorizontalMenuTray.MenuItem { Text = p.Name, OnClick = (sender, args) => ActivateGodTool("Rail/" + p.Name) }) } }, new HorizontalMenuTray.MenuItem { Text = "USING PATTERNS", ExpansionChild = new HorizontalMenuTray.Tray { Columns = 1, ItemSource = Rail.RailLibrary.EnumeratePatterns().Select(p => new HorizontalMenuTray.MenuItem { Text = p.Name, OnClick = (sender, args) => { var railTool = Master.Tools[GameMaster.ToolMode.BuildRail] as Rail.BuildRailTool; railTool.Pattern = p; Master.ChangeTool(GameMaster.ToolMode.BuildRail); railTool.GodModeSwitch = true; } }) } }, new HorizontalMenuTray.MenuItem { Text = "PAINT", OnClick = (sender, args) => { var railTool = Master.Tools[GameMaster.ToolMode.PaintRail] as Rail.PaintRailTool; railTool.SelectedResources = new List <ResourceAmount>(new ResourceAmount[] { new ResourceAmount("Rail", 1) }); Master.ChangeTool(GameMaster.ToolMode.PaintRail); railTool.GodModeSwitch = true; } } } } }, new HorizontalMenuTray.MenuItem { Text = "KILL THINGS", OnClick = (sender, args) => ActivateGodTool("Kill Things") }, new HorizontalMenuTray.MenuItem { Text = "TRAILER", ExpansionChild = new HorizontalMenuTray.Tray { ItemSource = new List <HorizontalMenuTray.MenuItem>() { new HorizontalMenuTray.MenuItem { Text = "SPIN +", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 2.0f, 0.0f), }, new HorizontalMenuTray.MenuItem { Text = "SPIN -", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, -2.0f, 0.0f), }, new HorizontalMenuTray.MenuItem { Text = "ZOOM -", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 0.0f, 2.5f), }, new HorizontalMenuTray.MenuItem { Text = "ZOOM +", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 0.0f, -2.5f), }, new HorizontalMenuTray.MenuItem { Text = "FWD", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Forward * 5, 0.0f, 0.0f), }, new HorizontalMenuTray.MenuItem { Text = "BACK", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Backward * 5, 0.0f, 0.0f), }, new HorizontalMenuTray.MenuItem { Text = "LEFT", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Left * 5, 0.0f, 0.0f), }, new HorizontalMenuTray.MenuItem { Text = "RIGHT", OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Right * 5, 0.0f, 0.0f), }, } } }, new HorizontalMenuTray.MenuItem { Text = "FILL WATER", OnClick = (sender, args) => ActivateGodTool("Fill Water") }, new HorizontalMenuTray.MenuItem { Text = "FILL LAVA", OnClick = (sender, args) => ActivateGodTool("Fill Lava") }, new HorizontalMenuTray.MenuItem { Text = "TRADE ENVOY", ExpansionChild = new HorizontalMenuTray.Tray { ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s => { return(new HorizontalMenuTray.MenuItem { Text = s.Name, OnClick = (sender, args) => Master.World.Diplomacy.SendTradeEnvoy(s, Master.World) }); }), } }, new HorizontalMenuTray.MenuItem { Text = "EVENT", ExpansionChild = new HorizontalMenuTray.Tray { ItemSource = Master.World.GoalManager.EventScheduler.Events.Events.Select(e => { return(new HorizontalMenuTray.MenuItem { Text = e.Name, OnClick = (sender, args) => Master.World.GoalManager.EventScheduler.ActivateEvent(Master.World, e) }); }), } }, new HorizontalMenuTray.MenuItem { Text = "WAR PARTY", ExpansionChild = new HorizontalMenuTray.Tray { ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s => { return(new HorizontalMenuTray.MenuItem { Text = s.Name, OnClick = (sender, args) => Master.World.Diplomacy.SendWarParty(s) }); }), } }, new HorizontalMenuTray.MenuItem { Text = "DWARF BUX", OnClick = (sender, args) => Master.Faction.AddMoney(100m) }, new HorizontalMenuTray.MenuItem { Text = "MINIONS", ExpansionChild = new HorizontalMenuTray.Tray { ItemSource = new HorizontalMenuTray.MenuItem[] { new HorizontalMenuTray.MenuItem { Text = "PAY", OnClick = (sender, args) => Master.PayEmployees() }, new HorizontalMenuTray.MenuItem { Text = "STARVE", OnClick = (sender, args) => { foreach (var minion in Master.Faction.Minions) { minion.Status.Hunger.CurrentValue = 0; } } }, new HorizontalMenuTray.MenuItem { Text = "XP", OnClick = (sender, args) => { foreach (var minion in Master.Faction.Minions) { minion.AddXP(100); } } }, new HorizontalMenuTray.MenuItem { Text = "DISEASE", OnClick = (sender, args) => ActivateGodTool("Disease") }, new HorizontalMenuTray.MenuItem { Text = "HAPPY", OnClick = (sender, args) => { foreach (var minion in Master.Faction.Minions) { var thoughts = minion.GetRoot().GetComponent <DwarfThoughts>(); if (thoughts != null) { thoughts.AddThought(Thought.ThoughtType.CheatedHappy); } } } }, new HorizontalMenuTray.MenuItem { Text = "PISSED", OnClick = (sender, args) => { foreach (var minion in Master.Faction.Minions) { var thoughts = minion.GetRoot().GetComponent <DwarfThoughts>(); if (thoughts != null) { thoughts.AddThought(Thought.ThoughtType.CheatedPissed); } } } }, new HorizontalMenuTray.MenuItem { Text = "GAMBLE", OnClick = (sender, args) => { foreach (var employee in Master.Faction.Minions) { employee.AssignTask(new Scripting.GambleTask() { Priority = Task.PriorityType.High }); } } }, new HorizontalMenuTray.MenuItem { Text = "PASS OUT", OnClick = (sender, args) => { var employee = Datastructures.SelectRandom(Master.Faction.Minions); if (employee != null) { employee.Creature.Heal(-employee.Status.Health.CurrentValue * employee.Creature.MaxHealth + 1); } } } } } }, new HorizontalMenuTray.MenuItem { Text = "SPAWN TEST", OnClick = (sender, args) => { // Copy is required because spawning some types results in the creation of new types. EG, snakes create snake meat. var keys = EntityFactory.EnumerateEntityTypes().ToList(); int num = keys.Count(); float gridSize = (float)Math.Ceiling(Math.Sqrt((double)num)); Vector3 gridCenter = Master.World.CursorLightPos; int i = 0; for (float dx = -gridSize / 2; dx <= gridSize / 2; dx++) { for (float dz = -gridSize / 2; dz <= gridSize / 2; dz++) { if (i >= num) { continue; } Vector3 pos = MathFunctions.Clamp(gridCenter + new Vector3(dx, VoxelConstants.ChunkSizeY, dz), Master.World.ChunkManager.Bounds); VoxelHandle handle = VoxelHelpers.FindFirstVisibleVoxelOnRay(Master.World.ChunkManager.ChunkData, pos, pos + Vector3.Down * 100); if (handle.IsValid) { EntityFactory.CreateEntity <GameComponent>(keys[i], handle.WorldPosition + Vector3.Up); } i++; } } } }, new HorizontalMenuTray.MenuItem { Text = "SPAWN CRAFTS", OnClick = (sender, args) => { // Copy is required because spawning some types results in the creation of new types. EG, snakes create snake meat. var itemTypes = CraftLibrary.EnumerateCraftables().Where(craft => craft.Type == CraftItem.CraftType.Object).ToList(); int num = itemTypes.Count(); float gridSize = (float)Math.Ceiling(Math.Sqrt((double)num)); Vector3 gridCenter = Master.World.CursorLightPos; int i = 0; for (float dx = -gridSize / 2; dx <= gridSize / 2; dx++) { for (float dz = -gridSize / 2; dz <= gridSize / 2; dz++) { if (i < num) { var item = itemTypes[i]; if (item.Name != "Explosive") { Vector3 pos = MathFunctions.Clamp(gridCenter + new Vector3(dx, VoxelConstants.ChunkSizeY, dz), Master.World.ChunkManager.Bounds); VoxelHandle handle = VoxelHelpers.FindFirstVisibleVoxelOnRay(Master.World.ChunkManager.ChunkData, pos, pos + Vector3.Down * 100); if (handle.IsValid) { var blackboard = new Blackboard(); List <ResourceAmount> resources = item.RequiredResources.Select(r => new ResourceAmount(ResourceLibrary.GetResourcesByTag(r.ResourceType).First(), r.NumResources)).ToList(); blackboard.SetData <List <ResourceAmount> >("Resources", resources); blackboard.SetData <string>("CraftType", item.Name); var entity = EntityFactory.CreateEntity <GameComponent>(item.EntityName, handle.WorldPosition + Vector3.Up + item.SpawnOffset, blackboard); if (entity != null) { if (item.AddToOwnedPool) { Master.Faction.OwnedObjects.Add(entity as Body); } if (item.Moveable) { entity.Tags.Add("Moveable"); } if (item.Deconstructable) { entity.Tags.Add("Deconstructable"); } } } } } i++; } } } }, new HorizontalMenuTray.MenuItem { Text = "+1 HOUR", OnClick = (sender, args) => { Master.World.Time.CurrentDate += new TimeSpan(1, 0, 0); } }, new HorizontalMenuTray.MenuItem { Text = "FORCE REBUILD", OnClick = (sender, args) => { foreach (var chunk in Master.World.ChunkManager.ChunkData.ChunkMap) { for (int Y = 0; Y < VoxelConstants.ChunkSizeY; ++Y) { chunk.InvalidateSlice(Y); } } } }, new HorizontalMenuTray.MenuItem { Text = "REPULSE", OnClick = (sender, args) => ActivateGodTool("Repulse") }, new HorizontalMenuTray.MenuItem { Text = "SLOWMO", OnClick = (sender, args) => GameSettings.Default.EnableSlowMotion = !GameSettings.Default.EnableSlowMotion }, new HorizontalMenuTray.MenuItem { Text = "LET IT SNOW", OnClick = (sender, args) => { var storm = Weather.CreateStorm(Vector3.One, 100.0f, Master.World); storm.TypeofStorm = StormType.SnowStorm; storm.Start(); } } }; base.Construct(); }
public abstract void AddWeather(Weather weather);