Ejemplo n.º 1
0
        void selected(Object sender, EventArgs e)
        {
            bool      bought = false;
            LinkLabel ll     = (LinkLabel)sender;

            if (ll.Text.Equals((shopInventory[0].ToString() + "  " + shopInventory[0].Cost)) && !bought)
            {
                if (player.Money >= shopInventory[0].Cost && !bought)
                {
                    player.Money -= shopInventory[0].Cost;

                    if (shopInventory[0] is Consumable)
                    {
                        bought = true;
                        player.AcquireItem((Consumable)shopInventory[0]);
                    }

                    if (shopInventory[0] is Equipment)
                    {
                        bought = true;
                        player.AcquireItem((Equipment)shopInventory[0]);
                    }
                }
            }
            else if (ll.Text.Equals(shopInventory[1].ToString() + "  " + shopInventory[1].Cost) && !bought)
            {
                if (player.Money >= shopInventory[1].Cost)
                {
                    player.Money -= shopInventory[1].Cost;
                    if (shopInventory[1] is Consumable)
                    {
                        player.AcquireItem((Consumable)shopInventory[1]);
                        bought = true;
                    }
                    if (shopInventory[1] is Equipment)
                    {
                        player.AcquireItem((Equipment)shopInventory[1]);
                        bought = true;
                    }
                }
            }
        }