示例#1
0
    private void Update()
    {
        if (isInPickupRange)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                ItemContainerController container = gameObject.GetComponent <ItemContainerController>();

                switch (gameObject.tag)
                {
                case "WasteBin":
                    ItemTrash inventoryTrash = inventory.GetTrashItem();
                    if (inventoryTrash.item != null)
                    {
                        container.AddItem(inventoryTrash);
                        inventory.RemoveTrashItem(inventoryTrash);
                    }
                    break;

                case "TrashCan":
                    ItemTrash containerTrash = container.GetTrashItem();
                    if (containerTrash.item != null)
                    {
                        inventory.AddTrashItem(containerTrash);
                        container.RemoveItem(containerTrash);
                    }
                    break;
                }
            }
        }
    }
 public void RemoveItem(ItemTrash trash)
 {
     if (trash != null)
     {
         container.trashList.Remove(trash);
     }
 }
示例#3
0
    public void RemoveTrashItem(ItemTrash trash)
    {
        PlayerInventorySlot fullSlot = inventorySlots.Find(p => p.item == trash);

        Destroy(fullSlot.item.item);
        fullSlot.item = null;
    }
 public void AddItem(ItemTrash trash)
 {
     if (trash != null)
     {
         container.trashList.Add(trash);
     }
 }
示例#5
0
    public void AddTrashItem(ItemTrash trash)
    {
        PlayerInventorySlot openSlot = inventorySlots.FirstOrDefault <PlayerInventorySlot>(p => p.isFull == false);
        GameObject          newItem  = Instantiate <GameObject>(trash.item, openSlot.slot.transform, false);

        openSlot.item = newItem.GetComponent <ItemTrash>();
    }