예제 #1
0
        override public void Update(MouseState mouseState)
        {
            if (container.Contains(mouseState.Position) && mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton != ButtonState.Pressed &&
                mouseState.Position.Y < container.Y + 30)
            {
                dragging = true;
            }

            if (dragging)
            {
                if (mouseState.LeftButton != ButtonState.Pressed)
                {
                    dragging = false;
                }
                else
                {
                    container.X += mouseState.Position.X - previousMouseState.Position.X;
                    container.Y += mouseState.Position.Y - previousMouseState.Position.Y;
                }
            }

            if (itemSlot.Contains(mouseState.Position) && mouseState.RightButton == ButtonState.Pressed && previousMouseState.RightButton != ButtonState.Pressed)
            {
                UnEquip();
            }


            itemSlot = new Rectangle(container.X + 10, container.Y + 30, 50, 50);
            if (equippedItem != null)
            {
                equippedItem.SetLocation(new Vector2(itemSlot.X + 10, itemSlot.Y + 10));
            }

            previousMouseState = mouseState;
        }
예제 #2
0
 public void Equip(InventoryItem item)
 {
     UnEquip();
     equippedItem = item;
     equippedItem.SetLocation(new Vector2(itemSlot.X + 10, itemSlot.Y + 10));
 }