Esempio n. 1
0
 public TranslatedMouse(IMouse mouse, int xOffset, int yOffset)
 {
     this.x            = mouse.GetX() + xOffset;
     this.y            = mouse.GetY() + yOffset;
     this.pressedLeft  = mouse.IsLeftMouseButtonPressed();
     this.pressedRight = mouse.IsRightMouseButtonPressed();
 }
Esempio n. 2
0
 public CopiedMouse(IMouse mouse)
 {
     this.x          = mouse.GetX();
     this.y          = mouse.GetY();
     this.leftMouse  = mouse.IsLeftMouseButtonPressed();
     this.rightMouse = mouse.IsRightMouseButtonPressed();
 }
Esempio n. 3
0
        public void ProcessFrame(
            IMouse mouseInput,
            IMouse previousMouseInput)
        {
            int mouseX = mouseInput.GetX();
            int mouseY = mouseInput.GetY();

            if (mouseInput.IsLeftMouseButtonPressed() &&
                !previousMouseInput.IsLeftMouseButtonPressed() &&
                this._xPos <= mouseX &&
                mouseX <= this._xPos + 40 &&
                this._yPos <= mouseY &&
                mouseY <= this._yPos + 50)
            {
                if (this._currentVolume == 0)
                {
                    this._currentVolume = this._unmuteVolume == 0 ? DEFAULT_VOLUME : this._unmuteVolume;
                    this._unmuteVolume  = this._currentVolume;
                }
                else
                {
                    this._unmuteVolume  = this._currentVolume;
                    this._currentVolume = 0;
                }
            }

            if (mouseInput.IsLeftMouseButtonPressed() &&
                !previousMouseInput.IsLeftMouseButtonPressed() &&
                this._xPos + 50 <= mouseX &&
                mouseX <= this._xPos + 150 &&
                this._yPos + 10 <= mouseY &&
                mouseY <= this._yPos + 40)
            {
                this._isDraggingVolumeSlider = true;
            }

            if (this._isDraggingVolumeSlider && mouseInput.IsLeftMouseButtonPressed())
            {
                int volume = mouseX - (this._xPos + 50);
                if (volume < 0)
                {
                    volume = 0;
                }
                if (volume > 100)
                {
                    volume = 100;
                }

                this._currentVolume = volume;
                this._unmuteVolume  = this._currentVolume;
            }

            if (!mouseInput.IsLeftMouseButtonPressed())
            {
                this._isDraggingVolumeSlider = false;
            }
        }
Esempio n. 4
0
        public void ProcessInputs(IKeyboard keyboardInput, IMouse mouseInput, IKeyboard previousKeyboardInput, IMouse previousMouseInput)
        {
            int x = mouseInput.GetX();
            int y = mouseInput.GetY();

            this.isHoveringOverNewGame = x >= 0 &&
                                         x <= 250 &&
                                         y >= 0 &&
                                         y <= 50;

            this.hasStartedNewGame = this.isHoveringOverNewGame &&
                                     mouseInput.IsLeftMouseButtonPressed() &&
                                     !previousMouseInput.IsLeftMouseButtonPressed();
        }
Esempio n. 5
0
        public void ProcessInputs(IKeyboard keyboardInput, IMouse mouseInput, IKeyboard previousKeyboardInput, IMouse previousMouseInput)
        {
            int x = mouseInput.GetX();
            int y = mouseInput.GetY();

            if (mouseInput.IsLeftMouseButtonPressed() && !previousMouseInput.IsLeftMouseButtonPressed())
            {
                if (y >= 0 && y <= 50)
                {
                    if (x >= 150 && x < 250)
                    {
                        this.currentlySelectedDifficultyValue = DTSudokuDifficultyValue.Easy;
                    }
                    if (x >= 250 && x < 350)
                    {
                        this.currentlySelectedDifficultyValue = DTSudokuDifficultyValue.Normal;
                    }
                    if (x >= 350 && x < 450)
                    {
                        this.currentlySelectedDifficultyValue = DTSudokuDifficultyValue.Hard;
                    }
                }
            }
        }
Esempio n. 6
0
        public void ProcessInputs(IKeyboard keyboardInput, IMouse mouseInput, IKeyboard previousKeyboardInput, IMouse previousMouseInput)
        {
            Func <Key, bool> isPressed = key => keyboardInput.IsPressed(key) && !previousKeyboardInput.IsPressed(key);

            if (this.selectedCell != null)
            {
                if (isPressed(Key.UpArrow) && this.selectedCell.Item2 > 0)
                {
                    this.selectedCell = new Tuple <int, int>(this.selectedCell.Item1, this.selectedCell.Item2 - 1);
                }
                if (isPressed(Key.DownArrow) && this.selectedCell.Item2 < 8)
                {
                    this.selectedCell = new Tuple <int, int>(this.selectedCell.Item1, this.selectedCell.Item2 + 1);
                }
                if (isPressed(Key.LeftArrow) && this.selectedCell.Item1 > 0)
                {
                    this.selectedCell = new Tuple <int, int>(this.selectedCell.Item1 - 1, this.selectedCell.Item2);
                }
                if (isPressed(Key.RightArrow) && this.selectedCell.Item1 < 8)
                {
                    this.selectedCell = new Tuple <int, int>(this.selectedCell.Item1 + 1, this.selectedCell.Item2);
                }
            }

            if (mouseInput.IsLeftMouseButtonPressed() && !previousMouseInput.IsLeftMouseButtonPressed())
            {
                int x = mouseInput.GetX() / WIDTH;
                int y = mouseInput.GetY() / WIDTH;

                if (x >= 0 && x < 9 && y >= 0 && y < 9 && mouseInput.GetX() >= 0 && mouseInput.GetY() >= 0)
                {
                    this.selectedCell = new Tuple <int, int>(x, y);
                }
                else
                {
                    this.selectedCell = null;
                }
            }

            if (this.selectedCell != null)
            {
                int x = this.selectedCell.Item1;
                int y = this.selectedCell.Item2;

                if (this.initialBoard[x, y] == 0)
                {
                    if (isPressed(Key.One))
                    {
                        this.currentBoard[x, y] = 1;
                    }
                    if (isPressed(Key.Two))
                    {
                        this.currentBoard[x, y] = 2;
                    }
                    if (isPressed(Key.Three))
                    {
                        this.currentBoard[x, y] = 3;
                    }
                    if (isPressed(Key.Four))
                    {
                        this.currentBoard[x, y] = 4;
                    }
                    if (isPressed(Key.Five))
                    {
                        this.currentBoard[x, y] = 5;
                    }
                    if (isPressed(Key.Six))
                    {
                        this.currentBoard[x, y] = 6;
                    }
                    if (isPressed(Key.Seven))
                    {
                        this.currentBoard[x, y] = 7;
                    }
                    if (isPressed(Key.Eight))
                    {
                        this.currentBoard[x, y] = 8;
                    }
                    if (isPressed(Key.Nine))
                    {
                        this.currentBoard[x, y] = 9;
                    }
                    if (isPressed(Key.Zero) || isPressed(Key.Backspace) || isPressed(Key.Delete))
                    {
                        this.currentBoard[x, y] = 0;
                    }
                }
            }
        }