// Save and load game. public static void WriteSaveGameSummary(SaveGameSummary summary) { var saveSummaries = ReadSummaryFile(); saveSummaries[summary.GameData.GameID] = summary; WriteSummaryFile(saveSummaries); }
public void TestSaveGame() { var data1 = new GameData(99, "Aleasha"); var summary1 = new SaveGameSummary(data1, "Large Test Level"); var saveGame = new SaveGame(summary1); Assert.AreEqual(99, summary1.GameData.GameID); }
public void TestSaveGameSummary() { var data1 = new GameData(99, "Aleasha"); var summary1 = new SaveGameSummary(data1, "Large Test Level"); Assert.AreEqual(99, summary1.GameData.GameID); Assert.AreEqual("Aleasha", summary1.GameData.GameIdentifier); Assert.AreEqual("Large Test Level", summary1.CurrentLevelName); Assert.AreEqual("Game Identifier: Aleasha, Current Level: Large Test Level", summary1.ToString()); }
public void TestCharacterSelectionNew() { for (int i = 1; i < 4; i++) { var summary = new SaveGameSummary(new GameData(i, "Test" + i.ToString()), "TestLevel1"); ApplicationSettings.AddSaveGame(i); UserDataManager.WriteSaveGameSummary(summary); } var keyList = new List <string> { "4" }; UserInputHandler.AddKeyboardInput(keyList); var characterSelectionMenu = new CharacterSelectionMenu(); Assert.AreEqual(-2, characterSelectionMenu.SelectCharacterToPlay()); }
public bool LoadFile(string alt_filename) { if (alt_filename.Equals("") && isLoaded()) { return(true); } string filename = (alt_filename.Equals("")) ? summary.getFileName() : alt_filename; try { SaveData save_data = SaveData.Load(filename); SaveGameSummary newSummary = save_data.GetValue <SaveGameSummary>("summary"); if (!newSummary.savegame_version.Equals(Central.Instance.game_saver.savegame_version)) { DeleteFile(); Debug.Log("Found Savegame version mismatch " + newSummary.savegame_version + " does not match game version " + Central.Instance.game_saver.savegame_version + "\n"); return(false); } persistent = save_data.GetValue <SaveState>("persistent"); midlevels = save_data.GetValue <SaveState[]>("midlevels"); if (getCurrentWave() == -1) { rawText = save_data.raw_text; } summary = newSummary; } catch (Exception e) { DeleteFile(); Debug.LogError($"Deleting file {filename}\n"); Debug.LogError($"{e.Message}\n"); // Tracker.ThrowNonFatal(e.ToString()); return(false); } isLoaded(true); return(true); }
public GameData CreateNewCharacter() { var parameters = new GameData(); parameters = GetCharacterName(parameters); if (parameters == null) { return(parameters); } parameters.GameID = ApplicationSettings.GenerateNextGameId(); var saveGameSummary = new SaveGameSummary(parameters, "NEWGAME"); UserDataManager.WriteSaveGameSummary(saveGameSummary); return(parameters); }