public static void start_game() { Player.get_room().describe(); Text_Buffer.Add("\nEnemy is located at [ " + enemy._X_Position + ", " + enemy._Y_Position + " ]"); Text_Buffer.Add("\nYou are located at [ " + Player._Player._X_Position + ", " + Player._Player._Y_Position + " ]"); Text_Buffer.print(); }
public static Player GeneratePlayer() { Player p = null; string n = string.Empty; bool correct = false; Text_Buffer.Add("\nPlease enter your name: "); Text_Buffer.prompt(); n = Console.ReadLine(); while (!correct) { string newName; Text_Buffer.Add("\nIf " + n + " is correct, press < enter >\n\n\tIf it's not, please re-enter your name now:"); Text_Buffer.prompt(); newName = Console.ReadLine(); if (newName == string.Empty) { Text_Buffer.Add("\nWhat a good, strong name, " + n + "!"); correct = true; } else { n = newName; } } Player_Class pc = 0; Text_Buffer.Add("\nThere are 3 races in this game."); Text_Buffer.Add("\tThey are:"); Text_Buffer.Add("\n\t1. Rankari"); Text_Buffer.Add("\t2. Nobellus"); Text_Buffer.Add("\t3. Ginoba"); Text_Buffer.Add("\nPlease choose one: "); Text_Buffer.prompt(); string t = Console.ReadLine(); correct = false; int i = 0; while (!correct) { if (t == "1" || t == "2" || t == "3") { i = int.Parse(t); correct = true; } else { Console.WriteLine("That is not a valid choice. Try again..."); t = Console.ReadLine(); } } switch (i) { case 1: pc = Player_Class.Rankari; correct = true; break; case 2: pc = Player_Class.Nobellus; correct = true; break; case 3: pc = Player_Class.Ginoba; correct = true; break; default: Text_Buffer.Add("No race selected!"); pc = Player_Class.INCOGNITO; Text_Buffer.print(); break; } Player_Weapon pw = 0; Text_Buffer.Add("\nThere are 4 weapons in this game."); Text_Buffer.Add("\tThey are:"); Text_Buffer.Add("\n\t1. Knife"); Text_Buffer.Add("\t2. Sword"); Text_Buffer.Add("\t3. Axe"); Text_Buffer.Add("\t4. Warhammer"); Text_Buffer.Add("\nPlease choose one: "); Text_Buffer.prompt(); string s = Console.ReadLine(); correct = false; int j = 0; while (!correct) { if (s == "1" || s == "2" || s == "3" || s == "4") { j = int.Parse(s); correct = true; } else { Console.WriteLine("That is not a valid choice. Try again..."); s = Console.ReadLine(); } } switch (j) { case 1: pw = Player_Weapon.Knife; break; case 2: pw = Player_Weapon.Sword; break; case 3: pw = Player_Weapon.Axe; break; case 4: pw = Player_Weapon.WarHammer; break; default: Text_Buffer.Add("No weapon selected!"); Text_Buffer.print(); break; } switch (pc) { case Player_Class.Rankari: p = new Rankari(n, pw); break; case Player_Class.Nobellus: p = new Nobellus(n, pw); break; case Player_Class.Ginoba: p = new Ginoba(n, pw); break; default: Text_Buffer.Add("No Player Detected..."); break; } return(p); }
// determine what action to take based // on the user input public static void process(string input) { // get the first half and trim it to one easy to read command string command = Game_Utilities.extract_command(input.Trim().Trim().ToLower()); // get the second half and trim it to one easy to read command string action = Game_Utilities.extract_action(input.Trim().Trim().ToLower()); string direction = Game_Manager.enemy.npc_direction(); // now take action based on the input given: /* * user commands are: * ~ move - moves the player * ~ look - describes the current area * ~ take - takes an object from the area * ~ stats - displays the Player's current stats * ~ drop - drops an object from the area * ~ inventory - lists the player's inventory items * ~ help - displays the list of user commands * ~ quit - exits the game */ switch (command) { case "move": Player.move(action); Text_Buffer.Add("\nYou are located at [ " + Player._Player._X_Position + ", " + Player._Player._Y_Position + " ]"); break; case "battlecry": Player._Player.BattleCry(); break; case "look": Player.get_room().describe(); break; case "take": Player.pickup_item(action); break; case "drop": Player.drop_item(action); break; case "stats": Player.stats(); break; case "inventory": Player.print_inventory(); break; case "help": help_screen(); break; case "quit": Program.quit = true; return; } process_enemy(direction); Game_Manager.check_game_rules(); Text_Buffer.print(); }