Ejemplo n.º 1
0
    /// <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);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 设置天气
 /// </summary>
 /// <param name="weather"></param>
 public void SetWeather(WeatherTypeEnum weather)
 {
     this.weather = weather;
     if (tvWeather != null)
     {
         tvWeather.text = WeatherTypeEnumTools.GetWeahterName(weather);
     }
 }
Ejemplo n.º 3
0
    public float weatherAddition;       //天气加成

    public WeatherBean(WeatherTypeEnum weatherType)
    {
        this.weatherType = weatherType;
        weatherAddition  = WeatherTypeEnumTools.GetWeatherAddition(weatherType);
        weatherSize      = 1;
    }