コード例 #1
0
ファイル: DragDrop.cs プロジェクト: Rachellie/Crecipe
    public void OnDrop(PointerEventData eventData)
    {
        if (eventData.pointerDrag.name != "Scroll View")
        {
            DragDrop script = eventData.pointerDrag.GetComponent <DragDrop>();

            Debug.Log("from " + script.tag + " to dragdrop " + tag);

            if (!script.tag && !tag)            // BAG TO BAG
            {
                Debug.Log("OnDrop " + index);

                PlayerData.player.SwapBagItems(script.index, index);
                PlayerData.player.SetCurrentFood(PlayerData.player.GetBag()[15]);
            }
            else if (script.tag && tag)            // INVENTORY TO INVENTORY
            {
                PlayerData.player.SwapInventoryItems(script.index, index);
            }
            else if (!script.tag && tag)            // BAG TO INVENTORY
            {
                PlayerData.player.BagInventorySwap(script.GetIndex(), index);
            }
            else if (script.tag && !tag)            // INVENTORY TO BAG
            {
                PlayerData.player.InventoryBagSwap(script.GetIndex(), index);
            }

            bagScript.Refresh();
            if (bagScript != null && bagScript != script.GetBagScript())
            {
                bagScript.Refresh();
            }
        }
    }
コード例 #2
0
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log("OnDrop itemslot " + slotNum);
        if (eventData.pointerDrag != null)
        {
            if (eventData.pointerDrag.name != "Scroll View")
            {
                DragDrop script = eventData.pointerDrag.GetComponent <DragDrop>();
                script.droppedOnSlot = true;

                Debug.Log("from " + script.tag + " to itemslot " + tag);

                if (!script.tag && !tag)                // BAG TO BAG
                {
                    PlayerData.player.SwapBagItems(script.GetIndex(), slotNum);
                    if (script.GetIndex() == 15 && slotNum != 15)
                    {
                        PlayerData.player.SetCurrentFood(null);
                    }
                    if (slotNum == 15)
                    {
                        PlayerData.player.SetCurrentFood(PlayerData.player.GetBag()[15]);
                    }
                }
                else if (script.tag && tag)                // INVENTORY TO INVENTORY
                {
                    Debug.Log("inventory drop");
                    PlayerData.player.SwapInventoryItems(script.GetIndex(), slotNum);
                }
                else if (!script.tag && tag)                // BAG TO INVENTORY
                {
                    PlayerData.player.BagInventorySwap(script.GetIndex(), slotNum);
                }
                else if (script.tag && !tag)                // INVENTORY TO BAG
                {
                    PlayerData.player.InventoryBagSwap(script.GetIndex(), slotNum);
                }

                script.Refresh();
                if (bagScript != null && bagScript != script.GetBagScript())
                {
                    bagScript.Refresh();
                }
            }
        }
    }