示例#1
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  Buy()
        //------------------------------------------------------------------------------------------------------------------------
        //not implemented yet
        public void Buy()
        {
            Item itemSelect = GetSelectedItem();

            int itemAmount = itemSelect.GetPropertyValue <int>(typeof(AmountProperty));
            int itemCost   = itemSelect.GetPropertyValue <int>(typeof(CostProperty));

            if (itemAmount > 0 && playerMoney >= itemSelect.GetPropertyValue <int>(typeof(CostProperty)))
            {
                decreaseMoney(itemCost);
                itemSelect.decreaseStock();
                inventoryList.Add(itemSelect);
                AddMessage("Successful purchase!");
            }
            else
            {
                if (playerMoney < itemCost)
                {
                    AddMessage("You don't have enough money!");
                }
                else if (itemAmount < 1)
                {
                    AddMessage("Out of stock!");
                }
            }
        }
示例#2
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  Sell()
        //------------------------------------------------------------------------------------------------------------------------
        //not implemented yet
        public void Sell()
        {
            Item itemSelect = GetSelectedItem();

            if (inventoryList.Contains(itemSelect))
            {
                int itemCost = itemSelect.GetPropertyValue <int>(typeof(CostProperty));
                increaseMoney(itemCost);
                itemSelect.increaseStock();
                inventoryList.Remove(itemSelect);
                AddMessage("Sold!");
            }
            else
            {
                AddMessage("You don't have this item!");
            }
        }