Пример #1
0
        Image GetWeatherImage(Weather.Type type)
        {
            var time = DateTime.Now;

            switch (type)
            {
            case Weather.Type.no:
                return(WeatherImages["null"]);

            case Weather.Type.Thunderstorm:
                return(GifWeatherImages["Thunderstorm"].GetCurrentFrame);

            case Weather.Type.Drizzle:
                return(GifWeatherImages["Drizzle"].GetCurrentFrame);

            case Weather.Type.Rain:
                return(GifWeatherImages["Rain"].GetCurrentFrame);

            case Weather.Type.Snow:
                return(GifWeatherImages["Snow"].GetCurrentFrame);

            case Weather.Type.Mist:
                return(GifWeatherImages["Mist"].GetCurrentFrame);

            case Weather.Type.Clear:
                if (time > weather.SunRise && time < weather.SunSet)
                {
                    return(GifWeatherImages["Clear"].GetCurrentFrame);
                }
                else
                {
                    return(GifWeatherImages["ClearNight"].GetCurrentFrame);
                }

            case Weather.Type.Clouds:
                if (time > weather.SunRise && time < weather.SunSet)
                {
                    return(GifWeatherImages["Clouds"].GetCurrentFrame);
                }
                else
                {
                    return(GifWeatherImages["CloudsNight"].GetCurrentFrame);
                }

            default:
                return(WeatherImages["null"]);
            }
        }
Пример #2
0
    //天气切换
    void changeWeather()
    {
        Weather.Type weather          = Weather.Type.SUN;
        int          total_probablity = probability_sun + probability_rain + probability_snow;
        int          rnd = Random.Range(0, total_probablity);

        if (rnd < probability_sun)
        {
            weather = Weather.Type.SUN;
        }
        else if (rnd < probability_sun + probability_rain)
        {
            weather = Weather.Type.RAIN;
        }
        else
        {
            weather = Weather.Type.SNOW;
        }

        Weather.nowWeather = weather;
        Debug.Log("change weather" + weather);
    }