Ejemplo n.º 1
0
    public bool AddItem(ItemObject item, int slot)
    {
        if (slot == -1)
        {
            return(false);
        }
        if (inventory[slot] == null)
        {
            inventory[slot] = new InventorySlot(item, item.GetAmount());

            if (slot == 1)
            {
                gameUI.UpdateGrenadeAmount(item.GetAmount());
            }
            else if (slot == 0)
            {
                gameUI.AddTowerIcon(item.GetIconSprite());
            }

            return(true);
        }
        if (inventory[slot].item == item)
        {
            if (inventory[slot].amount < inventorySlotSize[slot])
            {
                inventory[slot].addAmount(1);

                if (slot == 1)
                {
                    gameUI.UpdateGrenadeAmount(inventory[slot].amount);
                }

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

        return(false);
    }