예제 #1
0
 private void SlotClicked(InventorySlotUi sender)
 {
     if (sender.ContainingEntity != null)
     {
         _userInterfaceManager.DragInfo.StartDrag(sender.ContainingEntity);
     }
 }
예제 #2
0
        public void RebuildInventoryView(int maxSlots, List <Entity> entities)
        {
            int currX = 0;
            int currY = 0;

            const int spacing = 50;
            const int xOffset = 12;
            const int yOffset = 5;

            _inventoryContainer.components.Clear();

            foreach (Entity entity in entities)
            {
                var slot = new InventorySlotUi(entity, _resourceManager)
                {
                    Position = new Point(currX * spacing + xOffset, currY * spacing + yOffset)
                };

                slot.Clicked += SlotClicked;

                _inventoryContainer.components.Add(slot);

                currX++;

                if (currX < 5)
                {
                    continue;
                }

                currX = 0;
                currY++;
            }

            for (int i = 0; i < (maxSlots - entities.Count); i++)
            {
                var slot = new InventorySlotUi(null, _resourceManager)
                {
                    Position = new Point(currX * spacing + xOffset, currY * spacing + yOffset)
                };

                slot.Clicked += SlotClicked;

                _inventoryContainer.components.Add(slot);

                currX++;

                if (currX < 5)
                {
                    continue;
                }

                currX = 0;
                currY++;
            }

            _inventoryContainer.ResetScrollbars();
        }
예제 #3
0
        public void RebuildInventoryView(int maxSlots, List<Entity> entities)
        {
            int currX = 0;
            int currY = 0;

            const int spacing = 50;
            const int xOffset = 12;
            const int yOffset = 5;

            _inventoryContainer.components.Clear();

            foreach (Entity entity in entities)
            {
                var slot = new InventorySlotUi(entity, _resourceManager)
                               {
                                   Position = new Point(currX*spacing + xOffset, currY*spacing + yOffset)
                               };

                slot.Clicked += SlotClicked;

                _inventoryContainer.components.Add(slot);

                currX++;

                if (currX < 5) continue;

                currX = 0;
                currY++;
            }

            for (int i = 0; i < (maxSlots - entities.Count); i++)
            {
                var slot = new InventorySlotUi(null, _resourceManager)
                               {
                                   Position = new Point(currX*spacing + xOffset, currY*spacing + yOffset)
                               };

                slot.Clicked += SlotClicked;

                _inventoryContainer.components.Add(slot);

                currX++;

                if (currX < 5) continue;

                currX = 0;
                currY++;
            }

            _inventoryContainer.ResetScrollbars();
        }
예제 #4
0
 private void SlotClicked(InventorySlotUi sender)
 {
     if (sender.ContainingEntity != null)
         _userInterfaceManager.DragInfo.StartDrag(sender.ContainingEntity);
 }