//Print the text logo public static void LogoPrint() { Console.WriteLine(Environment.NewLine); Print.Red(" ██████╗ ██████╗ █████╗ ██████╗ ██████╗ ███╗ ██╗ ██████╗ ██╗ ██╗███████╗███████╗████████╗"); Print.Red(" ██╔══██╗██╔══██╗██╔══██╗██╔════╝ ██╔═══██╗████╗ ██║ ██╔═══██╗██║ ██║██╔════╝██╔════╝╚══██╔══╝"); Print.Red(" ██║ ██║██████╔╝███████║██║ ███╗██║ ██║██╔██╗ ██║ ██║ ██║██║ ██║█████╗ ███████╗ ██║ "); Print.Red(" ██║ ██║██╔══██╗██╔══██║██║ ██║██║ ██║██║╚██╗██║ ██║▄▄ ██║██║ ██║██╔══╝ ╚════██║ ██║ "); Print.Red(" ██████╔╝██║ ██║██║ ██║╚██████╔╝╚██████╔╝██║ ╚████║ ╚██████╔╝╚██████╔╝███████╗███████║ ██║ "); var bottom = " ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚══▀▀═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ "; Print.Red(bottom); for (int i = 0; i < bottom.Length; i++) { if (i == 0 || i == 1) { Console.Write(" "); } else { Print.RedW("*"); } } Console.WriteLine(Environment.NewLine); }
//Main menu public void StartMenu(Menu menuObject) { _menuObject = menuObject; //Start the music menuMusic.PlaySound(menu); bool continueCode = false; bool firstTimeRunningProgram = true; string option; bool error = false; string errorMsg = default; do { //print the logo if (firstTimeRunningProgram) { Print.LogoPrint(); firstTimeRunningProgram = false; } Print.ClearAllScreen(); Print.EnemyPrint("Ending dragon"); top = 13; //Print the menu for (int i = 0; i < startMenuOptions.Length; i++) { Console.SetCursorPosition(left, top); Console.WriteLine($"{i + 1}. {startMenuOptions[i]}"); top++; } //If there are errors (or messages to the player) they will be printed here. if (error) { Console.SetCursorPosition(left, top + 2); Print.Red(errorMsg); errorMsg = default; } Console.SetCursorPosition(left, top + 1); Console.Write("Choose your option> "); Console.CursorVisible = true; option = Console.ReadLine(); Console.CursorVisible = false; var sounds = _menuObject.SoundList(); AudioPlaybackEngine sound = new AudioPlaybackEngine(); sound.PlaySound(sounds[1]); Thread.Sleep(700); sound.Dispose(); switch (option) { //New game case "1": error = false; if (File.Exists(pathway + file)) { File.Delete(pathway + file); Directory.Delete(pathway); } int check = FileHandling.CheckFileFolderExistance(); if (check == 1 || check == 2) { NewGame(); } break; //Continue adventure case "2": string pathwayFull = string.Concat(pathway, file); if (FileHandling.CheckFileFolderExistance() == 1 || FileHandling.CheckFileFolderExistance() == 2) { error = true; errorMsg = "No previous games saved"; } else { if (new FileInfo(pathwayFull).Length == 0) { error = true; errorMsg = "No previous games saved"; } else { playerList = FileHandling.BinaryDeSerializer(playerList); error = false; NewGame(); } } break; //Exit game case "3": Thread.Sleep(1000); Environment.Exit(0); break; default: error = true; errorMsg = "Wrong menu choice"; break; } } while (!continueCode); }
//In game menyn private void InGameMenu() { bool continueCode = false; string option; bool error = false; string errorMsg = default; int saveReminder = default; do { //If the player has killed the dragon player will be over 20 strength. //so the check is for if player is back on lvl1 but strength is > 20, //then you have finished the game if (player.Level == 1 && player.KilledCreatures > 5) { Print.ClearAllScreen(); Print.EnemyPrint("Ending dragon"); Console.SetCursorPosition(left, top); Print.Yellow("You made it til the end, the dragon is defeted. You´re a hero!"); top++; Console.SetCursorPosition(left, top); Print.Yellow($"Killed enemies: {player.KilledCreatures}"); Console.ReadKey(); continueCode = true; } //if player is alive else { if (player.Alive) { Print.ClearAllScreen(); //Front logo on menu screen Print.EnemyPrint("Ending dragon"); player.PrintCurrentPlayerStatus(); top = 13; left = 45; for (int i = 0; i < inGameMenuOptions.Length; i++) { Console.SetCursorPosition(left, top); Console.WriteLine($"{i + 1}. {inGameMenuOptions[i]}"); top++; } //Reminder for the player to save if (saveReminder >= 5 && saveReminder < 10) { Console.SetCursorPosition(left, top - 7); Print.Yellow("Don´t forget to save your progress!"); } else if (saveReminder >= 10) { saveReminder = default; } //Error message is printed out (if there are any) if (error) { Console.SetCursorPosition(left, top + 2); Print.Red(errorMsg); errorMsg = default; } Console.SetCursorPosition(left, top + 1); Console.Write("Choose your option> "); Console.CursorVisible = true; option = Console.ReadLine(); Console.CursorVisible = false; var sounds = _menuObject.SoundList(); AudioPlaybackEngine sound = new AudioPlaybackEngine(); sound.PlaySound(sounds[1]); Thread.Sleep(700); sound.Dispose(); switch (option) { case "1": //Go explore error = false; Thread.Sleep(500); Explore explore = new Explore(); menuMusic.PauseSound(); explore.GoAdventure(player, _menuObject); //If you died, play game over sound. if (!player.Alive) { continueCode = true; var listsound = _menuObject.SoundList(); AudioPlaybackEngine dead = new AudioPlaybackEngine(); dead.PlaySound(listsound[12]); Print.PlayerStatsPrint(player); } //else resume menu music and increse reminder counter else { menuMusic.ResumeSound(); saveReminder++; } break; case "2": InventoryGui inventory = new InventoryGui(); inventory.InventoryMenu(player, _menuObject); break; case "3": //Go shop menuMusic.PauseSound(); var soundList = _menuObject.SoundList(); AudioPlaybackEngine shopMusic = new AudioPlaybackEngine(); shopMusic.PlaySound(soundList[2]); Shop theShop = new Shop(_menuObject, player); theShop.GoIn(player); //shop is the sound for the shop that´s disposing shopMusic.Dispose(); menuMusic.ResumeSound(); error = false; saveReminder++; break; case "4": //Save your game errorMsg = FileHandling.SavePlayerToFile(playerList); error = true; saveReminder = 0; break; case "5": //Exit game Thread.Sleep(500); Environment.Exit(0); break; default: //If anything else is pressed, errormessage is set. error = true; errorMsg = "Wrong menu choice"; break; } } else { continueCode = true; } } } while (!continueCode); }
/****************************************************************** * NEW GAME MENU ******************************************************************/ private void NewGame() { Thread.Sleep(500); Print.ClearAllScreen(); Print.DragonPrint(); string name; bool emptyName = true; string errorMsg = default; string pathwayFull = string.Concat(pathway, file); //If no filepath is found if (new FileInfo(pathwayFull).Length == 0) { do { if (!string.IsNullOrEmpty(errorMsg)) { Console.SetCursorPosition(left, top + 1); Print.Red(errorMsg); errorMsg = default; } //User input for name Print.SetTopLeftCursorPosToStandard(); Console.Write("What is our heros name?> "); Console.CursorVisible = true; name = Console.ReadLine(); Console.CursorVisible = false; var sounds = _menuObject.SoundList(); AudioPlaybackEngine sound = new AudioPlaybackEngine(); sound.PlaySound(sounds[1]); Thread.Sleep(700); sound.Dispose(); //Check if name is empty if (!string.IsNullOrEmpty(name)) { emptyName = false; } else { top = 13; Console.SetCursorPosition(left, top + 1); errorMsg = "Name can not be empty"; } } while (emptyName); //Creating a new player and saves it to a list player = new Player(name); playerList.Add(player); //Saving the player list to a file. FileHandling.BinarySerializer(playerList); } else { foreach (var item in playerList) { player = item; } } player.PrintCurrentPlayerStatus(); InGameMenu(); }
//Dragon animation endfight public static void DragonAnimation(Player player, Enemy enemy, List <string> fightText, Menu _menuObject) { List <String> dragon = new List <String>(); { dragon.Add("<~>"); dragon.Add(@" \ \,_____"); dragon.Add(@" ___`\"); dragon.Add(@" \('>\`-__"); dragon.Add(" ~ ~~~--__"); dragon.Add(@" ______(@\"); dragon.Add(@" /******~~~~\"); dragon.Add(@" \ `--____"); dragon.Add(" / ~~~--_____ ~~~/"); dragon.Add(" / `~~~~~ "); dragon.Add(" / "); dragon.Add(" / "); } List <String> dragonFire = new List <String>(); { dragonFire.Add("<~>"); dragonFire.Add(@" \ \,_____"); dragonFire.Add(@" ___`\"); dragonFire.Add(@" \('>\`-__"); dragonFire.Add(" ~ ~~~--__*****"); dragonFire.Add(@" ______(@\ ******* **** ******* ******"); dragonFire.Add(@" /******~~~~\**********************************"); dragonFire.Add(@" \ `--____******************************************"); dragonFire.Add(" / ~~~--_____ ~~~/ ***************************************"); dragonFire.Add(" / `~~~~~ ******************************"); dragonFire.Add(" / **** **************"); dragonFire.Add(" / *** *********** "); } WeaponAnimation(true, _menuObject); EnemyPrint("End fight", 80, 10); Print.FightConsole(); var sounds = _menuObject.SoundList(); AudioPlaybackEngine sound = new AudioPlaybackEngine(); sound.PlaySound(sounds[8]); FightConsolePrintText(fightText, player, enemy); SetTopLeftCursorPosToStandardDragon(); for (int j = 0; j < dragon.Count; j++) { Console.SetCursorPosition(left, top); Print.Blue(dragon[j]); top++; } Thread.Sleep(500); SetTopLeftCursorPosToStandardDragon(); for (int j = 0; j < dragonFire.Count; j++) { Console.SetCursorPosition(left, top); Print.Red(dragonFire[j]); top++; } Thread.Sleep(500); sound.Dispose(); Print.ClearAllScreen(); EnemyPrint("End fight", 80, 10); player.PrintCurrentPlayerStatus(); Print.FightConsole(); SetTopLeftCursorPosToStandardDragon(); for (int j = 0; j < dragon.Count; j++) { Console.SetCursorPosition(left, top); Print.Blue(dragon[j]); top++; } WeaponAnimation(true, _menuObject); }
//Print text during fights public static void FightConsolePrintText(List <string> fightText, Player player, Enemy enemy) { int consolePrintPositionTop = 33; int consolePrintPositionLeft = 0; foreach (var item in fightText) { Console.SetCursorPosition(consolePrintPositionLeft, consolePrintPositionTop); Print.Yellow(item); consolePrintPositionTop++; } int hpStatsCursorTop = 34; int hpStatsCursorLeft = 93; for (int i = 0; i < 3; i++) { Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); if (i == 0) { if (player.Alive) { Console.Write(new string(' ', 14)); Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); if (player.Health < player.MaxHealth / 5) { Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop - 1); Print.Red("!!! WARNING !!!"); Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); Console.Write("Player HP: "); Print.Red($"{player.Health}"); } else { Console.WriteLine($"Player HP: {player.Health}"); } } else { Console.Write(new string(' ', 14)); Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); Console.WriteLine($"You died!"); } } if (i == 2) { if (enemy.Alive) { Console.Write(new string(' ', 14)); Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); Print.Yellow($"{enemy.Type} "); hpStatsCursorTop++; Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); Console.WriteLine($"Enemy HP: {enemy.Health} "); hpStatsCursorTop++; Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); Console.WriteLine($"Strength: {enemy.Strength} "); hpStatsCursorTop++; } else { Console.Write(new string(' ', 14)); Console.SetCursorPosition(hpStatsCursorLeft, hpStatsCursorTop); Console.WriteLine($"Enemy is dead!"); } } hpStatsCursorTop++; } }