public void HideInventory() { if (!equipmentWindow.Enabled) { Hide(); } InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent; inventory.Inventory.SetEnabled(false); inventoryWindow.Hide(); }
public void ShowInventory() { if (!Enabled) { Show(); } InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent; inventory.Inventory.SetEnabled(true); inventoryWindow.Show(); }
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; } } }
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); }
public void AddItemToInventory(InventoryItem item) { InventoryWindowComponent inventory = inventoryWindow.Component as InventoryWindowComponent; inventory.Inventory.AddItemToFirstFreeSlot(item); }