Exemplo n.º 1
0
        private static void InitialiseMetadata()
        {
            MetadataEntries = new SaveGameMetadata[SAVE_SLOT_COUNT];
            string basePath = SAVE_FILE_DIRECTORY + METADATA_FILE_PREFIX;

            for (int i = 0; i < SAVE_SLOT_COUNT; i++)
            {
                try
                {
                    string json = File.ReadAllText(basePath + i);
                    MetadataEntries[i] = SaveGameMetadata.FromJSON(json);
                }
                catch (System.Exception) { }
            }
        }
Exemplo n.º 2
0
        public static bool SaveGame(int saveFileIndex)
        {
            SaveGameMetadata metadata = new SaveGameMetadata();

            metadata.SaveTimestamp = System.DateTime.Now.Ticks;

            SaveGameData saveData = new SaveGameData();

            saveData.CurrentBase = null; // TODO
            saveData.Survivors   = SurvivorModel.AllModels.ToArray();

            try
            {
                File.WriteAllText(SAVE_FILE_DIRECTORY + METADATA_FILE_PREFIX + saveFileIndex, metadata.ToJSON());
                File.WriteAllText(SAVE_FILE_DIRECTORY + SAVE_FILE_PREFIX + saveFileIndex, saveData.ToJSON());
            }
            catch (System.Exception)
            {
                Debug.Log("An error occured while saving the game");
                return(false);
            }

            return(true);
        }