public void CheckForSavedData() { //Find the files where the data is being stored SaveVisitedRooms.GetWorkingVisitedRoomsDirectory(); SaveHintQuotes.GetWorkingHintQuotesDirectory(); SaveWholeBoard.GetWorkingBoardDirectory(); SaveElements.GetWorkingElementDirectory(); SaveHints.GetWorkingHintDirectory(); //Create files if (!File.Exists(SaveWholeBoard.WorkingBoardDirectory)) { File.Create(SaveVisitedRooms.WorkingVisitedRoomsDirectory); File.Create(SaveHintQuotes.WorkingHintQuotesDirectory); File.Create(SaveWholeBoard.WorkingBoardDirectory); File.Create(SaveElements.WorkingElementDirectory); File.Create(SaveHints.WorkingHintDirectory); } //If there is saved data - load it if (new FileInfo(SaveWholeBoard.WorkingBoardDirectory).Length != 0) { SaveVisitedRooms.Stored(); SaveHintQuotes.Stored(); SaveHints.Stored(); SaveWholeBoard.Stored(); SaveElements.StoredElements(); } else //Otherwise - setup a new game { StartSetUp(); } }
private void SaveTheGame() { Console.Clear(); SaveVisitedRooms.Saved(); SaveHintQuotes.Saved(); SaveElements.Saved(); SaveWholeBoard.Saved(); Console.WriteLine("You game has been saved, Seen you soon."); }
public static void Saved() { SaveHintQuotes SavedHintsLists = new SaveHintQuotes { SeenHints = string.Join(",", Game.Collected_Hints), }; File.WriteAllText(WorkingHintQuotesDirectory, JsonConvert.SerializeObject(SavedHintsLists)); }
private void EndOfGame() { if (Number_of_Lives == 0) { EndPage.LoseScene(); } else { EndPage.WinScene(); } EndPage.ThankYouAsciiArt(); SaveHintQuotes.ResetHintQuotesFile(); SaveVisitedRooms.ResetVisitedRoomsFile(); SaveHints.ResetHintsFile(); SaveWholeBoard.ResetBoardFile(); SaveElements.ResetElementsFile(); }