/// <summary> /// Start Weather according given Weather Object /// </summary> /// <param name="weather">Weather to Start</param> private void StartWeather(RegionWeather weather) { if (EventLogWeather && log.IsInfoEnabled) { log.InfoFormat("Weather Started in Region {0} (ID {1})\n{2}", weather.Region.Description, weather.Region.ID, weather); } foreach (var player in weather.Region.Objects.OfType <GamePlayer>()) { SendWeatherUpdate(weather, player); } }
/// <summary> /// Send Weather Update to Player /// </summary> /// <param name="weather">Weather to send</param> /// <param name="player">Player Targeted</param> private void SendWeatherUpdate(RegionWeather weather, GamePlayer player) { if (player == null || player.ObjectState != GameObject.eObjectState.Active) { return; } if (weather.StartTime == 0) { player.Out.SendWeather(0, 0, 0, 0, 0); } else { player.Out.SendWeather(weather.CurrentPosition(SimpleScheduler.Ticks), weather.Width, weather.Speed, weather.FogDiffusion, weather.Intensity); } }
/// <summary> /// Stop Weather from given Weather Object /// </summary> /// <param name="weather">Weather to Stop</param> private void StopWeather(RegionWeather weather) { var weatherCurrentPosition = weather.CurrentPosition(SimpleScheduler.Ticks); if (EventLogWeather && log.IsInfoEnabled) { log.InfoFormat("Weather Stopped in Region {0} (ID {1}) CurrentPosition : {2}\n{3}", weather.Region.Description, weather.Region.ID, weatherCurrentPosition, weather); } weather.Clear(); foreach (var player in weather.Region.Objects.OfType <GamePlayer>()) { SendWeatherUpdate(weather, player); if (player.Position.X > weatherCurrentPosition - weather.Width && player.Position.X < weatherCurrentPosition) { player.Out.SendMessage("The sky clears up again as the storm clouds disperse!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); } } }
public void WeatherRegion_InitWeather_MinMaxEqualZone() { var region = FakeRegion(); var weather = new RegionWeather(region); weather.CreateWeather(65000, 300, 100, 16000, 0); var duration = (65535 + 65000) * 1000 / 300; Assert.AreEqual(65535 + 65000, weather.CurrentPosition(duration)); Assert.AreEqual(0, weather.CurrentPosition(0)); }
/// <summary> /// Send Weather Update to Player /// </summary> /// <param name="weather">Weather to send</param> /// <param name="player">Player Targeted</param> private void SendWeatherUpdate(RegionWeather weather, GamePlayer player) { if (player == null || player.ObjectState != GameObject.eObjectState.Active) return; if (weather.StartTime == 0) player.Out.SendWeather(0, 0, 0, 0, 0); else player.Out.SendWeather(weather.CurrentPosition(SimpleScheduler.Ticks), weather.Width, weather.Speed, weather.FogDiffusion, weather.Intensity); }
/// <summary> /// Start Weather according given Weather Object /// </summary> /// <param name="weather">Weather to Start</param> private void StartWeather(RegionWeather weather) { if (EventLogWeather && log.IsInfoEnabled) log.InfoFormat("Weather Started in Region {0} (ID {1})\n{2}", weather.Region.Description, weather.Region.ID, weather); foreach (var player in weather.Region.Objects.OfType<GamePlayer>()) SendWeatherUpdate(weather, player); }
/// <summary> /// Stop Weather from given Weather Object /// </summary> /// <param name="weather">Weather to Stop</param> private void StopWeather(RegionWeather weather) { var weatherCurrentPosition = weather.CurrentPosition(SimpleScheduler.Ticks); if (EventLogWeather && log.IsInfoEnabled) log.InfoFormat("Weather Stopped in Region {0} (ID {1}) CurrentPosition : {2}\n{3}", weather.Region.Description, weather.Region.ID, weatherCurrentPosition, weather); weather.Clear(); foreach (var player in weather.Region.Objects.OfType<GamePlayer>()) { SendWeatherUpdate(weather, player); if (player.X > weatherCurrentPosition - weather.Width && player.X < weatherCurrentPosition) player.Out.SendMessage("The sky clears up again as the storm clouds disperse!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); } }