Пример #1
0
        public void SellMenu()
        {
            for (bool sellMenuOpen = true; sellMenuOpen == true;)
            {
                Console.Clear();
                Console.WriteLine(Global.shopName + ": " + Global.shopEnterMessage);
                Console.WriteLine();
                inventory.SellInventoryDisplay(player, shopKeeper);
                Console.WriteLine();
                Console.WriteLine(Global.shopName + "'s Gold: " + shopKeeper.CheckMoney() + "      " + player.name + "'s Gold: " + player.CheckMoney());
                Console.WriteLine();
                Console.WriteLine("To sell an item, press the related number of said item + enter.");
                Console.WriteLine();
                Console.WriteLine("E + enter) Exit");
                Console.WriteLine();

                string input = Console.ReadLine();
                for (int x = 0; x < inventory.InventorySize(); x++)
                {
                    if (input == "e")
                    {
                        sellMenuOpen = false;
                        return;
                    }
                    else if (Global.isNumeric(input) && int.Parse(input) <= inventory.InventorySize())
                    {
                        if (Convert.ToInt16(input) == x + 1)// - 48 == x + 1)
                        {
                            if (inventory.InventorySlots(x) != null)
                            {
                                if (inventory.InventorySlots(x).itemType == Item.ItemType.Key || inventory.InventorySlots(x).itemType == Item.ItemType.Valuable)
                                {
                                    Console.Clear();
                                    Console.WriteLine("You cannot sell this item.");
                                    Console.WriteLine("Press any key to continue.");
                                    Console.ReadKey(true);
                                    return;
                                }
                                else
                                {
                                    for (bool inputCheck = false; inputCheck == false;)
                                    {
                                        if (shopKeeper.CheckMoney() >= inventory.InventorySlots(x).CheckPrice())
                                        {
                                            Console.Clear();
                                            Console.WriteLine("Do you want to sell " + inventory.InventorySlots(x).CheckName() + " for " + inventory.InventorySlots(x).CheckPrice() + "?");
                                            Console.WriteLine(Global.shopName + "'s Gold: " + shopKeeper.CheckMoney() + "      " + player.name + "'s Gold: " + player.CheckMoney());
                                            Console.WriteLine("Y) Yes     N) No");
                                            ConsoleKeyInfo secondaryInput = Console.ReadKey(true);

                                            if (secondaryInput.Key == ConsoleKey.Y)
                                            {
                                                player.GainMoney(inventory.InventorySlots(x).CheckPrice());
                                                shopKeeper.LoseMoney(inventory.InventorySlots(x).CheckPrice());
                                                inventory.removeItemFromInventory(x);
                                                inputCheck = true;
                                            }
                                            else if (secondaryInput.Key == ConsoleKey.N)
                                            {
                                                inputCheck = true;
                                            }
                                        }
                                        else
                                        {
                                            Console.Clear();
                                            Console.WriteLine("The " + Global.shopName + " cannot afford the original price of " + inventory.InventorySlots(x).CheckPrice() + ".");
                                            Console.WriteLine("Do you still want to sell " + inventory.InventorySlots(x).CheckName() + " for " + shopKeeper.CheckMoney() + "?");
                                            Console.WriteLine(Global.shopName + "'s Gold: " + shopKeeper.CheckMoney() + "      " + player.name + "'s Gold: " + player.CheckMoney());
                                            Console.WriteLine("Y) Yes     N) No");
                                            ConsoleKeyInfo secondaryInput = Console.ReadKey(true);

                                            if (secondaryInput.Key == ConsoleKey.Y)
                                            {
                                                player.GainMoney(shopKeeper.CheckMoney());
                                                shopKeeper.LoseMoney(shopKeeper.CheckMoney());
                                                inventory.removeItemFromInventory(x);
                                                inputCheck = true;
                                            }
                                            else if (secondaryInput.Key == ConsoleKey.N)
                                            {
                                                inputCheck = true;
                                            }
                                        }
                                    }
                                }
                                sellMenuOpen = false;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public void DisplayHUD(Player player, EnemyManager enemyManager, Camera camera, Inventory inventory, ItemManager itemManager)
        {
            //player stats
            //clear string to prevent overlapping text and values.....
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(0, camera.endViewY + 2);
            Console.WriteLine(clear);
            Console.Write(player.name + " health: " + player.health + "             " + player.xLoc + ", " + player.yLoc);
            Console.WriteLine(clear);
            Console.Write(player.name + " shield condition: " + player.shield + "       Gold: " + player.CheckMoney());
            Console.WriteLine(clear);
            Console.Write(player.name + " weapon in hand: " + player.equippedWeapon.itemType);
            Console.WriteLine(clear);
            Console.Write("Stolen valuables recoved: " + player.collectedValuables + "/" + itemManager.valuableCount);
            Console.WriteLine(clear);
            Console.Write("Hit 'i' to open inventory....");
            if (inventory.inventoryIsFull == true)
            {
                Console.WriteLine(clear);
                Console.WriteLine("YOUR INVENTORY IS FULL!");
                Console.WriteLine(clear);
            }
            Console.WriteLine();

            //if an enemy is close display they're stats
            for (int i = 0; i < enemyManager.enemyCount; i++)
            {
                if ((player.xLoc <= enemyManager.enemies[i].xLoc + 5) && (player.xLoc >= enemyManager.enemies[i].xLoc - 5) && (player.yLoc <= enemyManager.enemies[i].yLoc + 5) && (player.yLoc >= enemyManager.enemies[i].yLoc - 5))
                {
                    Console.WriteLine(clear);
                    Console.Write(enemyManager.enemies[i].name + " enemy number " + i + "'s health: " + enemyManager.enemies[i].health);
                }
            }
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
            Console.WriteLine(clear);
        }