Ejemplo n.º 1
0
    //Handles actions to be taken after finished dragging a piece of gear somewhere out of the players equipment screen
    private void StopDraggingFromEquipment(DraggableUIComponent DraggingSlot)
    {
        //First check if they stopped dragging the item into one of their inventory slots
        for (int i = 0; i < InventorySlots.Length; i++)
        {
            //Ignore this slot if it isnt where the mouse is right now
            if (!InventorySlots[i].MouseInside)
            {
                continue;
            }

            //Drag from equipment to empty inventory slot
            if (InventorySlots[i].ItemData == null)
            {
                //Dragged a piece of equipment to an empty inventory slot, unequip the item and store it in this bag slot
                ItemManagementPacketSender.SendUnequipItemRequest(PlayerManager.Instance.GetCurrentPlayerName(), InventorySlots[i].InventorySlotNumber, DraggingSlot.EquipSlotType);
                return;
            }
            //Drag from equipment to filled inventory slot
            else
            {
                //When dragging item into a filled inventory slot, the items locations are swapped if the item in the bag slot equips into the same gear slot as the item being dragged to it
                if (InventorySlots[i].EquipSlotType == DraggingSlot.EquipSlotType)
                {
                    //Dragged a piece of equipment to an already filled inventory slot with an item of the same gear slot type, swap the items positions around
                    ItemManagementPacketSender.SendSwapEquipmentItem(PlayerManager.Instance.GetCurrentPlayerName(), InventorySlots[i].InventorySlotNumber, DraggingSlot.EquipSlotType);
                    return;
                }
                else
                {
                    //Dragged a piece of equipment to an already filled inventory slot with an item of some different gear slot type, do nothing
                    return;
                }
            }
        }

        //Second, check if they stopped dragging the item into one of the other equipment slots
        for (int i = 0; i < EquipmentSlots.Length; i++)
        {
            //Ignore this slot if it isnt where the mouse is right now
            if (!EquipmentSlots[i].MouseInside)
            {
                continue;
            }

            //Drag from equipment to same equipment slot
            if (EquipmentSlots[i] == DraggingSlot)
            {
                //Dragged a piece of equipment back onto the same gear slot that it came from, do nothing
                return;
            }
            else
            {
                //Dragged a piece of equipment onto a different equipment gear slot, do nothing
                return;
            }
        }

        //Thirdly, check if they stopped dragging the item onto one of the action bar slots
        for (int i = 0; i < ActionBarSlots.Length; i++)
        {
            //Ignore this action bar slot if it isnt where the mouse is right now
            if (!ActionBarSlots[i].MouseInside)
            {
                continue;
            }

            //Dragged a piece of equipment onto the action bar, do nothing
            return;
        }

        //Dragged a piece of equipment out into the game world, unequip that item and drop it at the characters current location

        ItemManagementPacketSender.SendDropEquipmentItem(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.EquipSlotType, PlayerManager.Instance.GetCurrentCharacterLocation());
    }
