Esempio n. 1
0
        private void StopDraggingItem(SlotButton button)
        {
            myDragOriginButton.Slot.Item  = myDraggedItem;
            myDragOriginButton.Slot.Count = myDragCount;

            RemoveChild(myDragSprite);
            myDragSprite = null;

            if (myDragOriginButton != button)
            {
                myDraggingItem = false;

                button.Slot.Swap(myDragOriginButton.Slot);

                InventorySingleView invViewA = myDragOriginButton.Parent as InventorySingleView;
                InventorySingleView invViewB = button.Parent as InventorySingleView;

                GameClient.SendTransferItem(invViewA.Inventory.Owner, invViewB.Inventory.Owner, myDragOriginButton.Slot, button.Slot);
            }

            foreach (SlotButton btn in myPlayerView.Slots)
            {
                if (!btn.Slot.HasItem)
                {
                    btn.Disable();
                }
            }

            if (myEntityView != null)
            {
                foreach (SlotButton btn in myEntityView.Slots)
                {
                    if (!btn.Slot.HasItem)
                    {
                        btn.Disable();
                    }
                }
            }
        }
Esempio n. 2
0
        public InventoryView(Inventory inventory, Vector2 size)
            : base(size)
        {
            Title = "Inventory View";

            myPlayerView = new InventorySingleView(this, inventory, new Vector2(InnerWidth, InnerHeight));
            AddChild(myPlayerView);

            myPlayerView.SlotButtonClicked += delegate(object sender, SlotButtonClickedEventArgs e)
            {
                if (!IsDraggingItem)
                {
                    if (e.Slot.HasItem)
                    {
                        GameClient.SendUseItem(e.Slot);
                    }
                }
                else
                {
                    myDraggingItem = false;
                }
            };
        }
Esempio n. 3
0
        public InventoryView(Inventory inventoryA, Inventory inventoryB, Vector2 size)
            : base(size)
        {
            Title = "Inventory View";

            myPlayerView = new InventorySingleView(this, inventoryA, new Vector2(InnerWidth / 2 - 2, InnerHeight));
            myEntityView = new InventorySingleView(this, inventoryB, new Vector2(InnerWidth / 2 - 2, InnerHeight))
            {
                Left = InnerWidth / 2 + 2
            };

            AddChild(myPlayerView);
            AddChild(myEntityView);

            myPlayerView.SlotButtonClicked += delegate(object sender, SlotButtonClickedEventArgs e)
            {
                if (!IsDraggingItem)
                {
                    if (e.Slot.HasItem)
                    {
                        Item item = e.Slot.Item;

                        if (inventoryB.CanAddItem(item))
                        {
                            GameClient.SendTransferItem(inventoryA.Owner, inventoryB.Owner, e.Slot);
                        }
                    }
                }
                else
                {
                    myDraggingItem = false;
                }
            };

            myEntityView.SlotButtonClicked += delegate(object sender, SlotButtonClickedEventArgs e)
            {
                if (!IsDraggingItem)
                {
                    if (e.Slot.HasItem)
                    {
                        Item item = e.Slot.Item;

                        if (inventoryA.CanAddItem(item))
                        {
                            GameClient.SendTransferItem(inventoryB.Owner, inventoryA.Owner, e.Slot);
                        }
                    }
                }
                else
                {
                    myDraggingItem = false;
                }
            };

            Closed += delegate(object sender, EventArgs e)
            {
                if (inventoryA != null)
                {
                    (inventoryA.Owner as IContainer).Inventory = inventoryA = null;
                }
                if (inventoryB != null)
                {
                    (inventoryB.Owner as IContainer).Inventory = inventoryB = null;
                }
            };
        }