IEnumerator IGetLocale(string lat, string lon) { WWW www = new WWW("https://maps.googleapis.com/maps/api/geocode/json?address=" + lat + "," + lon + "&key=AIzaSyC55Xgl4YTGrnILi4jgqiXroEB4venvhzI&language=ko"); yield return(www); if (www.error != null) { } else if (www.isDone) { //Debug.Log(www.text); locationInfo = JsonUtility.FromJson <JHchoi.Contents.LocationInfo>(www.text); try { string split = " "; string[] addr = locationInfo.results[0].formatted_address.Split(split.ToCharArray()); Message.Send <AddressMsg>(new AddressMsg(addr[1], addr[2])); //myWeather.SetWeatherLocale(addr[1], addr[2]); } catch (System.Exception e) { //Debug.Log(e.ToString); } } }
IEnumerator IGetLocale(string lat, string lon, Weathers weathers, string temp, Character character, bool isTTsRequest) { string addr1 = ""; string addr2 = ""; WWW www = new WWW("https://maps.googleapis.com/maps/api/geocode/json?address=" + lat + "," + lon + "&key=AIzaSyC55Xgl4YTGrnILi4jgqiXroEB4venvhzI&language=ko"); yield return(www); if (www.error != null) { } else if (www.isDone) { //Debug.Log(www.text); locationInfo = JsonUtility.FromJson <JHchoi.Contents.LocationInfo>(www.text); try { string split = " "; string[] addr = locationInfo.results[0].formatted_address.Split(split.ToCharArray()); addr1 = addr[1]; addr2 = addr[2]; Message.Send <AddressMsg>(new AddressMsg(addr[1], addr[2])); } catch (System.Exception e) { Debug.Log(e.ToString()); } } if (isTTsRequest) { string weather = ""; if (weathers == Weathers.Clean) { weather = "맑음"; } else if (weathers == Weathers.Cloud) { weather = "흐림"; } else if (weathers == Weathers.Rain) { weather = "비"; } else if (weathers == Weathers.Snow) { weather = "눈"; } string temper; Mathf.Abs((int)float.Parse(temp)); if ((int)float.Parse(temp) >= 0) { temper = Mathf.Abs((int)float.Parse(temp)).ToString(); } else { temper = "영하" + Mathf.Abs((int)float.Parse(temp)).ToString(); } string msg = string.Format("현재 {0} {1}의 날씨는 {2}이고 현재 온도는 {3}도 입니다.", addr1, addr2, weather, temper); Message.Send <TTSSendMsg>(new TTSSendMsg("", msg, character)); } }