예제 #1
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            frmHighScores frmHighScore2 = new frmHighScores();

            Hide();
            frmHighScore2.ShowDialog();
        }
예제 #2
0
        protected override void Update(GameTime gameTime)
        {
            Rectangle cursor = new Rectangle(mouseState.X, mouseState.Y, 1, 1);

            previousKeyboardState = currentKeyboardState;
            oldMouseState         = mouseState;

            currentKeyboardState = Keyboard.GetState();
            mouseState           = Mouse.GetState();

            // check if player is in main menu
            if (scrActive == scrStart)
            {
                if (scrInstructions.Enabled)
                {
                    if (UniqueKeyPress(Keys.Escape))
                    {
                        scrActive.Enabled = true;
                        scrInstructions.Hide();
                    }
                }
                else
                {
                    if (UniqueKeyPress(Keys.Enter) || (cursor.Intersects(scrStart.MenuAreas[scrStart.SelectedIndex]) && LeftClicked()))
                    {
                        switch (scrStart.SelectedIndex)
                        {
                        case (int)MENU_OPTIONS.START_GAME:
                            scrActive.Hide();
                            StartGame();
                            scrActive = scrPlay;
                            scrActive.Show();
                            break;

                        case (int)MENU_OPTIONS.INSTRUCTIONS:
                            scrActive.Enabled = false;
                            scrInstructions.Show();
                            break;

                        case (int)MENU_OPTIONS.HIGH_SCORES:
                            frmHighScores.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                            frmHighScores.UpdateScores(currentAccount.Scores());
                            frmHighScores.ShowDialog();
                            break;

                        case (int)MENU_OPTIONS.EXIT:
                            this.Exit();
                            break;
                        }
                    }
                }
            }

            // check if player is in game screen
            else if (scrActive == scrPlay)
            {
                if (UniqueKeyPress(Keys.Escape) && !scrPlay.GameOver)
                {
                    // quick pause/unpause
                    if (scrPause.Enabled)
                    {
                        UnPause();
                    }
                    else
                    {
                        Pause();
                    }
                }
                else if (scrPause.Enabled)
                {
                    // choose options in pause menu
                    if (UniqueKeyPress(Keys.Enter) || (cursor.Intersects(scrPause.MenuAreas[scrPause.SelectedIndex]) && LeftClicked()))
                    {
                        switch (scrPause.SelectedIndex)
                        {
                        case (int)PAUSE_OPTIONS.RESUME:
                            UnPause();
                            break;

                        case (int)PAUSE_OPTIONS.LEAVE_GAME:
                            CloseGame();
                            break;
                        }
                    }
                }
                else if (scrPlay.GameOver)
                {
                    // when player has no lifes left
                    scrActive.Enabled = false;
                    scrGameOver.Show();

                    // close game over screen
                    if (UniqueKeyPress(Keys.Enter) || (cursor.Intersects(scrPause.MenuAreas[scrPause.SelectedIndex]) && LeftClicked()))
                    {
                        currentAccount.SaveScore(scrPlay.Score);
                        CloseGame();
                    }
                }
            }

            base.Update(gameTime);
        }