コード例 #1
0
ファイル: WeatherView.cs プロジェクト: zgszft/UTSHelpsMobile
        public WeatherView(CGRect frame)
            : base(frame)
        {
            ShowsFPS = true;
            ShowsNodeCount = true;
            ShowsDrawCount = true;

            var scene = new WeatherScene (Frame.Size);
            scene.ScaleMode = SKSceneScaleMode.AspectFill;
            PresentScene (scene);
        }
コード例 #2
0
    public async Task LoadWeather(string cityName)
    {
        //Reseting Weather Text:
        //Write WeatherData
        textCity.text = textTemp.text = textDescription.text = "...";

        //Fetch WeatherData
        WeatherData weatherData = await weatherQuery.FetchWeatherData(cityName);

        if (weatherData == null)
        {
            Debug.LogError("WeatherData is null!");
            return;
        }

        int code = weatherData.weather[0].id;

        //Assign Weatherscene
        WeatherScene weatherScene = CodeToWeather(code);

        weatherWidget.WeatherScene = weatherScene;

        //Assign Rain
        //Thunderstrom or Cloudy
        weatherWidget.ThunderstormRain.enabled = weatherScene == WeatherScene.THUNDERSTORM;
        weatherWidget.CloudRain.enabled        = weatherScene == WeatherScene.PARTLY_CLOUDY || weatherScene == WeatherScene.CLOUDY;
        //Assign Rain Intensity
        float rainIntensity = CodeToRainIntensity(code);

        weatherWidget.ThunderstormRain.RainRate = rainIntensity;
        weatherWidget.CloudRain.RainRate        = rainIntensity;

        //Assign Snow
        float snowIntensity = CodeToSnowIntensity(code);

        weatherWidget.CloudSnow.RainEnabled = snowIntensity > 0;
        weatherWidget.CloudSnow.RainRate    = snowIntensity;

        //Write WeatherData
        textCity.text        = weatherData.name;
        textTemp.text        = weatherData.main.temp + "°C";
        textDescription.text = weatherScene.ToString();
    }