Example #1
0
    void IDropHandler.OnDrop(PointerEventData eventData)
    {
        if (IsLocked)
        {
            return;
        }

        DraggableItemUI droppedItem = eventData.pointerDrag.gameObject.GetComponent <DraggableItemUI>();

        if (droppedItem == null)
        {
            return;
        }

        DroppableSlotUI fromSlot = droppedItem.GetComponentInParent <DroppableSlotUI>();

        if (fromSlot == null || fromSlot == this)
        {
            return;
        }

        if (inventoryUI == null)
        {
            Debug.LogError("Inventory Does Not Exists!!!\nAdd Inventory Component.");
            return;
        }

        // Check IsLocked
        if (inventoryUI.itemUIs[Index]?.Item.LockItemSlot ?? false || droppedItem.Item.LockItemSlot)
        {
            return;
        }

        // Trigger Action
        UI_Screen screen = null;

        if (fromSlot.onMoveItem(fromSlot.Index, inventoryUI.inventory, Index))
        {
            // Drop Success
            OnDropSuccess();

            // Get This Screen
            screen = GetComponentInParent <UI_Screen>();
        }
        else
        {
            // Drop Fail
            OnDropFail();

            // Get Item Screen
            screen = droppedItem.GetComponent <UI_Screen>();
        }

        // Send Screen to Top
        if (screen != null)
        {
            CloseableScreenManager.Inst.SendScreenToTop(screen);
        }
    }
    void IDropHandler.OnDrop(PointerEventData eventData)
    {
        DraggableItemUI droppedItem = eventData.pointerDrag.gameObject.GetComponent <DraggableItemUI>();

        if (droppedItem == null)
        {
            return;
        }

        // Drop Item
        InventoryBase inventory = droppedItem.Item.Inventory;

        inventory.DropItem(inventory.GetIndex_ItemID(droppedItem.Item.Info.ID));
    }