Beispiel #1
0
        public Money PriceOf(Item[] items, Shop shop)
        {
            Money money = new Money();
            for(int i = 0; i < items.Length; ++i)
            {
                money.Amount += shop.PriceOf(items[i]).Amount;
            }

            return money;
        }
Beispiel #2
0
        // TOOD
        public void SellToShop(Shop shop, Player player, Item[] itemsToSell)
        {
            for(int i = 0; i < itemsToSell.Length; ++i)
            {
                Item item = itemsToSell[i];

                player.Money.Amount += shop.PriceOf(item).Amount;
                player.Inventory.Remove(item);

                shop.Add(item);
            }
        }
Beispiel #3
0
        public void BuyFromShop(Shop shop, Player player, Item[] itemsToBuy)
        {
            Money price = PriceOf(itemsToBuy, shop);

            if (player.Money.Amount < price.Amount)
            {
                throw new Exception("You only have: " + player.Money.ToString() + ", the items you wish to buy cost: " + PriceOf(itemsToBuy, shop).ToString());
            }

            if (!player.Inventory.CanHold(itemsToBuy))
            {
                throw new Exception("You cannot hold the items that you wish to purchase!");
            }

            foreach (Item item in itemsToBuy)
            {
                Money priceOfItem = shop.PriceOf(item);

                player.Money.Amount -= priceOfItem.Amount;
                player.Inventory.Add(item);

                shop.Remove(item);
            }
        }
Beispiel #4
0
 public void RemoveShop(Shop shop)
 {
     shops.Remove(shop);
     shop.Location = null;
 }
Beispiel #5
0
 public void AddShop(Shop shop)
 {
     shops.Add(shop);
     shop.Location = this;
 }
Beispiel #6
0
        /// <summary>
        /// Adds a shop to the GUI
        /// </summary>
        /// <param name="shop">The shop you wish to add</param>
        private void addShopInGui(Shop shop)
        {
            shopComboBox.Items.Add(shop);

            shopToolStripMenuItem.DropDown.Items.Add(shop.Name);
            shopToolStripMenuItem.DropDown.Items[shopToolStripMenuItem.DropDown.Items.Count - 1].Click += new EventHandler(shopItemsToolStripMenuItem_Click);
        }
Beispiel #7
0
        public void SwitchShop(Shop shop)
        {
            if (shop == null || shop == game.CurrentShop)
            {
                return;
            }

            game.CurrentShop = shop;
            shop.RandomizePriceList();

            this.shopUserControl.Shop = game.CurrentShop;
        }