Ejemplo n.º 2
0
    //Handles actions to be taken after finished dragging an item somewhere out of the players inventory
    private void StopDraggingFromInventory(DraggableUIComponent DraggingSlot)
    {
        //First figure if, which one of the inventory slots they stopped dragging this item over
        for (int i = 0; i < InventorySlots.Length; i++)
        {
            //Ignore this inventory slot if this isnt where the mouse is
            if (!InventorySlots[i].MouseInside)
            {
                continue;
            }

            //If they stopped dragging over the same inventory slot they started from, nothing needs to be done
            if (DraggingSlot == InventorySlots[i])
            {
                //Dragged item from inventory back to the same bag slot it came from, do nothing
                return;
            }

            //Second check if they stopped dragging it on top of some other empty slot in the inventory
            if (InventorySlots[i].ItemData == null)
            {
                //Dragged item from inventory to a different empty bag slot, move the item to that bag slot
                ItemManagementPacketSender.SendMoveInventoryItem(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, InventorySlots[i].InventorySlotNumber);
                return;
            }
            //Otherwise, we know there is an item here so the two items should swap positions
            else
            {
                //Dragged item to another full bag space, swap the items positions in the inventory
                ItemManagementPacketSender.SendSwapInventoryItem(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, InventorySlots[i].InventorySlotNumber);
                return;
            }
        }

        //If it wasnt found the user stopped dragging the item over an inventory slot, next check if they released the item over any equipment slot
        for (int i = 0; i < EquipmentSlots.Length; i++)
        {
            //Ignore this equipment slot if this isnt where the mouse is
            if (!EquipmentSlots[i].MouseInside)
            {
                continue;
            }

            //Do nothing if they drag a piece of equipment onto the slot of another equipment type
            if (DraggingSlot.ItemData.Slot != EquipmentSlots[i].EquipSlotType)
            {
                //Dragged item from inventory to an incompatible equipment gear slot, do nothing
                Log.PrintChatMessage("1: " + DraggingSlot.ItemData.Name + " from inventory to " + EquipmentSlots[i].EquipSlotType + " incompatible gear slot, do nothing.");
                return;
            }
            else
            {
                //If the equipment slot is empty, then the item is simply equipped here to this slot
                if (EquipmentSlots[i].ItemData == null)
                {
                    //Dragged item from inventory to an empty equipment gear slot, equip the item in this gear slot
                    Log.PrintChatMessage("2: " + DraggingSlot.ItemData.Name + " from inventory to " + EquipmentSlots[i].EquipSlotType + " empty+compatible gear slot, equip it here.");

                    ItemManagementPacketSender.SendEquipItemRequest(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, EquipmentSlots[i].EquipSlotType);
                    return;
                }
                //Otherwise, the current piece needs to be removed and replaced with the piece that was dragged on
                else
                {
                    //Dragged item from inventory to a filled equipment gear slot, equip the new item to that slot and unequip the previous item placing it where the previous item was being stored
                    Log.PrintChatMessage("3: " + DraggingSlot.ItemData.Name + " from inventory to " + EquipmentSlots[i].EquipSlotType + " full+compatible gear slot, swap them.");
                    ItemManagementPacketSender.SendSwapEquipmentItem(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, EquipmentSlots[i].EquipSlotType);
                    return;
                }
            }
        }

        //If it wasnt found the user stopped dragging the item over any inventory or equipment gear slot, finally check if they released the item over one of the action bar slots
        for (int i = 0; i < ActionBarSlots.Length; i++)
        {
            //Ignore this action bar slot if this isnt where the mouse is
            if (!ActionBarSlots[i].MouseInside)
            {
                continue;
            }

            //If they drag a non ability gem item into onto one of the action bar slots then do nothing
            if (DraggingSlot.ItemData.Type != ItemType.AbilityGem)
            {
                //Dragged an item from the inventory onto the action bar that wasnt an ability gem, do nothing
                return;
            }
            else
            {
                if (ActionBarSlots[i].ItemData == null)
                {
                    //Dragged an ability gem from the inventory onto an empty action bar slot, equip the ability
                    ItemManagementPacketSender.SendEquipAbility(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, ActionBarSlots[i].ActionBarSlotNumber);
                    return;
                }
                else
                {
                    //Dragged an ability gem from the inventory onto a filled action bar slot, swap the gems positions around
                    ItemManagementPacketSender.SendSwapEquipAbility(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, ActionBarSlots[i].ActionBarSlotNumber);
                    return;
                }
            }
        }

        //Dragged an item from the inventory to the game world, remove the item from the players inventory and drop it at their current position
        ItemManagementPacketSender.SendDropInventoryItem(PlayerManager.Instance.GetCurrentPlayerName(), DraggingSlot.InventorySlotNumber, PlayerManager.Instance.GetCurrentCharacterLocation());
    }