示例#1
0
        public static void DeleteParty()
        {
            string path = PersistenDataManager.GetPersistentPath("/Save/PartySave.gd");

            if (File.Exists(path))
            {
                File.Delete(path);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }
示例#4
0
    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);
        }
    }