Пример #1
0
    void Start()
    {
        //Get gamemaster
        if (gm == null)
        {
            gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>();
        }

        if (windzone == null)
        {
            windzone = GameObject.FindGameObjectWithTag("windzone").GetComponent <CityWind> ();
        }
    }
Пример #2
0
        /// <summary>
        /// Get the city wind direction and speed
        /// </summary>
        /// <param name="cityName">City name</param>
        public async Task <CityWind> GetCityWind(string cityName)
        {
            var client    = _httpClientFactory.CreateClient("WeatherClient");
            var url       = $"http://api.openweathermap.org/data/2.5/weather?q={cityName}&appid={_options.APIKEY}";
            var stringRes = await client.GetStringAsync(url);

            var res = JsonSerializer.Deserialize <WeatherResponce>(stringRes);

            var result = new CityWind()
            {
                City      = cityName,
                Speed     = res.Wind.Speed,
                Direction = ToDirection(res.Wind.Degree)
            };

            return(result);
        }