static public void GameLoop() { bool levelSettingDone = false; bool gameStatus = true; Hero player = new Hero(); Enemy opponent = new Enemy(); Level lvl = new Level(); int currentLevel = 1; // Generate items and let player create own character. Weapon we = new Weapon(); Armour ar = new Armour(); we.GenerateWeapons(); ar.GenerateArmours(); CreateCharacter(player, we, ar); while (gameStatus) { // Check which level player is on if (currentLevel == 1 && !levelSettingDone) { lvl = new Level("easy", 5); lvl.Generate(); player.SetMaxVisitedRooms(lvl.GetRoomAmount()); levelSettingDone = true; // Show level settings. Console.WriteLine(lvl.GetSettings()); Continue(); } else if (currentLevel == 2 && !levelSettingDone) { lvl = new Level("medium", 10); lvl.Generate(); player.SetMaxVisitedRooms(lvl.GetRoomAmount()); levelSettingDone = true; // Show level settings. Console.WriteLine(lvl.GetSettings()); Continue(); } else if (currentLevel == 3 && !levelSettingDone) { lvl = new Level("hard", 20); lvl.Generate(); player.SetMaxVisitedRooms(lvl.GetRoomAmount()); levelSettingDone = true; // Show level settings. Console.WriteLine(lvl.GetSettings()); Continue(); } // If player isn't in any room -> throw player into Entrance. if (player.GetRoom() == null) { player.SetRoom(lvl.GetRoom("Entrance")); } // Move player to the next room else if (player.GetRoom() != null) { // Add visited room to roomsVisited array. player.AddVisitedRoom(); player.visitedRoomsCount++; try { player.SetRoom(lvl.GetRoomFromMapLayout(player.visitedRoomsCount)); } catch (IndexOutOfRangeException e) { goto Boss; } Console.WriteLine(player.GetName() + " moved to " + player.GetRoom() + " room."); Continue(); } // if not visited encounter happens if (!player.GetVisitedRooms().Contains(player.GetRoom()) && player.health > 0) { CombatLoop(opponent, player, Dice(1, lvl.GetMaxEnemyAmount(player.GetRoom()))); if (player.health > 0) { Rewards(player, ar, we); } } Boss: if (player.GetVisitedRooms().Contains("Boss")) { Console.WriteLine("You have beaten the boss of current floor!\nAdvancing to the next floor."); Continue(); currentLevel++; levelSettingDone = false; if (currentLevel > 3) { gameStatus = false; } } if (player.health <= 0) { Console.WriteLine("Game Over.\nYou Died."); break; } else if (gameStatus == false) { Console.WriteLine("You have beaten the pyramid!"); break; } } }
static public Hero CreateCharacter(Hero player, Weapon weapon, Armour armour) { int health = 0; string answer = ""; answer = QuestionInput("Name your character "); player.SetName(answer); Console.WriteLine("Use numbers to choose."); answer = QuestionInput("Choose your race:\n 1 Human\n 2 Dragon-Kin\n 3 Troll "); if (answer == "1") { player.SetRace("human"); } else if (answer == "2") { player.SetRace("dragon-kin"); } else if (answer == "3") { player.SetRace("troll"); } answer = QuestionInput("\nChoose your equipments.\nWeapons:\n " + "1 " + weapon.weaponPool[0].GetName() + ", " + weapon.weaponPool[0].GetDamage() + " damage\n " + "2 " + weapon.weaponPool[1].GetName() + ", " + weapon.weaponPool[1].GetDamage() + " damage\n " + "3 " + weapon.weaponPool[2].GetName() + ", " + weapon.weaponPool[2].GetDamage() + " damage"); if (answer == "1") { player.inv.TakeWeapon(weapon.weaponPool[0]); player.inv.EquipWeapon(weapon.weaponPool[0], player); } else if (answer == "2") { player.inv.TakeWeapon(weapon.weaponPool[1]); player.inv.EquipWeapon(weapon.weaponPool[1], player); } else if (answer == "3") { player.inv.TakeWeapon(weapon.weaponPool[2]); player.inv.EquipWeapon(weapon.weaponPool[2], player); } answer = QuestionInput("\nArmour:\n " + "1 " + armour.armourPool[0].GetName() + ", " + armour.armourPool[0].GetArmour() + " armour" + "\n " + "2 " + armour.armourPool[1].GetName() + ", " + armour.armourPool[1].GetArmour() + " armour" + "\n " + "3 " + armour.armourPool[2].GetName() + ", " + armour.armourPool[2].GetArmour() + " armour"); if (answer == "1") { player.inv.TakeArmour(armour.armourPool[0]); player.inv.EquipArmour(armour.armourPool[0], player); } else if (answer == "2") { player.inv.TakeArmour(armour.armourPool[1]); player.inv.EquipArmour(armour.armourPool[1], player); } else if (answer == "3") { player.inv.TakeArmour(armour.armourPool[2]); player.inv.EquipArmour(armour.armourPool[2], player); } if (player.race == "human") { health = 300; player.SetHealth(health); player.SetMaxHealth(health); } else if (player.race == "dragon-kin") { health = 500; player.SetHealth(health); player.SetMaxHealth(health); } else if (player.race == "troll") { health = 700; player.SetHealth(health); player.SetMaxHealth(health); } Console.WriteLine("Your character: \n" + player.GetStats()); Continue(); return(player); }