-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSkyAPI.cs
61 lines (47 loc) · 2.32 KB
/
SkyAPI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SkyAPI : MonoBehaviour {
public Sprite clear , cloudy, precip, snow;
private WeatherAPI weather;
public string skyWeather;
// Use this for initialization
void Start () {
//get WeatherAPI
weather = WeatherAPI.FindObjectOfType<WeatherAPI>();
Debug.Log ("found sky API");
}
public void SkyChoice (){
//get weather forecast from weather API
string skyWeather = weather.weatherDescription.ToString();
Debug.Log ("skyweather is" + skyWeather);
if (skyWeather == "Clear" || skyWeather == "clear sky" || skyWeather == "scattered clouds" || skyWeather == "few clouds") {
gameObject.GetComponent<SpriteRenderer>().sprite = clear;
Debug.Log ("Clear");
} else if (skyWeather == "Clouds" || skyWeather == "overcast clouds" || skyWeather == "scattered clouds" || skyWeather == "broken clouds") {
gameObject.GetComponent<SpriteRenderer>().sprite = cloudy;
//Debug.Log ("Cloudy");
} else if (skyWeather == "Rain" || skyWeather == "Thunderstorm" ||
skyWeather == "mist" || skyWeather == "shower rain" || skyWeather == "light intensity rain" || skyWeather == "light thunderstorm"
|| skyWeather == "thunderstorm with light rain" || skyWeather == "thunderstorm with rain" || skyWeather == "thunderstorm with heavy rain"
|| skyWeather == "drizzle"|| skyWeather == "light intensity drizzle"|| skyWeather == "moderate rain"
|| skyWeather == "heavy intensity rain"|| skyWeather == "freezing rain"|| skyWeather == "moderate rain"
|| skyWeather == "light intensity shower rain" || skyWeather == "light rain"
) {
gameObject.GetComponent<SpriteRenderer>().sprite = precip;
//Debug.Log ("precipitation");
} else if (skyWeather == "Snow" || skyWeather == "hail"|| skyWeather == "hail"|| skyWeather == "hail"
|| skyWeather == "light snow" || skyWeather == "heavy snow"|| skyWeather == "sleet"|| skyWeather == "rain and snow"
|| skyWeather == "light snow" || skyWeather == "heavy shower snow"|| skyWeather == "light shower snow"|| skyWeather == "shower snow") {
gameObject.GetComponent<SpriteRenderer>().sprite = snow;
}
else {
gameObject.GetComponent<SpriteRenderer>().sprite = cloudy;
Debug.Log ("weather type not found for sky");
}
}
// Update is called once per frame
void Update(){
//SkyChoice ();
}
}