/// <summary> /// Load the data from the file /// </summary> public void LoadGame() { if (File.Exists(m_path)) { if (PC_GameSetup.Game_Settings.ENCRYPT_SAVE_FILES) { m_gameData = PC_ComplexFormatter.LoadObjectFromDESFile <PC_SaveData>(m_path); } else if (PC_GameSetup.Game_Settings.USE_BINARY_SAVE_FILES) { m_gameData = PC_ComplexFormatter.LoadObjectFromBinaryFile <PC_SaveData>(m_path); } else { m_gameData = m_gameData = PC_ComplexFormatter.LoadObjectFromJSONFile <PC_SaveData>(m_path); } PC_Casino.Instance.SetSaveData(m_gameData); Debug.Log("Loaded the game data from " + m_path); } else { // We create initial Data PC_Casino.Instance.InitData(); SaveGame(); PC_EventManager.TriggerEvent(PC_EventSetup.GAME_LOADED); } }
private void DESToJSON() { string EncryptedFilePath = EditorUtility.OpenFilePanel("Select the file that will be decrypted", Application.dataPath, m_jsonToDecrypt.name + ".JSON"); string jsonString = PC_ComplexFormatter.LoadJSONStringFromDESFile(EncryptedFilePath, EncryptionSetup.PRIVATE_KEY); string WhereToSave = EditorUtility.OpenFolderPanel("Select the folder where the JSON file will be created", Application.dataPath, m_jsonToDecrypt.name + ".JSON"); PC_ComplexFormatter.SaveJSONStringToJSONFile(jsonString, WhereToSave); }
/// <summary> /// Save the game to a file - Just a test - set your data as needed /// </summary> public void SaveGame() { PC_SaveData currentData = PC_Casino.Instance.GetCommonData(); m_gameData.coins = currentData.coins; m_gameData.hasCoinCase = currentData.hasCoinCase; if (PC_GameSetup.Game_Settings.ENCRYPT_SAVE_FILES) { PC_ComplexFormatter.SaveObjectToDESFile(m_gameData, m_path); } else if (PC_GameSetup.Game_Settings.USE_BINARY_SAVE_FILES) { PC_ComplexFormatter.SaveObjectToBinaryFile(m_gameData, m_path); } else { PC_ComplexFormatter.SaveObjectoToJSONFile(m_gameData, m_path); } Debug.Log("Saved the game data in " + m_path); }
private void JSONToDES() { string path = EditorUtility.OpenFolderPanel("Select the folder where the encrypted file will be created", Application.dataPath, m_jsonToEncrypt.name + ".data"); PC_ComplexFormatter.SaveJSONStringToDESFile(m_jsonToEncrypt.text, path, EncryptionSetup.PRIVATE_KEY); }