private IEnumerator CreateOpponents() { while (true) { yield return(new WaitForSeconds(3f)); Opponent op = opponentPool.GetFirstAvailable(); NameAndPic cont = new NameAndPic(); if (gPlusIds.Count > 0) { cont = gPlusIds.Pop(); } if (op != null) { if (Random.Range(0, 1000) % 2 == 1) { Log("Creating slower opponent!"); op.Create(vehicle.position + new Vector3(0, 0, 800), slowerSpeed, cont.name, cont.pic); } else { Log("Creating faster opponent!"); op.Create(vehicle.position + new Vector3(0, 0, -150), fasterSpeed, cont.name, cont.pic); } } else { Log("Wanted to create Opponent but there was no ops available."); } } }
IEnumerator GetInformation(string gplus_id) { string url = "https://www.googleapis.com/plus/v1/people/" + gplus_id + "?key=AIzaSyCVqa4G6A7UkkKHmSsZVaWlgJYVnmcduf8"; //100601054994187376077 WWW www = new WWW(url); yield return(www); if (www.error == null) { WWW www2 = null; NameAndPic container = new NameAndPic(); try { Dictionary <string, object> dict = Json.Deserialize(www.text) as Dictionary <string, object>; Dictionary <string, object> nameDict = (Dictionary <string, object>)dict["name"]; container.name = (string)nameDict["givenName"]; nameDict = (Dictionary <string, object>)dict["image"]; www2 = new WWW((string)nameDict["url"]); } catch (Exception e) { Log("Exception: " + e.Message); } yield return(www2); if (www.error == null && www.texture != null) { container.pic = www2.texture; Log("Success! Name: " + container.name); gPlusIds.Push(container); } else { Log("Error while downloading picture! " + www2.error); } } else { Log("Error while getting profile from base URL. " + www.error); } }