Esempio n. 1
0
    public bool Add(Item item, int stack)
    {
        /*
         * Add an item in the inventory with is stack (ex: if you loot 3 same potion)
         */
        if (!item.isDefaultItem)
        {
            ItemStack itemStackInventory = itemsStack.Find(x => x.item == item);
            if (itemStackInventory != null)
            {
                itemStackInventory.AddStacks(stack);
            }
            else
            {
                if (itemsStack.Count >= space)
                {
                    Debug.Log("Not enough space in inventory");
                    return(false);
                }
                //Debug.Log("ICI: " + item.name + stack.ToString() );
                itemsStack.Add(new ItemStack(item, stack));
            }

            onItemChangedCallback?.Invoke();

            return(true);
        }
        return(false);
    }