public void OnDrop(PointerEventData data)
    {
        GUIItemEquipped itemEquip = GetItemEquipDrop(data);

        if (itemEquip != null)
        {
            // move from equipped to player inventory
            if (Type == "Inventory")
            {
                if (itemEquip.CurrentItemCollector != null)
                {
                    UnitZ.playerManager.PlayingCharacter.inventory.UnEquipItem(itemEquip.CurrentItemCollector);
                }
                return;
            }
            // drop from equipped to ground
            if (Type == "Ground")
            {
                if (itemEquip.CurrentItemCollector != null)
                {
                    UnitZ.playerManager.PlayingCharacter.inventory.DropItemByCollector(itemEquip.CurrentItemCollector, itemEquip.CurrentItemCollector.Num);
                }
            }
        }


        GUIItemCollector itemDrop = GetDropItem(data);

        if (itemDrop != null)
        {
            // Pick from ground to Player inventory;
            if (itemDrop.Type == "Ground" && Type == "Inventory")
            {
                if (itemDrop.Item != null)
                {
                    UnitZ.playerManager.PlayingCharacter.Interactive(itemDrop.Item.Item.gameObject);
                }
            }

            // Drop from player inventory to ground;
            if (itemDrop.Type == "Inventory" && Type == "Ground")
            {
                if (itemDrop.Item != null)
                {
                    itemDrop.currentInventory.DropItemByCollector(itemDrop.Item, itemDrop.Item.Num);
                }
            }
        }
    }
Beispiel #2
0
    //扔出
    public void OnDrop(PointerEventData data)
    {
        if (UnitZ.playerManager.PlayingCharacter == null)
        {
            return;
        }

        GUIItemEquipped itemEquip = GetItemEquipDrop(data);

        if (itemEquip != null)
        {
            //与已装备物品切换
            UnitZ.playerManager.PlayingCharacter.inventory.SwapEquppedSticker(CurrentSticker, itemEquip.CurrentSticker);
            return;
        }

        GUIItemCollector itemDrop = GetItemCollectorDrop(data);

        if (itemDrop != null && itemDrop.Item != null)
        {
            //从面板装备物品
            if (itemDrop.Type == "Inventory")
            {
                if (itemDrop.Item != null)
                {
                    if (UnitZ.playerManager.PlayingCharacter.inventory.EquipItemToStickerByCollector(itemDrop.Item, CurrentSticker))
                    {
                        UnitZ.playerManager.PlayingCharacter.inventory.ToggleUseEquipped(itemDrop.Item);
                    }
                }
            }

            //从地上装备物品
            if (itemDrop.Type == "Ground")
            {
                if (itemDrop.Item != null)
                {
                    UnitZ.playerManager.PlayingCharacter.Interactive(itemDrop.Item.Item.gameObject);
                    UnitZ.playerManager.PlayingCharacter.inventory.stickerTarget = CurrentSticker;
                }
            }
        }
    }
    public void OnDrop(PointerEventData data)
    {
        if (GUIItem == null || GUIItem.Item == null)
        {
            return;
        }

        // if it drag from Item equipped inventory
        GUIItemEquipped itemEquip = GetItemEquipDrop(data);

        if (itemEquip != null && GUIItem.Type == "Inventory")
        {
            if (!UnitZ.playerManager.PlayingCharacter.inventory.EquipItemToStickerByCollector(GUIItem.Item, itemEquip.Tag))
            {
                UnitZ.playerManager.PlayingCharacter.inventory.UnEquipItem(itemEquip.CurrentItemCollector);
            }
            return;
        }

        // if it drag from normal inventory
        GUIItemCollector itemDrop = GetItemCollectorDrop(data);

        if (itemDrop != null && itemDrop.Item != null)
        {
            // if it picking from ground
            if (itemDrop.Type == "Ground" && GUIItem.Type == "Inventory")
            {
                if (itemDrop.Item != null)
                {
                    UnitZ.playerManager.PlayingCharacter.Interactive(itemDrop.Item.Item.gameObject);
                }
                return;
            }

            // if it move from inventory to ground
            if (itemDrop.Type == "Inventory" && GUIItem.Type == "Ground")
            {
                if (itemDrop.Item != null)
                {
                    UnitZ.playerManager.PlayingCharacter.inventory.DropItemByCollector(itemDrop.Item, itemDrop.Item.Num);
                }
                return;
            }

            // if it moved on inventory
            if (GUIItem.currentInventory)
            {
                ItemCollector tmp = new ItemCollector();
                GUIItem.currentInventory.CopyCollector(tmp, GUIItem.Item);
                if ((GUIItem.Type == "Stock" || GUIItem.Type == "Inventory") && itemDrop.Type != "Shop")
                {
                    if (GUIItem.currentInventory != itemDrop.currentInventory)
                    {
                        // Difference Inventory
                        if (GUIItem.currentInventory.character && GUIItem.currentInventory.character.IsMine)
                        {
                            // swap to me
                            UnitZ.playerManager.PlayingCharacter.inventory.PutCollector(itemDrop.Item, GUIItem.Item.InventoryIndex);
                            UnitZ.playerManager.PlayingCharacter.inventory.PutCollectorSync(tmp, itemDrop.Item.InventoryIndex);
                        }
                        else
                        {
                            // swap to another
                            UnitZ.playerManager.PlayingCharacter.inventory.PutCollectorSync(itemDrop.Item, GUIItem.Item.InventoryIndex);
                            UnitZ.playerManager.PlayingCharacter.inventory.PutCollector(tmp, itemDrop.Item.InventoryIndex);
                        }
                    }
                    else
                    {
                        // Same Inventory

                        if (GUIItem.currentInventory.character && GUIItem.currentInventory.character.IsMine)
                        {
                            // is mine
                            GUIItem.currentInventory.SwarpCollector(GUIItem.Item, itemDrop.Item);
                        }
                        else
                        {
                            // is server
                            UnitZ.playerManager.PlayingCharacter.inventory.PutCollectorSync(itemDrop.Item, GUIItem.Item.InventoryIndex);
                            UnitZ.playerManager.PlayingCharacter.inventory.PutCollectorSync(tmp, itemDrop.Item.InventoryIndex);
                        }
                    }
                }
            }
        }
    }