/// <summary> /// 随机化一个天气 /// </summary> public WeatherBean RandomWeather() { WeatherTypeEnum weatherStatusRandom = WeatherTypeEnum.Sunny; GameTimeHandler.Instance.GetTime(out int year, out int month, out int day); float weatherRate = UnityEngine.Random.Range(0f, 1f); if (weatherRate <= 0.5f) { weatherStatusRandom = WeatherTypeEnum.Sunny; } else if (weatherRate > 0.5f && weatherRate <= 0.8f) { weatherStatusRandom = WeatherTypeEnum.Cloudy; } else { List <WeatherTypeEnum> listWeather = WeatherTypeEnumTools.GetWeahterListByMonth(month); weatherStatusRandom = RandomUtil.GetRandomDataByList(listWeather); } WeatherBean weatherData = new WeatherBean(weatherStatusRandom); SetWeather(weatherData); return(weatherData); }
/// <summary> /// 设置天气数据 /// </summary> /// <param name="weatherData"></param> public void SetWeatherData(WeatherBean weatherData) { WeatherTypeEnum weatherType = weatherData.GetWeatherType(); SceneElementHandler.Instance.manager.SetRainActive(false); SceneElementHandler.Instance.manager.SetCloudAction(false); switch (weatherType) { case WeatherTypeEnum.Sunny: currentWeather = new WeatherSunny(weatherData); break; case WeatherTypeEnum.Cloudy: currentWeather = new WeatherCloudy(weatherData); break; case WeatherTypeEnum.Rain: currentWeather = new WeatherRain(weatherData); break; case WeatherTypeEnum.Snow: currentWeather = new WeatherSnow(weatherData); break; } }
/// <summary> /// 设置天气 /// </summary> /// <param name="weather"></param> public void SetWeather(WeatherTypeEnum weather) { this.weather = weather; if (tvWeather != null) { tvWeather.text = WeatherTypeEnumTools.GetWeahterName(weather); } }
/// <summary> /// 改变天气 /// </summary> /// <param name="weatherType">天气类型</param> /// <param name="timeMaxForWeather"></param> public void ChangeWeather(WeatherTypeEnum weatherType, float timeMaxForWeather) { WeatherBean weatherData = new WeatherBean(); weatherData.SetWeatherType(weatherType); weatherData.timeForWeather = timeMaxForWeather; weatherData.timeMaxForWeather = timeMaxForWeather; manager.SetWeatherData(weatherData); }
/// <summary> /// 获取指定天气人流量加成 /// </summary> /// <returns></returns> public static float GetWeatherAddition(WeatherTypeEnum weatherType) { float addition = 0; switch (weatherType) { case WeatherTypeEnum.Sunny: addition = 0; break; case WeatherTypeEnum.Cloudy: addition = 0.5f; break; case WeatherTypeEnum.LightRain: addition = -0.1f; break; case WeatherTypeEnum.Rain: addition = -0.15f; break; case WeatherTypeEnum.Thunderstorm: addition = -0.2f; break; case WeatherTypeEnum.Fog: addition = -0.1f; break; case WeatherTypeEnum.LightSnow: addition = -0.1f; break; case WeatherTypeEnum.Snow: addition = -0.15f; break; case WeatherTypeEnum.Wind: addition = -0.1f; break; case WeatherTypeEnum.Defoliation: addition = 0f; break; } return(addition); }
public static string GetWeahterName(WeatherTypeEnum weatherType) { string name = ""; switch (weatherType) { case WeatherTypeEnum.Sunny: break; case WeatherTypeEnum.Cloudy: name = TextHandler.Instance.manager.GetTextById(701); break; case WeatherTypeEnum.LightRain: name = TextHandler.Instance.manager.GetTextById(702); break; case WeatherTypeEnum.Rain: name = TextHandler.Instance.manager.GetTextById(703); break; case WeatherTypeEnum.Thunderstorm: name = TextHandler.Instance.manager.GetTextById(704); break; case WeatherTypeEnum.Fog: name = TextHandler.Instance.manager.GetTextById(705); break; case WeatherTypeEnum.LightSnow: name = TextHandler.Instance.manager.GetTextById(706); break; case WeatherTypeEnum.Snow: name = TextHandler.Instance.manager.GetTextById(707); break; case WeatherTypeEnum.Wind: name = TextHandler.Instance.manager.GetTextById(708); break; case WeatherTypeEnum.Defoliation: name = TextHandler.Instance.manager.GetTextById(709); break; } return(name); }
public float weatherAddition; //天气加成 public WeatherBean(WeatherTypeEnum weatherType) { this.weatherType = weatherType; weatherAddition = WeatherTypeEnumTools.GetWeatherAddition(weatherType); weatherSize = 1; }
public void SetWeatherType(WeatherTypeEnum weatherType) { this.weatherType = (int)weatherType; }