public void AddItem(ItemList.ItemInfo itemInfo)
        {
            int maxStack       = Inventory.CreateItem(itemInfo.itemCode).Data.maxStack;
            int remainingCount = itemInfo.count;

            while (remainingCount > 0)
            {
                int bundleCount = Mathf.Clamp(remainingCount, 0, maxStack);
                var newItem     = NextEmptyCell().SetItem(Inventory.CreateItem(itemInfo.itemCode), bundleCount);
                if (openBagSlotAction != null)
                {
                    newItem.SetSelfAction(openBagSlotAction);
                }
                else
                {
                    newItem.SetUseAction();
                }

                remainingCount -= bundleCount;
            }
        }
Beispiel #2
0
    private void BuyConsumable(bool Food = false)
    {
        var virtualShopItems = GameObject.Find("Career Scripts").GetComponent <Items.Shops.GeneralStore>().Items;
        List <InventorySystem.ItemList.ItemInfo> shopList = new List <InventorySystem.ItemList.ItemInfo>();

        InventorySystem.ItemList.ItemInfo itemToBuy = new InventorySystem.ItemList.ItemInfo();
        float price = -1;

        foreach (var Item in virtualShopItems)
        {
            if (Item.Name == "Water" && !Food)
            {
                price = Item.price * 2;
            }
            else if (Item.Name != "Water" && Food)
            {
                if (Item.ItemType == Items.ItemType.Food)
                {
                    price = ItemIngredientPrice(Item);
                }
            }
            if (Stats.Money >= price && price > 0)
            {
                Stats.RemoveMoney(price);
                itemToBuy.itemCode = Item.code;
                itemToBuy.count    = 1;
                shopList.Add(itemToBuy);
                InventorySystem.Inventory.PlaceOnBag(shopList);
                ConsumeItem(Item.name, 1);
                return;
            }
            else if (Item.Name == "Water" && !Food)
            {
                return;
            }
        }
    }