예제 #1
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);
        }
예제 #2
0
        private void CloseGame()
        {
            scrGameOver.Dispose();
            scrPause.Dispose();
            scrPlay.Dispose();

            scrActive = scrStart;
            scrActive.Show();
        }
예제 #3
0
        protected override void LoadContent()
        {
            frmHighScores = new frmHighScores();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>("GameFont");
            spriteFont.LineSpacing = 20;

            scrStart = new Screen_Basic(this, spriteBatch, Content.Load<Texture2D>("Graphics/Backgrounds/Start"), Menu.MenuItems(new MENU_OPTIONS()));
            Components.Add(scrStart);
            scrStart.Hide();

            scrInstructions = new scrPopup(this, spriteBatch, Content.Load<Texture2D>("Graphics/Backgrounds/Instructions"), scrStart, 500, 500);
            Components.Add(scrInstructions);
            scrInstructions.Hide();

            scrActive = scrStart;
            scrActive.Show();
        }