public void GetWeapon() { if (WeaponsBag.Count == 0) { Console.WriteLine("You don't have weapon in your bag."); Console.WriteLine(); } else { Console.WriteLine("You have the following weapons in your bag."); foreach (Weapon weapon in WeaponsBag) { int num = WeaponsBag.IndexOf(weapon) + 1; Console.WriteLine("Number {0}:", num); Console.WriteLine(weapon); } Console.WriteLine("Press the number to choose the weapon:"); string inputValue = Console.ReadLine(); Console.WriteLine(); int inputresult = checkInputValue(inputValue, WeaponsBag.Count); Weapon chosenWeapon = WeaponsBag[inputresult - 1]; Console.WriteLine("You choose the number of {0} weapon in your bag.", inputresult); Console.WriteLine(chosenWeapon); Console.WriteLine("-----------------------------------"); Console.WriteLine(); if (EquippedWeapon == null) { EquippedWeapon = chosenWeapon; } else { WeaponsBag.Add(EquippedWeapon); EquippedWeapon = chosenWeapon; WeaponsBag.Remove(chosenWeapon); } } }
public void ShowInventory() { Console.WriteLine("The current equipments of the hero:"); if (EquippedWeapon == null) { Console.WriteLine("No equiped weapon of the hero."); Console.WriteLine("------------------------------"); } else { Console.WriteLine(EquippedWeapon); } if (WeaponsBag.Count == 0) { Console.WriteLine("You don't have weapon in your bag."); Console.WriteLine("------------------------------"); Console.WriteLine(); } else { Console.WriteLine("You have the following weapons in your bag."); foreach (Weapon weapon in WeaponsBag) { int num = WeaponsBag.IndexOf(weapon) + 1; Console.WriteLine("Number {0}:", num); Console.WriteLine(weapon); Console.WriteLine(); } } if (EquippedArmor == null) { Console.WriteLine("No Armor of the hero."); Console.WriteLine("------------------------------"); } else { Console.WriteLine(EquippedArmor); } if (ArmorsBag.Count == 0) { Console.WriteLine("You don't have armor in your bag."); Console.WriteLine("------------------------------"); Console.WriteLine(); } else { Console.WriteLine("You have the following weapons in your bag."); foreach (Armor armor in ArmorsBag) { int num = ArmorsBag.IndexOf(armor) + 1; Console.WriteLine("Number {0}:", num); Console.WriteLine(armor); Console.WriteLine(); } } Console.WriteLine("----------------------------"); Console.WriteLine(); }