void OnDisable() { if(_instance == this) { _instance = null; } }
public AppFiguresGame(string name, string appID, string store, string developer, string iconUrl, GA_SignUp signup) { Name = name; AppID = appID; Store = store; Developer = developer; IconUrl = iconUrl; WWW www = new WWW(iconUrl); GA_ContinuationManager.StartCoroutine(GetIconTexture(www, signup), () => www.isDone); }
public void Opened() { if(_instance == null) { _instance = this; } else { Close(); } }
private IEnumerator<WWW> GetIconTexture(WWW www, GA_SignUp signup) { yield return www; try { if(string.IsNullOrEmpty(www.error)) { Icon = www.texture; signup.Repaint(); } else { Debug.LogError("Failed to get icon: " + www.error); } } catch { Debug.LogError("Failed to get icon"); } }
private static IEnumerator<WWW> GetAppFiguresFrontend(WWW www, Settings ga, GA_SignUp signup, string gameName) { yield return www; try { Hashtable returnParam = null; string error = ""; if(!string.IsNullOrEmpty(www.text)) { returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text); if(returnParam.ContainsKey("errors")) { ArrayList errorList = (ArrayList)returnParam["errors"]; if(errorList != null && errorList.Count > 0) { Hashtable errors = (Hashtable)errorList[0]; if(errors.ContainsKey("msg")) { error = errors["msg"].ToString(); } } } } if(string.IsNullOrEmpty(www.error)) { if(!String.IsNullOrEmpty(error)) { Debug.LogError(error); SetLoginStatus("Failed to get app.", ga); } else if(returnParam != null) { ArrayList resultList = (ArrayList)returnParam["results"]; List<AppFiguresGame> appFiguresGames = new List<AppFiguresGame>(); for(int s = 0; s < resultList.Count; s++) { Hashtable result = (Hashtable)resultList[s]; string name = result["title"].ToString(); string appID = result["store_id"].ToString(); string store = result["store"].ToString(); string developer = result["developer"].ToString(); string iconUrl = result["image"].ToString(); if(store.Equals("apple") || store.Equals("google_play") || store.Equals("amazon_appstore")) { appFiguresGames.Add(new AppFiguresGame(name, appID, store, developer, iconUrl, signup)); } } signup.AppFigComplete(gameName, appFiguresGames); } } else { Debug.LogError("Failed to find app: " + www.error + " " + www.text); SetLoginStatus("Failed to find app.", ga); } } catch(Exception e) { Debug.LogError("Failed to find app: " + e); SetLoginStatus("Failed to find app.", ga); } }
public static void GetAppFigures(Settings ga, GA_SignUp signup) { WWW www = new WWW(_gaUrl + "apps/search?query=" + WWW.EscapeURL(ga.GameName), null, GA_EditorUtilities.WWWHeadersWithAuthorization(ga.TokenGA)); GA_ContinuationManager.StartCoroutine(GetAppFiguresFrontend(www, ga, signup, ga.GameName), () => www.isDone); if(ga.AmazonIcon == null) { WWW wwwAmazon = new WWW("http://public.gameanalytics.com/resources/images/sdk_doc/appstore_icons/amazon.png"); GA_ContinuationManager.StartCoroutine(signup.GetAppStoreIconTexture(wwwAmazon, "amazon_appstore", signup), () => wwwAmazon.isDone); } if(ga.GooglePlayIcon == null) { WWW wwwGoogle = new WWW("http://public.gameanalytics.com/resources/images/sdk_doc/appstore_icons/google_play.png"); GA_ContinuationManager.StartCoroutine(signup.GetAppStoreIconTexture(wwwGoogle, "google_play", signup), () => wwwGoogle.isDone); } if(ga.iosIcon == null) { WWW wwwIos = new WWW("http://public.gameanalytics.com/resources/images/sdk_doc/appstore_icons/ios.png"); GA_ContinuationManager.StartCoroutine(signup.GetAppStoreIconTexture(wwwIos, "apple:ios", signup), () => wwwIos.isDone); } if(ga.macIcon == null) { WWW wwwMac = new WWW("http://public.gameanalytics.com/resources/images/sdk_doc/appstore_icons/mac.png"); GA_ContinuationManager.StartCoroutine(signup.GetAppStoreIconTexture(wwwMac, "apple:mac", signup), () => wwwMac.isDone); } if(ga.windowsPhoneIcon == null) { WWW wwwWindowsPhone = new WWW("http://public.gameanalytics.com/resources/images/sdk_doc/appstore_icons/windows_phone.png"); GA_ContinuationManager.StartCoroutine(signup.GetAppStoreIconTexture(wwwWindowsPhone, "windows_phone", signup), () => wwwWindowsPhone.isDone); } }
private static IEnumerator<WWW> CreateGameFrontend(WWW www, Settings ga, GA_SignUp signup, GAPlatformSignUp platform, AppFiguresGame appFiguresGame) { yield return www; try { Hashtable returnParam = null; string error = ""; if(!string.IsNullOrEmpty(www.text)) { returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text); if(returnParam.ContainsKey("errors")) { ArrayList errorList = (ArrayList)returnParam["errors"]; if(errorList != null && errorList.Count > 0) { Hashtable errors = (Hashtable)errorList[0]; if(errors.ContainsKey("msg")) { error = errors["msg"].ToString(); } } } } if(string.IsNullOrEmpty(www.error)) { if(!String.IsNullOrEmpty(error)) { Debug.LogError(error); SetLoginStatus("Failed to create game.", ga); signup.CreateGameFailed(); } else { ga.LastCreatedGamePlatform = (GAPlatform)((int)(platform + 1)); GetUserData(ga); signup.CreateGameComplete(); } } else { Debug.LogError("Failed to create game: " + www.error + " " + error); SetLoginStatus("Failed to create game.", ga); signup.CreateGameFailed(); } } catch { Debug.LogError("Failed to create game"); SetLoginStatus("Failed to create game.", ga); signup.CreateGameFailed(); } }
public static void CreateGame(Settings ga, GA_SignUp signup, int studioIndex, string gameTitle, string googlePlayPublicKey, GAPlatformSignUp platform, AppFiguresGame appFiguresGame) { Hashtable jsonTable = new Hashtable(); if(appFiguresGame != null) { jsonTable["title"] = gameTitle; jsonTable["store_id"] = appFiguresGame.AppID; jsonTable["store"] = appFiguresGame.Store; jsonTable["googleplay_key"] = string.IsNullOrEmpty(googlePlayPublicKey) ? null : googlePlayPublicKey; } else { jsonTable["title"] = gameTitle; jsonTable["store_id"] = null; jsonTable["store"] = null; jsonTable["googleplay_key"] = string.IsNullOrEmpty(googlePlayPublicKey) ? null : googlePlayPublicKey; } byte[] data = System.Text.Encoding.UTF8.GetBytes(GA_MiniJSON.JsonEncode(jsonTable)); string url = _gaUrl + "studios/" + ga.Studios[studioIndex].ID + "/games"; WWW www = new WWW(url, data, GA_EditorUtilities.WWWHeadersWithAuthorization(ga.TokenGA)); GA_ContinuationManager.StartCoroutine(CreateGameFrontend(www, ga, signup, platform, appFiguresGame), () => www.isDone); }
private static IEnumerator<WWW> SignupUserFrontend(WWW www, Settings ga, GA_SignUp signup) { yield return www; try { Hashtable returnParam = null; string error = ""; if(!string.IsNullOrEmpty(www.text)) { returnParam = (Hashtable)GA_MiniJSON.JsonDecode(www.text); if(returnParam.ContainsKey("errors")) { ArrayList errorList = (ArrayList)returnParam["errors"]; if(errorList != null && errorList.Count > 0) { Hashtable errors = (Hashtable)errorList[0]; if(errors.ContainsKey("msg")) { error = errors["msg"].ToString(); } } } } if(string.IsNullOrEmpty(www.error)) { if(!String.IsNullOrEmpty(error)) { Debug.LogError(error); SetLoginStatus("Failed to sign up.", ga); signup.SignUpFailed(); } else if(returnParam != null) { ArrayList resultList = (ArrayList)returnParam["results"]; Hashtable results = (Hashtable)resultList[0]; ga.TokenGA = results["token"].ToString(); ga.ExpireTime = results["exp"].ToString(); ga.JustSignedUp = true; //ga.SignUpOpen = false; ga.Studios = null; SetLoginStatus("Signed up. Getting data.", ga); GetUserData(ga); signup.SignUpComplete(); } } else { Debug.LogError("Failed to sign up: " + www.error + " " + error); SetLoginStatus("Failed to sign up.", ga); signup.SignUpFailed(); } } catch { Debug.LogError("Failed to sign up"); SetLoginStatus("Failed to sign up.", ga); signup.SignUpFailed(); } }
public static void SignupUser(Settings ga, GA_SignUp signup) { Hashtable jsonTable = new Hashtable(); jsonTable["email"] = ga.EmailGA; jsonTable["password"] = ga.PasswordGA; jsonTable["password_confirm"] = ga.PasswordConfirm; jsonTable["first_name"] = ga.FirstName; jsonTable["last_name"] = ga.LastName; jsonTable["studio_name"] = ga.StudioName; jsonTable["email_opt_out"] = ga.EmailOptIn; byte[] data = System.Text.Encoding.UTF8.GetBytes(GA_MiniJSON.JsonEncode(jsonTable)); WWW www = new WWW(_gaUrl + "user", data, GA_EditorUtilities.WWWHeaders()); GA_ContinuationManager.StartCoroutine(SignupUserFrontend(www, ga, signup), () => www.isDone); }
public IEnumerator<WWW> GetAppStoreIconTexture(WWW www, string storeName, GA_SignUp signup) { yield return www; try { if(string.IsNullOrEmpty(www.error)) { switch(storeName) { case "amazon_appstore": GameAnalytics.SettingsGA.AmazonIcon = www.texture; break; case "google_play": GameAnalytics.SettingsGA.GooglePlayIcon = www.texture; break; case "apple:ios": GameAnalytics.SettingsGA.iosIcon = www.texture; break; case "apple:mac": GameAnalytics.SettingsGA.macIcon = www.texture; break; case "windows_phone": GameAnalytics.SettingsGA.windowsPhoneIcon = www.texture; break; } signup.Repaint(); } } catch { } }