示例#1
0
        void joystick_JoystickReleased(Joystick sender, Joystick.ButtonState state)
        {
            homeScreen.DrawRectangle(GT.Color.Green, 3, 70, 30, 200, 50, 3, 3, Color.Black, 0, 0, Color.Black, 0, 0, 0xff);
            //homeScreen.DrawRectangle(GT.Color.Red, 3, 70, 100, 200, 50, 3, 3, Color.Black, 0, 0, Color.Black, 0, 0, 0xff);

            if (this.CurrentPosition.X >= 70 && this.CurrentPosition.X <= 270)
            {
                if (this.CurrentPosition.Y >= 30 && this.CurrentPosition.Y <= 80)
                {
                    if (OnButtonClicked != null)
                    {
                        OnButtonClicked("IN", null);
                    }
                }
                else if (this.CurrentPosition.Y >= 100 && this.CurrentPosition.Y <= 150)
                {
                    if (OnButtonClicked != null)
                    {
                        OnButtonClicked("OUT", null);
                    }
                }
                else if (this.CurrentPosition.Y >= 170 && this.CurrentPosition.Y <= 220)
                {
                    if (OnButtonClicked != null)
                    {
                        OnButtonClicked("CANCEL", null);
                    }
                }
            }
        }
        //Events to handle center clicks on the joystick
        void joystick_JoystickPressed(Joystick sender, Joystick.ButtonState state)
        {
            //when the user is on the game screen
            if (isGameScreen)
            {
                isGameOver = winMasterMind.submitResult();

                //user win or lose the game
                if (isGameOver && winMasterMind.getFullyCorrect() == 4)
                {
                    multicolorLED.TurnGreen();
                }
                else
                {
                    multicolorLED.TurnRed();
                }
            }
            // When the user is on the 2 Players screen
            else if (isPlayer2Win)
            {
                //get colors from user 1
                solution = winPlayer2.submitResult();

                isPlayer2Win = false;
                winPlayer2.getPlayer2Win().Dispose();

                //start game for user 1
                startGame(solution);
            }
            else
            {
                if (isPlayer1Selected)
                {
                    btn1Player_ButtonPressed(new Object());
                }
                else
                {
                    btn2Player_ButtonPressed(new Object());
                }
            }
        }