Exemplo n.º 1
0
        public void OpenInventory()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Game.consoleBuffer      = new char[Game.consoleHeight, Game.consoleWidth];
            Console.WriteLine(" Active Helmet: " + activeHelmet.name + " " + activeHelmet.GetInfo());
            Console.WriteLine(" Active Armor: " + activeArmor.name + " " + activeArmor.GetInfo());
            Console.WriteLine(" Active Weapon: " + activeWeapon.name + " " + activeWeapon.GetInfo());
            Console.WriteLine();
            for (int i = 0; i < items.Count; ++i)
            {
                Console.WriteLine(" [" + (i + 1) + "]" + " " + items[i].name + " " + items[i].GetInfo());
            }
            Console.WriteLine();
            Console.WriteLine(" Enter number of item, wich you want use");
            Console.WriteLine(" [C] - Close inventory");
            Console.Write(" ");
            string command = Console.ReadLine();

            if ((command == "c") || (command == "C"))
            {
                Console.Clear();
                return;
            }
            else
            {
                if (Int32.TryParse(command, out int itemIndex))
                {
                    if ((itemIndex <= items.Count) && (itemIndex > 0))
                    {
                        items[itemIndex - 1].Use();
                        if (!(((items[itemIndex - 1] is Armor) || (items[itemIndex - 1] is Helmet)) && (Game.player.specification.race == ERaсe.MINOTAUR)))
                        {
                            items.RemoveAt(itemIndex - 1);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect value");
                }
                OpenInventory();
            }
        }