protected override void LoadContent() { itemSlotTexture = Game.Content.Load<Texture2D>("item_slot"); inventoryWidth = itemSlotTexture.Width; inventoryHeight = itemSlotTexture.Height; // Add item slots based on the base amount of inventory slots for (int i = 0; i < numberOfInventorySlots; i++) { ItemSlot item = new ItemSlot(); items.Add(item); } base.LoadContent(); }
public override void Update(GameTime gameTime) { KeyboardState newKeyBoardState = Keyboard.GetState(); MouseState newMouseState = Mouse.GetState(); #region Keyboard input if (newKeyBoardState.IsKeyDown(Keys.Escape) && oldKeyBoardState.IsKeyUp(Keys.Escape)) { showInventory = !showInventory; } if (newKeyBoardState.IsKeyDown(Keys.G) && oldKeyBoardState.IsKeyUp(Keys.G)) { AddItem("shortSword"); } #endregion #region Mouse input if(newMouseState != oldMouseState) { //Debug.WriteLine("Mouse Moved"); if (newMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released) { int slotIndex = GetSlotIndexAt(newMouseState.X, newMouseState.Y); if(heldItem == null) { heldItem = items[slotIndex]; } } } #endregion oldMouseState = newMouseState; oldKeyBoardState = newKeyBoardState; base.Update(gameTime); }