Example #1
0
    private void RemoveItem(Item itemToRemove, CharacterItemsList shopList)
    {
        //Debug.Log(itemToRemove.name + "removed");

        for (int i = shopList.itemsList.Count - 1; i >= 0; i--)
        {
            if (shopList.itemsList[i] == itemToRemove)
            {
                if (itemToRemove.stackable == true)
                {
                    if (shopList.ItemAndStackNumber(itemToRemove).y > 1)
                    {
                        shopList.DecItemStackNumber(itemToRemove);
                    }
                    else
                    {
                        shopList.RemoveItemFromStack(itemToRemove);
                        shopList.itemsList.RemoveAt(i);
                    }
                }
                else
                {
                    shopList.RemoveItemFromStack(itemToRemove);
                    shopList.itemsList.RemoveAt(i);
                    break;
                }
            }
        }
    }
Example #2
0
    public void AddItem(Item newItem)
    {
        item = newItem;

        icon.sprite  = item.itemIcon;
        icon.enabled = true;
        removeButton.interactable = true;
        if (item.stackable == true && playerInventory.ItemAndStackNumber(item).y > 1)
        {
            itemStackAmount.text    = playerInventory.ItemAndStackNumber(item).y.ToString();
            itemStackAmount.enabled = true;
        }
        else
        {
            itemStackAmount.enabled = false;
        }
    }