Esempio n. 1
0
        public void MouseInput(GameTime gameTime)
        {
            oldState     = currentState;
            currentState = Mouse.GetState();

            if (Global.displayInv)
            {
                if (currentState.LeftButton == ButtonState.Pressed && Global.hover == false)
                {
                    //get selected inv slot
                    selectedInvSlot = ui.GetSlot(currentState);
                    if (selectedInvSlot != -1)
                    {
                        Global.hover = true;
                        int textureID = player.GetSlotTexture(selectedInvSlot);
                        ui.SetHover(textureID);
                    }
                }
                else if (currentState.LeftButton == ButtonState.Released && Global.hover == true)
                {
                    newInvSlot = ui.GetSlot(currentState);
                    if (newInvSlot != -1)
                    {
                        player.MoveSlots(selectedInvSlot, newInvSlot);
                        Global.hover = false;
                    }
                    else
                    {
                        player.MoveSlots(selectedInvSlot, selectedInvSlot);
                        Global.hover = false;
                    }
                }
            }
            else
            {
                if (currentState.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Pressed)
                {
                    // if left mouse button is pressed and released
                    Global.digging = true;
                    area.BlockModifier("Delete", player, gameTime);
                }
                else
                {
                    area.ResetDig();
                }
                if (currentState.RightButton == ButtonState.Released && oldState.RightButton == ButtonState.Pressed)
                {
                    digTimer = 0;
                    // if left mouse button is pressed and released
                    area.BlockModifier("Add", player, gameTime);
                }
            }
        }