IEnumerator getURLData(string url, WWWForm form, bool postType) { if (postType) { ghsObj oldGhsObj = ghs; UnityWebRequest www = UnityWebRequest.Post(url, form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { // Debug.Log(www.downloadHandler.text); ghs = JsonUtility.FromJson <ghsObj>(www.downloadHandler.text); if (oldGhsObj.score > 0) { ghs.score = oldGhsObj.score; } if (settings) { ghs.userName = settings.userNameSignIn.text; ghs.password = settings.passwordSignIn.text; settings.setData(ghs); } saveData(ghs); } } else { } }
public void checkImageForDifferences() { ghs = loadSaveData(); string prevIcon = ghs.user_icon; StartCoroutine(Application.persistentDataPath + "/WorldDefer/image/user_icon.png"); if (prevIcon != ghs.user_icon) { ghs.useBlob = "true"; saveData(ghs); string base64Decoded; byte[] data = System.Convert.FromBase64String(ghs.user_icon); base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data); string[] base64split = base64Decoded.Split(','); byte[] Bytes = System.Convert.FromBase64String(base64split[1]); Texture2D tex = new Texture2D(500, 700); tex.LoadImage(Bytes); saveImage(tex, "user_icon.png"); } else { Debug.Log("User Icon is the same!"); } }
public static void saveData(ghsObj g) { BinaryFormatter bf = new BinaryFormatter(); Stream stream = File.Open(Application.persistentDataPath + "/WorldDefer/saves/save.sav", FileMode.OpenOrCreate); bf.Serialize(stream, g); stream.Close(); Debug.Log("Game has saved!"); }
public ghsObj loadSaveData() { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.persistentDataPath + "/WorldDefer/saves/save.sav", FileMode.Open); ghs = bf.Deserialize(stream) as ghsObj; Debug.Log("Found the save file!"); stream.Close(); Debug.Log("Save File Loaded :" + ghs); return(ghs); }
// Use this for initialization void Start() { signInBool = false; signUpBool = false; socialFail = ""; socialSuccess = ""; ghsObj = ghs.getData(); setData(ghsObj); if (ghsObj != null) { checkSocialStatus(ghsObj); } }
public void signInFunc() { ghs.ghsSignIn(userNameSignIn.text, passwordSignIn.text); ghsObj = ghs.getData(); if (ghsObj.success == "true") { disableAll(); setData(ghsObj); getUserIcon("true", ghsObj.user_icon); } else { popUperrorMsg.text = ghsObj.error_message; } }
void Start() { PlayGamesPlatform.Activate(); site = "https://ghostszmusic.com/api/ghs_api/v1/"; #if UNITY_EDITOR site = "http://localhost:3000/api/ghs_api/v1/"; #endif ghs = getData(); dataPath = Application.persistentDataPath + "/WorldDefer/saves/save.sav"; Instance = this; scene = SceneManager.GetActiveScene(); sceneName = scene.name; if (sceneName == "Settings") { settings = GetComponent <settingsScr>(); } }
// Use this for initialization void Start() { if (_manager == null) { _manager = GameObject.FindGameObjectWithTag("manager"); } if (sm == null) { sm = _manager.GetComponent <scoreManager>(); } if (con == null) { con = GameObject.FindGameObjectWithTag("Player").GetComponent <controller>(); } gu = this.gameObject.transform.parent.gameObject.GetComponent <ghsUtility>(); ghs = gu.getData(); preHS.text = sm.scoreTXT.text; preGOHS.text = sm.scoreTXT.text; if (ghs.user_icon != null) { getUserIcon(ghs.useBlob, ghs.user_icon, userIconPS); getUserIcon(ghs.useBlob, ghs.user_icon, userIconGOS); } if (ghs.name != null) { userNamePS.text = ghs.name; userNameGOS.text = ghs.name; } else { userNamePS.text = "username"; userNameGOS.text = "username"; } rewardBtn.enabled = !con.rewarded; }
public void setData(ghsObj g) { if (g.name == null) { userName.text = "UserName"; } else { userName.text = g.name; } if (g.user_icon == null) { Debug.Log("No userIcon available!"); } else { getUserIcon(g.useBlob, g.user_icon); } // checkSocialStatus(g); }
public void checkSocialStatus(ghsObj g) { if (g != null) { if (g.token.Length >= 2) { ghsCheck.text = socialSuccess; } else { ghsCheck.text = socialFail; } if (Social.localUser.authenticated) { googCheck.text = socialSuccess; } else { googCheck.text = socialSuccess; } } }
public void createDirs() { if (!Directory.Exists(Application.persistentDataPath + "/WorldDefer/")) { Directory.CreateDirectory(Application.persistentDataPath + "/WorldDefer/"); } if (!Directory.Exists(Application.persistentDataPath + "/WorldDefer/image/")) { Directory.CreateDirectory(Application.persistentDataPath + "/WorldDefer/image/"); } if (!Directory.Exists(Application.persistentDataPath + "/WorldDefer/temp/")) { Directory.CreateDirectory(Application.persistentDataPath + "/WorldDefer/temp/"); } if (!Directory.Exists(Application.persistentDataPath + "/WorldDefer/saves/")) { Directory.CreateDirectory(Application.persistentDataPath + "/WorldDefer/saves/"); ghsObj g = new ghsObj(); ghsUtility.saveData(g); } }
public void googleSignIn() { if (Social.localUser.authenticated) { PlayGamesPlatform.Instance.SignOut(); } else { PlayGamesPlatform.Instance.Authenticate((bool success) => { if (success) { Debug.Log("Signed In"); ghs = loadSaveData(); Debug.Log("Google Username: "******"Failed to sign in!"); } }); } }
public void gameOverQuit() { int score = int.Parse(sm.scoreTXT.text); ghs = gu.getData(); ghsUtility.saveData(ghs); Debug.Log("Score: " + score); if (Social.localUser.authenticated) { gu.addScoreToLB(GPGSIds.leaderboard_world_defenders, score); } if (ghs.token != null) { if (score >= 100 && score > ghs.score) { ghs.score = score; StartCoroutine(gu.ghsSendScore(score)); } } quitGame(); }
public ghsObj getData() { ghs = loadSaveData(); return(ghs); }