static void Start(ref Map map, ref Player player) { List <string> menuItems = new List <string>(); int choice; do { Console.Clear(); choice = ShowMenu(map, ref menuItems, player); Dictionary <string, Objects> list = map.GetLocation().GetItems(); Objects[] obj = list.Values.ToArray(); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { Console.Clear(); Console.WriteLine("Your are now leaving the " + map.GetLocation().GetName()); Console.ReadKey(); map.GetLocation().firstime = false; map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_SEARCH: if (player.lookItem(map, 0)) { player.PickupItem(obj[0]); info.infoText = (obj[0].GetName() + " \t\tHas had to your inventory"); } break; case ACTION_SPEAK: map.GetLocation().GetActor().Text(player); break; case ACTION_SPECIFIC: if (player.GetMoney() >= 600) { Console.Clear(); } break; } } }while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { List <string> menuItems = new List <string>(); int choice; // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(); Console.WriteLine(); Console.WriteLine($"Max Health : {map.GetHealth()}\n"); choice = ShowMenu(map, ref menuItems); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_SEARCH: Console.Clear(); Console.WriteLine("you step into the dungeon, your vision fades as you feel like you are drowning.."); Console.WriteLine("once you regain your consciousness you are standing in a damp script "); map.SetLocation(7, 3); Console.ReadLine(); Console.Clear(); break; case ACTION_FIGHT: map.BATTLE_SCNENE(); break; case ACTION_RUN: // Add code for running here break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { List <string> menuItems = new List <string>(); int choice; // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(); choice = ShowMenu(map, ref menuItems); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_SEARCH: if (true) { } // Add code to perform an item pickup break; case ACTION_FIGHT: // Add code for fighting here break; case ACTION_RUN: // Add code for running here break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { List <string> menuItems = new List <string>(); int choice; // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(); choice = ShowMenu(map, ref menuItems); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_STATS: player.ShowStats(player); Console.ReadKey(); break; case ACTION_INV: player.ShowInventory(); Console.ReadKey(); break; case ACTION_SEARCH: // Add code to perform an item pickup Console.ReadKey(); break; case ACTION_FIGHT: // Add code for fighting here break; case ACTION_RUN: // Add code for running here break; case ACTION_BOSS: //add code for bossfight here break; case ACTION_INN: player.SetHealth(); Console.WriteLine("You have been healed!"); Console.ReadKey(); break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player, ref Bandit bandit, ref Spider spider, ref Skeleton skeleton, ref Skeleton1 skeleton1, ref Skeleton2 skeleton2, ref Kraken kraken, ref Bchief bchief, ref DwarfKing dking, ref Zealot zealot, ref Troll troll, ref Snake snake) { List <string> menuItems = new List <string>(); int choice; // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(); choice = ShowMenu(map, ref menuItems, ref player); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_HEAL: player.HealPlayer(player); player.CheckHealth(player); break; case ACTION_TREASURE: Console.WriteLine("You return to Mana with your spoils and live a happy life"); Console.WriteLine("The game is now technically over, but feel free to wander around."); Console.WriteLine(""); Console.WriteLine("Thanks for playing!"); Console.WriteLine("Made by: Thom Martens, Kevin Rademacher and Bas Overvoorde"); Console.ReadKey(); break; case ACTION_STATS: player.ShowStats(player); Console.ReadKey(); break; case ACTION_INV: player.ShowInventory(); Console.ReadKey(); break; case ACTION_SEARCH: Console.Clear(); Dictionary <string, Objects> list = map.GetLocation().GetItems(); Objects[] obj = list.Values.ToArray(); for (int i = 0; i < obj.Count(); i++) { if (obj[i].GetAcquirable()) { player.PickupItem(obj[i]); } Console.ReadKey(); } player.HasStrBuff(player); player.HasArmBuff(player); break; case ACTION_FIGHT: map.GetLocation().hasEnemy = true; //church fight if (map.GetLocation().GetName() == "Church of Stendarr") { Console.WriteLine("You encounter a {0}!", zealot.GetName()); Console.WriteLine("Health:{0}/{1}", zealot.health, zealot.maxhealth); Console.WriteLine("Strenght:{0}", zealot.GetStr()); // Console.WriteLine("Thoughness: {0}", zealot.GetThough()); Console.WriteLine("Examine: {0}", zealot.Description()); Console.ReadKey(); if (zealot.health > 0) { Console.WriteLine("The {0} hits you with his sword!", zealot.GetName()); player.TakeHit(zealot.GetStr() - player.GetThough()); zealot.health = zealot.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", zealot.GetName()); Console.WriteLine("You deal {0} damage", player.GetStr()); if (zealot.health > 0) { Console.WriteLine("The {0} has {1} health left.", zealot.GetName(), zealot.health); } else if (zealot.health <= 0) { zealot.health = 0; Console.WriteLine("The {0} has {1} health left", zealot.GetName(), zealot.health); } Console.ReadKey(); } if (zealot.health <= 0) { Console.WriteLine("The {0} is dead.", zealot.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } if (map.GetLocation().GetName() == "Bog") { Console.WriteLine("You encounter a {0}!", snake.GetName()); Console.WriteLine("Health:{0}/{1}", snake.health, snake.maxhealth); Console.WriteLine("Strenght:{0}", snake.GetStr()); // Console.WriteLine("Thoughness: {0}", zealot.GetThough()); Console.WriteLine("Examine: {0}", snake.Description()); Console.ReadKey(); if (snake.health > 0) { Console.WriteLine("The {0} tries to bite you!", snake.GetName()); player.TakeHit(snake.GetStr() - player.GetThough()); snake.health = snake.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", snake.GetName()); Console.WriteLine("You deal {0} damage", player.GetStr()); if (snake.health > 0) { Console.WriteLine("The {0} has {1} health left.", snake.GetName(), snake.health); } else if (snake.health <= 0) { snake.health = 0; Console.WriteLine("The {0} has {1} health left", snake.GetName(), snake.health); } Console.ReadKey(); } if (snake.health <= 0) { Console.WriteLine("The {0} is dead.", snake.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } if (map.GetLocation().GetName() == "Dragonstar") { Console.WriteLine("You encounter a {0}!", bandit.GetName()); Console.WriteLine("Health:{0}/{1}", bandit.health, bandit.maxhealth); Console.WriteLine("Strenght:{0}", bandit.GetStr()); //Console.WriteLine("Thoughness: {0}", bandit.GetThough()); Console.WriteLine("Examine: {0}", bandit.Description()); Console.ReadKey(); if (bandit.health > 0) { Console.WriteLine("The {0} hits you with his sword!", bandit.GetName()); player.TakeHit(bandit.GetStr() - player.GetThough()); bandit.health = bandit.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", bandit.GetName()); if (bandit.health > 0) { Console.WriteLine("The {0} has {1} health left.", bandit.GetName(), bandit.health); } else if (bandit.health <= 0) { bandit.health = 0; Console.WriteLine("The {0} has {1} health left", bandit.GetName(), bandit.health); } Console.ReadKey(); } if (bandit.health <= 0) { Console.WriteLine("The {0} is dead.", bandit.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } //forest fight if (map.GetLocation().GetName() == "Woodhearth") { Console.WriteLine("You encounter a {0}!", spider.GetName()); Console.WriteLine("Health:{0}/{1}", spider.health, spider.maxhealth); Console.WriteLine("Strenght:{0}", spider.GetStr()); //Console.WriteLine("Thoughness: {0}", spider.GetThough()); Console.WriteLine("Examine: {0}", spider.Description()); Console.ReadKey(); if (spider.health > 0) { Console.WriteLine("The {0} hits you with his huge fangs!", spider.GetName()); player.TakeHit(spider.GetStr() - player.GetThough()); spider.health = spider.health - player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", spider.GetName()); if (spider.health > 0) { Console.WriteLine("The {0} has {1} health left.", spider.GetName(), spider.health); } else if (spider.health <= 0) { spider.health = 0; Console.WriteLine("The {0} has {1} health left", spider.GetName(), spider.health); } Console.ReadKey(); } if (spider.health <= 0) { spider.health = 0; Console.WriteLine("The {0} is dead.", spider.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } //tombroom fight if (map.GetLocation().GetName() == "Tombroom1") { Console.WriteLine("You encounter a {0}!", skeleton.GetName()); Console.WriteLine("Health:{0}/{1}", skeleton.health, skeleton.maxhealth); Console.WriteLine("Strenght:{0}", skeleton.GetStr()); //Console.WriteLine("Thoughness: {0}", skeleton.GetThough()); Console.WriteLine("Examine: {0}", skeleton.Description()); Console.ReadKey(); if (skeleton.health > 0) { Console.WriteLine("The {0} hits you with his Giant Axe!", skeleton.GetName()); player.TakeHit(skeleton.GetStr() - player.GetThough()); skeleton.health = skeleton.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", skeleton.GetName()); if (skeleton.health > 0) { Console.WriteLine("The {0} has {1} health left.", skeleton.GetName(), skeleton.health); } else if (skeleton.health <= 0) { skeleton.health = 0; Console.WriteLine("The {0} has {1} health left", skeleton.GetName(), skeleton.health); } Console.ReadKey(); } if (skeleton.health <= 0) { Console.WriteLine("The {0} is dead.", skeleton.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } //tombroom1 fight if (map.GetLocation().GetName() == "Tombroom2") { Console.WriteLine("You encounter a {0}!", skeleton1.GetName()); Console.WriteLine("Health:{0}/{1}", skeleton1.health, skeleton1.maxhealth); Console.WriteLine("Strenght:{0}", skeleton1.GetStr()); //Console.WriteLine("Thoughness: {0}", skeleton1.GetThough()); Console.WriteLine("Examine: {0}", skeleton1.Description()); Console.ReadKey(); if (skeleton1.health > 0) { Console.WriteLine("The {0} shoots at you with his bow!", skeleton1.GetName()); player.TakeHit(skeleton1.GetStr() - player.GetThough()); skeleton1.health = skeleton1.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", skeleton1.GetName()); if (skeleton1.health > 0) { Console.WriteLine("The {0} has {1} health left.", skeleton1.GetName(), skeleton1.health); } else if (skeleton1.health <= 0) { skeleton1.health = 0; Console.WriteLine("The {0} has {1} health left", skeleton1.GetName(), skeleton1.health); } Console.ReadKey(); } if (skeleton1.health <= 0) { Console.WriteLine("The {0} is dead.", skeleton1.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } //tombroom2 fight if (map.GetLocation().GetName() == "Tombroom3") { Console.WriteLine("You encounter a {0}!", skeleton2.GetName()); Console.WriteLine("Health:{0}/{1}", skeleton2.health, skeleton2.maxhealth); Console.WriteLine("Strenght:{0}", skeleton2.GetStr()); //Console.WriteLine("Thoughness: {0}", skeleton2.GetThough()); Console.WriteLine("Examine: {0}", skeleton2.Description()); Console.ReadKey(); if (skeleton2.health > 0) { Console.WriteLine("The {0} strikes you with his sword!", skeleton2.GetName()); player.TakeHit(skeleton2.GetStr() - player.GetThough()); skeleton2.health = skeleton2.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", skeleton2.GetName()); if (skeleton2.health > 0) { Console.WriteLine("The {0} has {1} health left.", skeleton2.GetName(), skeleton2.health); } else if (skeleton2.health <= 0) { skeleton2.health = 0; Console.WriteLine("The {0} has {1} health left", skeleton2.GetName(), skeleton2.health); } Console.ReadKey(); } if (skeleton2.health <= 0) { Console.WriteLine("The {0} is dead.", skeleton2.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } //tombroom 3 fight if (map.GetLocation().GetName() == "Tombroom4") { Console.WriteLine("You encounter a {0}!", skeleton.GetName()); Console.WriteLine("Health:{0}/{1}", skeleton.health, skeleton.maxhealth); Console.WriteLine("Strenght:{0}", skeleton.GetStr()); //Console.WriteLine("Thoughness: {0}", skeleton.GetThough()); Console.WriteLine("Examine: {0}", skeleton.Description()); Console.ReadKey(); if (skeleton.health > 0) { Console.WriteLine("The {0} hits you with his Giant Axe!", skeleton.GetName()); player.TakeHit(skeleton.GetStr() - player.GetThough()); skeleton.health = skeleton.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", skeleton.GetName()); if (skeleton.health > 0) { Console.WriteLine("The {0} has {1} health left.", skeleton.GetName(), skeleton.health); } else if (skeleton.health <= 0) { skeleton.health = 0; Console.WriteLine("The {0} has {1} health left", skeleton.GetName(), skeleton.health); } Console.ReadKey(); } if (skeleton.health <= 0) { Console.WriteLine("The {0} is dead.", skeleton.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } //troll fight if (map.GetLocation().GetName() == "The Hanger") { Console.WriteLine("You encounter a {0}!", troll.GetName()); Console.WriteLine("Health:{0}/{1}", troll.health, troll.maxhealth); Console.WriteLine("Strenght:{0}", troll.GetStr()); //Console.WriteLine("Thoughness: {0}", spider.GetThough()); Console.WriteLine("Examine: {0}", troll.Description()); Console.ReadKey(); if (troll.health > 0) { Console.WriteLine("The {0} hits you with his giant club!", troll.GetName()); player.TakeHit(troll.GetStr() - player.GetThough()); troll.health = troll.health - player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", troll.GetName()); if (troll.health > 0) { Console.WriteLine("The {0} has {1} health left.", troll.GetName(), troll.health); } else if (troll.health <= 0) { troll.health = 0; Console.WriteLine("The {0} has {1} health left", troll.GetName(), troll.health); } Console.ReadKey(); } if (troll.health <= 0) { troll.health = 0; Console.WriteLine("The {0} is dead.", troll.GetName()); map.GetLocation().hasEnemy = false; Console.ReadKey(); } } break; case ACTION_RUN: map.Run(); Console.WriteLine("You run away to {0}", map.GetLocation().GetName()); Console.ReadKey(); break; case ACTION_BOSS: map.GetLocation().hasBossEnemy = true; //kraken boss if (map.GetLocation().GetName() == "Black Lake") { Console.WriteLine("You encounter a {0}!", kraken.GetName()); Console.WriteLine("Health:{0}/{1}", kraken.health, kraken.maxhealth); Console.WriteLine("Strenght:{0}", kraken.GetStr()); //Console.WriteLine("Thoughness: {0}", kraken.GetThough()); Console.WriteLine("Examine: {0}", kraken.Description()); Console.ReadKey(); if (kraken.health > 0) { Console.WriteLine("The {0} strikes you with his tentacles!", kraken.GetName()); player.TakeHit(kraken.GetStr() - player.GetThough()); kraken.health = kraken.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", kraken.GetName()); if (kraken.health > 0) { Console.WriteLine("The {0} has {1} health left.", kraken.GetName(), kraken.health); } else if (kraken.health <= 0) { kraken.health = 0; Console.WriteLine("The {0} has {1} health left", kraken.GetName(), kraken.health); } Console.ReadKey(); } if (kraken.health <= 0) { Console.WriteLine("The {0} is dead.", kraken.GetName()); map.GetLocation().hasBossEnemy = false; Console.ReadKey(); } } //chief bandit if (map.GetLocation().GetName() == "Dragonstar armory") { Console.WriteLine("You encounter the {0}!", bchief.GetName()); Console.WriteLine("Health:{0}/{1}", bchief.health, bchief.maxhealth); Console.WriteLine("Strenght:{0}", bchief.GetStr()); //Console.WriteLine("Thoughness: {0}", bchief.GetThough()); Console.WriteLine("Examine: {0}", bchief.Description()); Console.ReadKey(); if (bchief.health > 0) { Console.WriteLine("The {0} strikes you with his basterdsword!", bchief.GetName()); player.TakeHit(bchief.GetStr() - player.GetThough()); bchief.health = bchief.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", bchief.GetName()); Console.WriteLine("The {0} has {1} health left.", bchief.GetName(), bchief.health); Console.ReadKey(); } if (bchief.health <= 0) { Console.WriteLine("The {0} is dead.", bchief.GetName()); map.GetLocation().hasBossEnemy = false; Console.ReadKey(); } } //dwarf king fight if (map.GetLocation().GetName() == "TombTreasureRoom") { Console.WriteLine("You encounter {0}!", dking.GetName()); Console.WriteLine("Health:{0}/{1}", dking.health, dking.maxhealth); Console.WriteLine("Strenght:{0}", dking.GetStr()); //Console.WriteLine("Thoughness: {0}", dking.GetThough()); Console.WriteLine("Examine: {0}", dking.Description()); Console.ReadKey(); if (dking.health > 0) { Console.WriteLine("The {0} strikes you with his Axe!", dking.GetName()); player.TakeHit(dking.GetStr() - player.GetThough()); dking.health = dking.health -= player.GetStr(); Console.WriteLine("You strike the {0} with your weapon.", dking.GetName()); Console.WriteLine("The {0} has {1} health left.", dking.GetName(), dking.health); Console.ReadKey(); } if (dking.health <= 0) { Console.WriteLine("The {0} is dead.", dking.GetName()); map.GetLocation().hasBossEnemy = false; Console.ReadKey(); } } break; case ACTION_INN: player.SetHealth(); Console.WriteLine("You have been healed!"); Console.ReadKey(); break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { List <string> menuItems = new List <string>(); int choice = 0; Random rdm = new Random(); // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(ref map); if (menuItems.Count != 0) { if (menuItems[choice].StartsWith(ACTION_DISCRIPTION_NORTH)) { Program.PrintLine(100, map.GetLocation().GetBlockage(0).GetDiscription(ref map)); } else if (menuItems[choice].StartsWith(ACTION_DISCRIPTION_EAST)) { Program.PrintLine(100, map.GetLocation().GetBlockage(1).GetDiscription(ref map)); } else if (menuItems[choice].StartsWith(ACTION_DISCRIPTION_SOUTH)) { Program.PrintLine(100, map.GetLocation().GetBlockage(2).GetDiscription(ref map)); } else if (menuItems[choice].StartsWith(ACTION_DISCRIPTION_WEST)) { Program.PrintLine(100, map.GetLocation().GetBlockage(3).GetDiscription(ref map)); } } choice = ShowMenu(map, ref menuItems); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } if (menuItems[choice].StartsWith(ACTION_INTERACT_NORTH)) { map.GetLocation().GetBlockage(0).OnPlayerInteraction(ref player, ref map); } else if (menuItems[choice].StartsWith(ACTION_INTERACT_EAST)) { map.GetLocation().GetBlockage(1).OnPlayerInteraction(ref player, ref map); } else if (menuItems[choice].StartsWith(ACTION_INTERACT_SOUTH)) { map.GetLocation().GetBlockage(2).OnPlayerInteraction(ref player, ref map); } else if (menuItems[choice].StartsWith(ACTION_INTERACT_WEST)) { map.GetLocation().GetBlockage(3).OnPlayerInteraction(ref player, ref map); } switch (menuItems[choice]) { case ACTION_SEARCH: foreach (Objects item in map.GetLocation().GetItems().Values) { player.PickupItem(item); } break; case ACTION_FIGHT: map.GetLocation().GetEnemy().TakeHit(rdm.Next(10, 20)); if (map.GetLocation().GetEnemy().GetHealth() > 0) { player.TakeHit(rdm.Next(5, 20)); if (player.GetHealth() <= 0) { Console.ReadLine(); Quit(); } } else { Program.PrintLine(100, "You have won from you enemy"); if (!map.GetLocation().GetItems().ContainsKey(map.GetLocation().GetEnemy().Loot().GetName())) { map.GetLocation().GetItems().Add(map.GetLocation().GetEnemy().Loot().GetName(), map.GetLocation().GetEnemy().Loot()); } map.GetLocation().SetEnemy(null); } break; case ACTION_RUN: Program.PrintLine(100, "You shouldn't have runned away from your enemy"); Console.ReadLine(); Quit(); break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { List <string> menuItems = new List <string>(); int choice; // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(); choice = ShowMenu(map, ref menuItems); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_TREASURE: Console.WriteLine("You return to Mana with your spoils and live a happy life"); Console.WriteLine(""); Console.WriteLine("Thanks for playing!"); Console.WriteLine("Made by: Thom Martens, Kevin Rademacher and Bas Overvoorde"); Console.ReadKey(); break; case ACTION_STATS: player.ShowStats(player); Console.ReadKey(); break; case ACTION_INV: player.ShowInventory(); Console.ReadKey(); break; case ACTION_SEARCH: Console.Clear(); Dictionary <string, Objects> list = map.GetLocation().GetItems(); Objects[] obj = list.Values.ToArray(); for (int i = 0; i < obj.Count(); i++) { if (obj[i].GetAcquirable()) { Console.WriteLine("{0}", obj[i].GetName()); player.PickupItem(obj[i]); } Console.ReadKey(); } break; case ACTION_FIGHT: // Add code for fighting here break; case ACTION_RUN: map.Run(); Console.WriteLine("You run away to {0}", map.GetLocation().GetName()); Console.ReadKey(); break; case ACTION_BOSS: //add code for bossfight here break; case ACTION_INN: player.SetHealth(); Console.WriteLine("You have been healed!"); Console.ReadKey(); break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { List<string> menuItems = new List<string>(); int choice; // Refactored by Michiel and Alex do { Console.Clear(); if (Game.JustDied) break; map.GetLocation().Description(); if (Game.JustDied) break; choice = ShowMenu(map, ref menuItems); if ( choice != menuItems.Count() ) { if ( validDirections.Contains( menuItems[choice] ) ) { map.Move( menuItems[choice] ); } switch ( menuItems[choice] ) { case ACTION_SEARCH: Console.Clear(); foreach (var item in map.GetLocation().GetItems()) { item.Value.Description(); player.PickupItem(item.Value); } player.ShowInventory(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); // Add code to perform an item pickup break; case ACTION_FIGHT: map.GetLocation().Fight(); break; case ACTION_RUN: // Add code for running here break; default: if(map.GetLocation().quiz) { if (map.GetLocation().quizQuestions.Contains(menuItems[choice])) { if(choice == map.GetLocation().quizAnswer) { map.GetLocation().OnQuizGoodAnswer(); } else { map.GetLocation().OnQuizBadAnswer(); } } } break; } } } // When the choice is equal to the total item it means exit has been chosen. while ( choice < menuItems.Count() - 1); }
static void Start(ref Map map, ref Player player) { Rik rik = new Rik("Rik", 10000, 10000); BloodDrake blooddrake = new BloodDrake("Blood Drake", 50, 10); AngryMan angryman = new AngryMan("Angry Man", 70, 10); CastleBoss boss = new CastleBoss("Castle Boss", 250, 10); List <string> menuItems = new List <string>(); int choice; rik.EncounterRik(); // Refactored by Michiel and Alex do { Console.Clear(); map.GetLocation().Description(); choice = ShowMenu(map, ref menuItems, ref player, ref blooddrake, ref angryman); if (choice != menuItems.Count()) { if (validDirections.Contains(menuItems[choice])) { map.Move(menuItems[choice]); } switch (menuItems[choice]) { case ACTION_SEARCH: // Add code to perform an item pickup break; case ACTION_FIGHT: // Add code for fighting here break; case ACTION_RUN: // Add code for running here break; case ACTION_SHOWINVENTORY: player.ShowInventory(); Console.ReadLine(); choice = 0; break; case ACTION_SHOP: Shop shop = new Shop(); shop.ShowShop(ref player); choice = 0; Console.ReadLine(); break; case "Fight the Blood Drake": Console.Clear(); blooddrake.StartEncouter(ref player, ref map); Console.ReadLine(); map.Move("Go North"); break; case "Go via the side of the bridge": Console.Clear(); player.ClimbBridge(ref player); Console.ReadLine(); map.Move("Go North"); break; case ACTION_USEHEALTHPOTION: HealthPotion hp = new HealthPotion("Health Potion", true); hp.UsePotion(ref player); choice = 0; break; case "Fight the man": Console.Clear(); angryman.StartEncounter(ref player, ref map); Console.ReadLine(); break; case "Leave the man": Console.Clear(); map.Move("Go West"); Console.ReadLine(); break; case "Climb over the wall": map.Move("Go North"); break; case "Fight the Boss": Console.Clear(); boss.StartEncounter(ref player); Console.ReadLine(); break; } } } // When the choice is equal to the total item it means exit has been chosen. while (choice < menuItems.Count() - 1); }