public void SaveToText() { // save animation Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(0, 43); Console.WriteLine("saving..."); var WaitMan = new WaitMan(9, 43); WaitMan.Start(); Thread.Sleep(2500); // settings (only values 1 or 0) n.WriteLine("sounds = 1"); n.WriteLine("introSong = 0"); n.WriteLine("resize = 0"); // player data n.WriteLine("LastRoom = 1"); n.WriteLine("LastInventory = 0"); n.Flush(); n.Close(); WaitMan.Stop(); Console.SetCursorPosition(0, 43); Console.WriteLine("GAME SAVED"); Music.SystemSound(); }
public bool CheckSaveFile() { try { // check if save_file.txt is present/reachable using (var fileStream = new FileStream("../../../../save_file.txt", FileMode.Open, FileAccess.Read)) return(true); } catch (IOException) { // error message // creates loading animation, then informs about missing save file Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(0, 43); Console.WriteLine("Loading..."); var WaitMan = new WaitMan(10, 43); WaitMan.Start(); Thread.Sleep(1500); WaitMan.Stop(); Console.SetCursorPosition(0, 43); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("LOADING FAILED - save file NOT FOUND"); return(false); } }
public static void LoadingAnimation() { // loading animation Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(0, 43); Console.WriteLine("Loading..."); var WaitMan = new WaitMan(10, 43); WaitMan.Start(); Thread.Sleep(2500); WaitMan.Stop(); // after last loading operation, press enter to start loaded game Console.SetCursorPosition(0, 43); Console.Write("GAME LOADED - "); Console.ForegroundColor = ConsoleColor.White; Console.Write("press"); Console.ForegroundColor = ConsoleColor.White; Console.Write(" ENTER"); Console.ForegroundColor = ConsoleColor.White; Console.Write(" to START"); Music.SystemSound(); while (Console.ReadKey().Key != ConsoleKey.Enter) { } }
public static void NewGameMenu() { Console.SetCursorPosition(0, 13); Console.ForegroundColor = ConsoleColor.White; // this and ONLY this WriteLine needs 85 characters in order to delete previous "press ENTER to START" Console.WriteLine(" version 0.2 \n\n"); Console.WriteLine(" > NEW GAME"); Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine(" LOAD GAME"); Console.WriteLine(" SETTINGS"); Console.WriteLine(" QUIT"); // sets text to black, so no input in menu is visible Console.ForegroundColor = ConsoleColor.Black; while (true) { var ch = Console.ReadKey(false).Key; switch (ch) { case ConsoleKey.Enter: // when loading after previous failed loading, this will clear the bottom error text Console.SetCursorPosition(0, 43); Console.WriteLine(" "); // plays quick loading animation, then starts GAME Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(0, 43); Console.WriteLine("Starting..."); var WaitMan = new WaitMan(11, 43); WaitMan.Start(); Thread.Sleep(1500); WaitMan.Stop(); Game.ClearSpace(); Game.Intro(); return; case ConsoleKey.DownArrow: Music.MenuSound(); LoadGameMenu(); return; case ConsoleKey.UpArrow: Music.MenuSound(); NewGameMenu(); return; case ConsoleKey.Escape: Music.NoSound(); QuitGame.QuitFromMenu(); return; } } }