public void Player_Data_Save() { FireBaseManager.Instance.LogEvent("Setting_Data_Save"); string jsonStr = JsonUtility.ToJson(DataManager.Instance.state_Player); string aes = AESCrypto.AESEncrypt128(jsonStr); StartCoroutine(Save(aes)); }
/// <summary> /// 집 정보 저장 하기 /// </summary> /// <param name="SaveData"></param> public void Save(State_Player SaveData) { string GameInfoPath = Application.persistentDataPath + PlayerDataName; BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(GameInfoPath); string jsonStr = JsonUtility.ToJson(SaveData); string aes = AESCrypto.AESEncrypt128(jsonStr); bf.Serialize(file, aes); file.Close(); }
/// <summary> /// 플레이어 데이터 저장 /// </summary> public void Save_Player_Data() { Save(state_Player); #if UNITY_ANDROID GoogleManager.Instance.isPopup = false; GoogleManager.Instance.Player_Data_Save(); #elif UNITY_IOS CloudOnceManager.Instance.isSave = false; string jsonStr = JsonUtility.ToJson(DataManager.Instance.state_Player); string aes = AESCrypto.AESEncrypt128(jsonStr); CloudVariables.Player_Data = aes; Cloud.OnCloudSaveComplete += CloudOnceManager.Instance.CloudeSave; Cloud.Storage.Save(); #endif }
/// <summary> /// 자기 정보 가져오기 /// </summary> /// <returns></returns> public State_Player Load_Player() { string InfoPath = Application.persistentDataPath + PlayerDataName; State_Player playerInfoSave = new State_Player(); if (File.Exists(InfoPath)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(InfoPath, FileMode.Open); var str = (string)bf.Deserialize(file); file.Close(); if (!string.IsNullOrEmpty(str)) { string aes = AESCrypto.AESDecrypt128(str); var data = JsonUtility.FromJson <State_Player>(aes); playerInfoSave = data; } } else { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(InfoPath); State_Player data = new State_Player(); playerInfoSave = data; string jsonStr = JsonUtility.ToJson(playerInfoSave); string aes = AESCrypto.AESEncrypt128(jsonStr); bf.Serialize(file, aes); file.Close(); } return(playerInfoSave); }
public void Buy(Dictionary <string, object> data) { Debug.Log((int)data["shop_type"]); switch ((Shop_itme_type)(int)data["shop_type"]) { case Shop_itme_type.ads: DataManager.Instance.state_Player.RemoveAds = true; transform.GetComponentsInChildren <ShopItem>(true)[0].gameObject.SetActive(false); AdsControl.Instance.BannerShow(); break; case Shop_itme_type.package: FindObjectOfType <MainScene>().PlayPackageAni(); for (int i = 0; i < 5; i++) { int item = (int)data["item_" + i]; if (item == 0) { continue; } switch ((Item_Type)i) { case Item_Type.Boom: DataManager.Instance.state_Player.item_Localdata.Boom += item; break; case Item_Type.Hammer: DataManager.Instance.state_Player.item_Localdata.Hammer += item; break; case Item_Type.Star: DataManager.Instance.state_Player.item_Localdata.Star += item; break; case Item_Type.Hint: DataManager.Instance.state_Player.item_Localdata.Hint += item; break; case Item_Type.coin: GM.GetInstance().AddDiamond(item); break; default: break; } } GameObject obj = UnityEngine.Object.Instantiate <GameObject>(Resources.Load("Prefabs/shop_complet") as GameObject); obj.GetComponent <ShopComplete>().Set_Item(data); DialogManager.GetInstance().show(obj); break; case Shop_itme_type.gift: AdsControl.Instance.reward_Type = Reward_Type.shop_ads; AdsControl.Instance.ShowRewardedAd(); break; case Shop_itme_type.gold: Debug.Log("골드~~ " + (int)data["item_4"]); GM.GetInstance().AddDiamond((int)data["item_4"]); break; case Shop_itme_type.item: if (DataManager.Instance.state_Player.LocalData_Diamond >= (int)data["price"]) { GM.GetInstance().ConsumeGEM((int)data["price"]); for (int i = 0; i < 5; i++) { int item = (int)data["item_" + i]; if (item == 0) { continue; } FindObjectOfType <MainScene>().PlayitemAni((Item_Type)i); switch ((Item_Type)i) { case Item_Type.Boom: FireBaseManager.Instance.LogEvent("Shop_bomb"); DataManager.Instance.state_Player.item_Localdata.Boom += item; break; case Item_Type.Hammer: FireBaseManager.Instance.LogEvent("Shop_cross_hammer"); DataManager.Instance.state_Player.item_Localdata.Hammer += item; break; case Item_Type.Star: FireBaseManager.Instance.LogEvent("Shop_color_star"); DataManager.Instance.state_Player.item_Localdata.Star += item; break; case Item_Type.Hint: FireBaseManager.Instance.LogEvent("Shop_magnigier"); DataManager.Instance.state_Player.item_Localdata.Hint += item; break; case Item_Type.coin: GM.GetInstance().AddDiamond(item); break; default: break; } } obj = UnityEngine.Object.Instantiate <GameObject>(Resources.Load("Prefabs/shop_complet") as GameObject); obj.GetComponent <ShopComplete>().Set_Item(data); DialogManager.GetInstance().show(obj); } break; default: break; } Game1Manager.GetInstance()?.Set_Txt_Item(); G3BoardManager.GetInstance()?.Set_Item_Txt(); DataManager.Instance.Save_Player_Data(); #if UNITY_ANDROID GoogleManager.Instance.isPopup = false; GoogleManager.Instance.Player_Data_Save(); #elif UNITY_IOS string jsonStr = JsonUtility.ToJson(DataManager.Instance.state_Player); string aes = AESCrypto.AESEncrypt128(jsonStr); CloudVariables.Player_Data = aes; Cloud.Storage.Save(); #endif }