Exemplo n.º 1
0
        public void HideInventory()
        {
            if (!equipmentWindow.Enabled)
            {
                Hide();
            }
            InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent;

            inventory.Inventory.SetEnabled(false);
            inventoryWindow.Hide();
        }
Exemplo n.º 2
0
        public void ShowInventory()
        {
            if (!Enabled)
            {
                Show();
            }
            InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent;

            inventory.Inventory.SetEnabled(true);
            inventoryWindow.Show();
        }
Exemplo n.º 3
0
        public void OnUnequip(object sender, EventArgs args)
        {
            if (!(sender is InventoryItem) ||
                inventoryManager.DraggedItem != null)
            {
                return;
            }
            else
            {
                InventoryItem            item      = (InventoryItem)sender;
                InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent;

                if (!inventory.Inventory.AddItemToFirstFreeSlot(item))
                {
                    inventoryManager.DraggedItem = item;
                    item.IsBeingDragged          = true;
                    item.IsMouseInside           = false;
                }
            }
        }
Exemplo n.º 4
0
        private SimpleHUDWindow CreateInventoryWindow(SpriteFont font, ContentManager content, Texture2D border, Rectangle screenRectangle, InventoryManager inventoryManager)
        {
            SimpleHUDWindow inventoryWindow = new SimpleHUDWindow(font);

            //TODO: hardcoded title
            inventoryWindow.Title = "Inventory";
            InventoryWindowComponent inventoryComponent = new InventoryWindowComponent(font, content, inventoryManager);

            inventoryComponent.RegisterEquip(OnEquip);
            inventoryWindow.BorderTexture = border;
            //TODO: hardcoded size
            inventoryWindow.Size = new Vector2(400, 600);

            float positionOffset = (screenRectangle.Width / 2 >= inventoryWindow.Size.X) ?
                                   (screenRectangle.Width / 2 - inventoryWindow.Size.X) / 2 :
                                   0;
            Vector2 position = new Vector2(screenRectangle.Width / 2 + positionOffset, (screenRectangle.Height - inventoryWindow.Size.Y) / 2);

            inventoryWindow.Position  = position;
            inventoryWindow.Component = inventoryComponent;

            return(inventoryWindow);
        }
Exemplo n.º 5
0
        public void AddItemToInventory(InventoryItem item)
        {
            InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent;

            inventory.Inventory.AddItemToFirstFreeSlot(item);
        }