//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); }
//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++; } }