private void Start() { xpPoint = 0; string xpStringEncrypted = PlayerPrefs.GetString(XP_COIN_SAVE, ""); if (xpStringEncrypted != "") { string xpStringDecrypted = CryptoEngine.Decrypt(xpStringEncrypted, XP_ENCRYPTION_KEY); xpPoint = Int32.Parse(xpStringDecrypted); } //Debug.Log(xpPoint); OnXPUpdateAction?.Invoke(); }
public void CheckXPUpdate() { // string xpStringEncrypted = PlayerPrefs.GetString(XP_COIN_SAVE, ""); // string xpStringDecrypted = ""; // if (xpStringEncrypted != "") // { // xpStringDecrypted = CryptoEngine.Decrypt(xpStringEncrypted, XP_ENCRYPTION_KEY); // } // xpPoint = xpStringDecrypted != "" ? Int32.Parse(xpStringDecrypted) : xpPoint; //xpPoint = xpPoint >= PlayerPrefs.GetInt(XP_COIN_SAVE, 0) ? xpPoint : PlayerPrefs.GetInt(XP_COIN_SAVE, 0); OnXPUpdateAction?.Invoke(); XP_Equalization(); }
public void XP_Equalization() { if (PlayFabClientAPI.IsClientLoggedIn()) { try { Dictionary <string, int> vc = new Dictionary <string, int>(); PlayFabClientAPI.GetUserInventory( new GetUserInventoryRequest { }, GetResult => { vc = GetResult.VirtualCurrency; //Debug.Log("GOLD :" + vc["GD"] + " | XP:" + vc["XP"]); //Debug.Log("XP Point on Game: " + xpPoint); if (CoinSystem.instance != null) { CoinSystem.instance.SetBalance(vc["GD"]); } if (vc["XP"] >= xpPoint) { xpPoint = vc["XP"]; string xpStringDecrypted = xpPoint.ToString(); string xpStringEncrypted = CryptoEngine.Encrypt(xpStringDecrypted, XP_ENCRYPTION_KEY); PlayerPrefs.SetString(XP_COIN_SAVE, xpStringEncrypted); // PlayerPrefs.SetInt("XP_POINT", xpPoint); } else { PlayfabController.Instance.Add_XP(xpPoint - vc["XP"]); } OnXPUpdateAction?.Invoke(); }, (op) => { Debug.LogError("unable to gets xp data from server !!!" + op.ErrorMessage); } ); } catch (Exception e) { // Crashlytics.Log("XP_System.Add_XP() : " + e); // Crashlytics.LogException(e); Debug.LogError("unable to gets xp data from server !!!" + e.Message); } } OnXPUpdateAction?.Invoke(); }