コード例 #1
0
ファイル: TraderGame.cs プロジェクト: miguelmartin75/Trader
        public void UpgradeInventory(Player player)
        {
            Money price = CalculateCostToUpgradeInventory(player);
            if (price.Amount > player.Money.Amount)
            {
                throw new System.Exception("Upgrade costs: " + price.ToString() + ", you have: " + player.Money.ToString());
            }

            // upgrade the inventory
            player.Inventory.MaxWeight += 5;
            player.Money.Amount -= price.Amount;

            preferences.BaseBagUpgradePrice += (int)(preferences.BaseBagUpgradePrice * preferences.BagUpgradePricePercentageIncrease / 100.0);
        }
コード例 #2
0
ファイル: TraderGame.cs プロジェクト: miguelmartin75/Trader
 public Money CalculateCostToUpgradeInventory(Player player)
 {
     return new Money(preferences.BaseBagUpgradePrice);
 }
コード例 #3
0
ファイル: TraderGame.cs プロジェクト: miguelmartin75/Trader
        // 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);
            }
        }
コード例 #4
0
ファイル: TraderGame.cs プロジェクト: miguelmartin75/Trader
        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);
            }
        }