public void AddItem(ItemScriptable item, int amount = 1)
    {
        int itemIndex = items.FindIndex(itemScript => itemScript.name == item.name);

        if (itemIndex != -1)
        {
            ItemScriptable listItem = items[itemIndex];

            if (listItem.stackable && listItem.Amount < listItem.maxStack)
            {
                listItem.ChangeAmount(item.Amount);
            }
        }
        else
        {
            if (item == null)
            {
                return;
            }

            ItemScriptable itemClone = Instantiate(item);
            itemClone.Initialize(playerController);
            itemClone.SetAmount(amount <= 1 ? item.Amount : amount);
            items.Add(itemClone);
        }
    }
예제 #2
0
    private void Instantiate()
    {
        ItemInstance = Instantiate(PickUpItem);
        if (Amount > 0)
        {
            ItemInstance.SetAmount(Amount);
        }

        ApplyMesh();
    }
    private void Instantiate()
    {
        itemInstance = Instantiate(pickUpItem);

        if (amount > 0)
        {
            itemInstance.SetAmount(amount);
        }

        ApplyMesh();
    }