public static void DeleteParty() { string path = PersistenDataManager.GetPersistentPath("/Save/PartySave.gd"); if (File.Exists(path)) { File.Delete(path); } }
public static bool LoadParty() { string path = PersistenDataManager.GetPersistentPath("/Save/PartySave.gd"); if (File.Exists(path)) { GameStateSave = (PartySave)PersistenDataManager.Deserialize(path); return(true); } else { return(false); } }
public static void SaveParty() { string path = PersistenDataManager.GetPersistentPath("/Save/PartySave.gd"); GameStateSave.Generate( InventoryPlayer.Instance.knowsItems, ConvertPlanetToSerialiable(EarthManager.Instance.Cells), ConvertPlayerPositionToSerializable(EarthManager.Instance.playerPositions), TimeManager.Instance.GenerateSave(), InventoryPlayer.Instance.nbItems, WorldManager.Instance.GenerateSave(), InventoryPlayer.Instance.givedOject, InteractablePNJ.GenerateSave().ToArray() ); GameStateSave.moneyStock = InventoryPlayer.Instance.moneyStock; GameStateSave.version = GameManager.VERSION; PersistenDataManager.Serialize(GameStateSave, path); }
public static object Deserialize(string pathFile, RuntimePlatform platform) { string path = GetStreamingAssetPath(platform) + pathFile; string persistentPath = PersistenDataManager.GetPersistentPath(pathFile); Debug.Log(string.Format("Deserialize strPath[{0}] psrtPath[{1}]", path, persistentPath)); BinaryFormatter bf = new BinaryFormatter(); if (File.Exists(path)) { if (platform != RuntimePlatform.Android) { FileStream reader = File.OpenRead(path); object obj = bf.Deserialize(reader); reader.Close(); return(obj); } else { return(null); } } else if (platform == RuntimePlatform.Android) { byte[] file = ReadAndroidBytes(path); File.WriteAllBytes(persistentPath, file); StreamReader wrp = new StreamReader(persistentPath); object obj = bf.Deserialize(wrp.BaseStream); wrp.Close(); return(obj); } else { return(null); } }