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 OnItemRemove()
    {
        if (item.stackable == true)
        {
            if (playerInventory.ItemAndStackNumber(item).y == 1)
            {
                playerInventory.itemsList.Remove(item);
                playerInventory.RemoveItemFromStack(item);
            }
            else
            {
                playerInventory.DecItemStackNumber(item);
            }
        }
        else
        {
            playerInventory.itemsList.Remove(item);
            playerInventory.RemoveItemFromStack(item);
        }

        ClearSlot();
    }