//Loading the game public static void GameLoad() { //Interface CharacterMethods methods = new CharacterMethods(); Console.Clear(); //To load the game, you have to type your game name Console.WriteLine("Type your game name to load the game:"); Character.name = Console.ReadLine(); if (File.Exists("SaveOf" + Character.name + ".txt")) { //Read the stats out of the .txt files TextReader tr = new StreamReader("SaveOf" + Character.name + ".txt"); Character.name = tr.ReadLine(); string goldString = tr.ReadLine(); string expString = tr.ReadLine(); string enrgyString = tr.ReadLine(); string lvlString = tr.ReadLine(); Performance.gold = Convert.ToInt32(goldString); Performance.experience = Convert.ToInt32(expString); Performance.energy = Convert.ToInt32(enrgyString); Level.Level1 = Convert.ToInt32(lvlString); tr.Close(); methods.ContinueHome(); } else { //If the user doesn't exist, you will get this error Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("This user doesn't exist!"); Console.ForegroundColor = ConsoleColor.White; } }
//Checking if you have enough gold public static void CheckGold() { CharacterMethods methods = new CharacterMethods(); if (gold < 50) { Console.Clear(); Home.PrintMenuHome(); Console.WriteLine( "________________________________________________________________________________________________________________________"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(">You don't have enough gold to refill your energy!"); Console.ForegroundColor = ConsoleColor.White; Console.ReadLine(); methods.ContinueHome(); } else { gold -= 50; energy += 100; methods.ContinueHome(); } }
//If you lose public static void YouLost() { CharacterMethods methods = new CharacterMethods(); Console.Clear(); SoundPlayer defeat = new SoundPlayer(@"C:\Users\vmadmin\RiderProjects\RPGProject\theme\defeat.wav"); defeat.Play(); Console.WriteLine("You couldn't win against Pepe..."); Console.WriteLine("\n>Press any key to go home"); Console.ReadKey(); Performance.gold += 50; Console.Clear(); methods.ContinueHome(); }
//Switch case for race private static void CheckEntryRace(int _race) { CharacterMethods methods = new CharacterMethods(); Console.ForegroundColor = ConsoleColor.White; { switch (_race) { case 1: Console.WriteLine("Human [1]{0}", race); methods.ContinueHome(); break; case 2: Console.WriteLine("Blood Elf [2]{0}", race); methods.ContinueHome(); break; case 3: Console.WriteLine("Gnome [3]{0}", race); methods.ContinueHome(); break; case 4: Console.WriteLine("Goblin [4]{0}", race); methods.ContinueHome(); break; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Input! Try again."); Console.ForegroundColor = ConsoleColor.White; break; } } }
//If you win public static void YouWon() { CharacterMethods methods = new CharacterMethods(); Console.Clear(); SoundPlayer victory = new SoundPlayer(@"C:\Users\vmadmin\RiderProjects\RPGProject\theme\victory.wav"); victory.Play(); Console.WriteLine("You defeated Pepe and brought peace into the world"); Console.WriteLine("\n>Press any key to go home"); Console.ReadKey(); Performance.gold += 500; Level.Level1++; Console.Clear(); methods.ContinueHome(); }
private static void CheckEntryQuest(int task) { CharacterMethods methods = new CharacterMethods(); switch (task) { case 1: Performance.CheckEnergy(); break; case 2: methods.ContinueHome(); break; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Input! Try again."); Console.ForegroundColor = ConsoleColor.White; break; } }