Exemple #1
0
        public void Main()
        {
            Console.WriteLine("");
            Console.WriteLine("Please choose an option by entering a number.");
            Console.WriteLine("1. View Stats");
            Console.WriteLine("2. View Inventory");
            Console.WriteLine("3. Fight Monster");
            Console.WriteLine("4. Go To The Shop");
            Console.WriteLine("5. Equip Weapon");
            Console.WriteLine("6. Equip Armor");
            Console.WriteLine("7. Sip Some Sizzurp");
            Console.WriteLine("8. QUIT");
            Console.WriteLine("");
            Console.Write("Enter your selection: ");
            var input = Console.ReadLine();

            if (input == "1")
            {
                this.Stats();
            }
            else if (input == "2")
            {
                this.Inventory();
            }
            else if (input == "3")
            {
                this.Fight();
            }
            else if (input == "4")
            {
                Shop.Menu();
            }
            else if (input == "5")
            {
                Hero.EquipWeapon();
            }
            else if (input == "6")
            {
                Hero.EquipArmor();
            }
            else if (input == "7")
            {
                Hero.EquipPotion();
            }
            else if (input == "8")
            {
                Environment.Exit(0);
            }
            else
            {
                this.Main();
            }

            #region Switch Statement
            //switch (input) {
            ////switch on value of input
            //    case "1":
            //        Stats();
            //        break;
            //    case "2":
            //        Inventory();
            //        break;
            //    case "3":
            //        Fight();
            //        break;
            //    case "4":
            //        shop.Menu();
            //        break;
            //    case "5":
            //    default:
            //        return;
            //}
            #endregion
        }
Exemple #2
0
        //Display Hero Inventory
        private void Inventory()
        {
            Hero.ShowInventory();

            Console.WriteLine("1-Equip Weapon");
            Console.WriteLine("2-UnEquip Weapon");
            Console.WriteLine("3-Equip Armor");
            Console.WriteLine("4-UnEquip Armor");
            Console.WriteLine("5-Equip Shield");
            Console.WriteLine("6-UnEquip Shield");

            Console.WriteLine("----------------------------------------------------------------------------------------------");
            Console.Write("Select the menu : ");

            var KeyInput = Console.ReadLine();

            //Equip Weapon
            if (KeyInput == "1")
            {
                var unEquippedWeapons = Hero.GetWeapons().Where(p => p != Hero.EquippedWeapon).ToList();

                for (var i = 0; i < unEquippedWeapons.Count(); i++)
                {
                    Console.WriteLine($"{i + 1} - {unEquippedWeapons[i].Name}");
                }

                Console.Write("Selet the weapon ID : ");
                var index = Hero.GetUserInputNumber() - 1;
                Hero.EquipWeapon(index);
            }

            //Unequip Weapon
            else if (KeyInput == "2")
            {
                Hero.UnEquipWeapon();
            }

            //Equip Armor
            else if (KeyInput == "3")
            {
                var unEquippedArmors = Hero.GetArmors().Where(p => p != Hero.EquippedArmor).ToList();
                for (var i = 0; i < unEquippedArmors.Count(); i++)
                {
                    Console.WriteLine($"{i + 1} - {unEquippedArmors[i].Name}");
                }
                Console.Write("Selet the armor ID : ");
                var index = Hero.GetUserInputNumber() - 1;
                Hero.EquipArmor(index);
            }

            //Unequip Armor
            else if (KeyInput == "4")
            {
                Hero.UnEquipArmor();
            }

            //Equip Shield
            else if (KeyInput == "5")
            {
                var unEquippedShield = Hero.GetShield().Where(p => p != Hero.EquippedShield).ToList();

                for (var i = 0; i < unEquippedShield.Count(); i++)
                {
                    Console.WriteLine($"{i + 1} - {unEquippedShield[i].Name}");
                }

                Console.Write("Selet the shield ID : ");
                var index = Hero.GetUserInputNumber() - 1;
                Hero.EquipShield(index);
            }

            //Unequip Shield
            else if (KeyInput == "6")
            {
                Hero.UnEquipShield();
            }

            Console.WriteLine("Press any key to return to main menu.");
            Console.ReadKey();
        }