示例#1
0
    public void StopDragItem(int index)
    {
        if (itemBox != null)
        {
            // IF the item box is dragged outside of the inventory boundaries
            if (!isWithinBounds(itemBox.transform.position, GetComponent <BoxCollider2D>()))
            {
                if (index < currInventory.items.Count)
                {
                    // IF the external inventory is open and IF the item box is inside its boundaries
                    if (externalInventoryReference != null && isWithinBounds(itemBox.transform.position, externalInventoryBoundsReference.GetComponent <BoxCollider2D>()))
                    {
                        if (externalInventoryReference.AddItem(currInventory.items[index]))
                        {
                            currInventory.removeItem(currInventory.items[index]);
                        }

                        externalInventoryBoundsReference.GetComponent <UI_InventoryController>().openInventory(externalInventoryReference);
                    }
                    else
                    {
                        currInventory.DropItem(currInventory.items[index]);
                    }
                }
            }

            Debug.Log(externalInventoryReference == null);

            openInventory(currInventory);
            itemBox.transform.position = startPos;

            inventoryChanged = true;
        }
    }