Ejemplo n.º 1
0
        private void ContainerSlotDragDrop(object sender, DragDropEventArgs args)
        {
            if (sender != args.Target)
            {
                return;
            }

            var sourceMetadata = ((InventorySlotMetadata)args.Dragged.Metadata);
            var targetMetadata = ((InventorySlotMetadata)args.Target.Metadata);

            var inventoryItem = GetInventoryItem(sourceMetadata);

            if (!CanAddItemToInventory(targetMetadata, inventoryItem))
            {
                return;
            }

            _gameClient.Engine.AudioEngine.Play(Resources.Sound.UIClickSoundName, (int)AudioChannel.Interface);

            var inventoryDragDropRequest =
                new ClientInventoryDragDrop
            {
                SourceInventoryId = sourceMetadata.InventoryId,
                SourceSlot        = sourceMetadata.SlotId,
                TargetInventoryId = targetMetadata.InventoryId,
                TargetSlot        = targetMetadata.SlotId
            };

            _gameClient.Engine.SendMessage(inventoryDragDropRequest);
        }
Ejemplo n.º 2
0
        private void ContainerSlotClick(object sender, ClickEventArgs args)
        {
            if (args.Button != MouseButton.Right)
            {
                return;
            }

            var metadata = ((InventorySlotMetadata)((Widget)sender).Metadata);
            var item     = GetInventoryItem(metadata);

            if (item == null)
            {
                return;
            }

            var playerInventory = GetPlayerInventory();
            var slotId          = playerInventory.GetFreeSlotForItem(item);

            if (slotId == null)
            {
                return;
            }

            var inventoryDragDropRequest =
                new ClientInventoryDragDrop
            {
                SourceInventoryId = metadata.InventoryId,
                SourceSlot        = metadata.SlotId,
                TargetInventoryId = playerInventory.Id,
                TargetSlot        = slotId.Value
            };

            _gameClient.Engine.SendMessage(inventoryDragDropRequest);
        }