private void LoadGame() { // list available save files var existingFiles = ShipwreckController.GetExistingSaveFileNames(); if (existingFiles.Count == 0) { Log.Warning("There are no saved games"); ViewHelpers.Continue(); return; } existingFiles.Add("Exit"); var fileToLoad = Prompt.Select("Which game would you like to load?", existingFiles); if (fileToLoad == "Exit") { return; } fileToLoad = FileHelper.AddExtension(fileToLoad, ".json"); // try load file if (ShipwreckController.TryLoadGame(fileToLoad, out var game)) { ShipwreckController.StartGame(game); } else { Log.Error($"Unable to load {fileToLoad}"); } }
private void SaveGame() { var fileName = Prompt.Input <string>("File Name", Shipwreck.CurrentGame.SaveFileName); if (string.IsNullOrEmpty(fileName)) { return; } var success = ShipwreckController.TrySaveGame(fileName); if (success) { Log.Success("Your game was successfully saved"); } else { Log.Warning("The game was not saved"); } }
private void StartNewGame() { ShipwreckController.SetupNewGame(); }