示例#1
0
    public bool AddItem(InventorySlot slot, Item item, int amount)
    {
        bool didAdd = false;

        if (slot.ItemMatch(item))
        {
            didAdd = slot.AddAmount(amount);
        }
        else
        {
            didAdd = false;
        }
        return(didAdd);
    }
示例#2
0
 public bool AddItem(Item _item, int _amount)
 {
     if(EmptySlotCount <= 0)
     {
         return false;
     }
     InventorySlot slot = FindItemOnInventory(_item);
     if (!database.GetItem[_item.Id].stackable || slot == null)
     {
         SetEmptySlot(_item, _amount);
         return true;
     }
     slot.AddAmount(_amount);
     return true;
 }
示例#3
0
    public bool AddItem(Item item, int amount)
    {
        if (EmptySlotCount <= 0)
        {
            return(false);
        }
        InventorySlot slot = FindItemOnInventory(item);

        if (!database.ItemObjects[item.id].stackable || slot == null)
        {
            SetEmptySlot(item, amount);
            return(true);
        }
        slot.AddAmount(amount);
        return(true);
    }
示例#4
0
    public bool AddItem(Item _item, int _amount)
    {
        if (EmptySlotCount <= 0)
        {
            return(false);
        }
        InventorySlot slot = FindItemOnInventory(_item);

        if (!database.ItemObjects[_item.Id].stackable || slot == null)
        {
            SetFirstEmptySlot(_item, _amount);
            return(true);
        }
        slot.AddAmount(_amount);
        return(true);
    }
示例#5
0
    public bool AddItem(Item pickupItem, int pickupAmount)
    {
        if (EmptySlotCount <= 0)
        {
            return(false);
        }
        InventorySlot slot = FindItemOnInventory(pickupItem);

        if (!database.ItemObjects[pickupItem.Id].isStackable || slot == null)
        {
            SetEmptySlot(pickupItem, pickupAmount);
            return(true);
        }
        slot.AddAmount(pickupAmount);
        return(true);
    }
示例#6
0
    // Methods
    public bool AddItem(Item _item, int _amount)
    {
        // Adds an item to an inventory if there is space
        if (EmptySlotCount <= 0)
        {
            return(false);
        }
        InventorySlot slot = FindItemOnInventory(_item);               // Check to see if the item is already in inventory, if so stack it.

        if (!database.ItemObjects[_item.Id].stackable || slot == null) // If the item is not stackable or item is not already in inventory
        {
            SetEmptySlot(_item, _amount);
            return(true);
        }
        slot.AddAmount(_amount);
        return(true);
    }
    public bool AddItem(Item _item, int _amount)
    {
        if (EmptySlotCount <= 0)
        {
            return(false);
        }
        InventorySlot slot = FindItemOnInventory(_item);

        if (!database.GetItem[_item.Id].stackable || slot == null)
        {
            Debug.Log("setting slot");
            SetEmptySlot(_item, _amount);
            return(true);
        }
        slot.AddAmount(_amount);
        return(true);
    }
    public bool AddItem(ItemDefinition item, int amount)
    {
        if (CountEmptySlots() == 0)
        {
            return(false);
        }

        InventorySlot slot = FindSlotWithSpecificItem(item);

        if (slot == null || !slot.item_SO.isStackable)
        {
            SetItemForEmptySlot(item, amount);
            return(true);
        }
        slot.AddAmount(amount);

        return(true);
    }
示例#9
0
    public bool AddItem(Item _item, int _amount)
    {
        //find items of same type in inventory
        InventorySlot slot = FindItemOnInventory(_item);

        //if item not stackable || we didnt find any items of the same type.
        if (!database.itemsObjects[_item.id].stackable || slot == null)
        {
            if (GetNumberOfEmptySlotsCount <= 0)
            {
                return(false);
            }

            FindAndSetItemToEmptySlot(_item, _amount);
            return(true);
        }
        //if we did find a item of same type add amount to it.
        slot.AddAmount(_amount);
        return(true);
    }
示例#10
0
 public void SwapItems(InventorySlot item1, InventorySlot item2)
 {
     if (item2.CanPlaceInSlot(item1.ItemObject) && item1.CanPlaceInSlot(item2.ItemObject))
     {
         InventorySlot temp = new InventorySlot(item2.item, item2.amount);
         if (item2.parent.inventory.name == "CraftingSystem")
         {
             item2.UpdateSlot(item1.item, 1);
             if (item1.amount > 1)
             {
                 item1.UpdateSlot(item1.item, item1.amount - 1);
             }
             else
             {
                 item2.UpdateSlot(item1.item, item1.amount);
                 item1.UpdateSlot(temp.item, temp.amount);
             }
             return;
         }
         if(item1.parent.inventory.name == "MailboxInventory")
         {
             itemRemovedFromMailbox = item1.item;
             itemRemovedAmount = item1.amount;
         }
         if (item1.parent.inventory.name == "MailboxInventory" || item2.parent.inventory.name == "MailboxInventory")
         {
             changedItem = true;
             item2.parent.inventory.changedItem = true;
         }
         if (item2.item.Id == item1.item.Id && item2.parent != item1.parent)
         {
             item2.AddAmount(item1.amount);
             item1.RemoveItem();
         }
         else
         {
             item2.UpdateSlot(item1.item, item1.amount);
             item1.UpdateSlot(temp.item, temp.amount);
         }
     }
 }
示例#11
0
    public bool AddItem(Item _item, int _amount)
    {
        if (EmptySlotCount <= 0 && !database.ItemObject[_item.Id].isStackable)
        {
            return(false);
        }

        InventorySlot slot = FindItemOnInventory(_item);

        if (EmptySlotCount <= 0 && slot == null && database.ItemObject[_item.Id].isStackable)
        {
            return(false);
        }

        if (!database.ItemObject[_item.Id].isStackable || slot == null) // si on le trouve mais sa stack pas ou si on trouve pas
        {
            SetEmptySlot(_item, _amount);
            return(true);
        }
        slot.AddAmount(_amount); // found stackable and slot is not null
        return(true);
    }
示例#12
0
    public bool AddItem(Item _item, int _amount)
    {
        if (type == InterfaceType.Inventory)
        {
            Player player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
            //player.player_Event.InvokeItemAddedToInventory(_item);
        }

        if (EmptySlotCount <= 0)
        {
            return(false);
        }
        InventorySlot slot = FindItemOnInventory(_item);

        if (!database.itemObjects[_item.id].isStackable || slot == null)
        {
            SetEmptySlot(_item, _amount);
            return(true);
        }
        slot.AddAmount(_amount);
        return(true);
    }