This is a game component that implements IUpdateable.
Inheritance: Microsoft.Xna.Framework.DrawableGameComponent
Beispiel #1
0
 private void HandleVictoryScreen()
 {
     if (CheckKey(Keys.Enter))
     {
         if (victoryScreen.SelectedIndex == 0)
         {
             this.Exit(); //exits the game
         }
         if (victoryScreen.SelectedIndex == 1)
         {
             activeScreen.Hide(); //hides the victory screen
             activeScreen = startScreen; // sets the start screen to active
             MediaPlayer.Play(mainMenuSong); //plays the menu song
             activeScreen.Show(); // shows the start screen
             finalScore = 0;
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        private void HandleStartScreen()
        {
            if (actionScreen.isOutOfLives)
            {
                actionScreen.isOutOfLives = false;

                gOverScreen.updateScore(finalScore);
                activeScreen.Enabled = false;
                activeScreen = gOverScreen;
                activeScreen.Show();
            }
            if (actionScreen.isBossDefeated)
            {
                actionScreen.isBossDefeated = false;

                victoryScreen.updateScore(finalScore);
                activeScreen.Enabled = false;
                activeScreen = victoryScreen;
                activeScreen.Show();
            }
            if (startMenuSong == true)
            {
                startMenuSong = false;
                MediaPlayer.Play(mainMenuSong);
            }
            if (CheckKey(Keys.Enter))
            {
                if (startScreen.SelectedIndex == 0)
                {
                    activeScreen.Hide();
                    startLevelOneSong = true;
                    activeScreen = actionScreen;
                    activeScreen.Show();
                }
                if (startScreen.SelectedIndex == 1)
                {
                    activeScreen.Hide();
                    activeScreen = instructionsScreen;
                    activeScreen.Show();
                }
                if (startScreen.SelectedIndex == 2)
                {
                    activeScreen.Hide();
                    activeScreen = creditScreen;
                    activeScreen.Show();
                }
                if (startScreen.SelectedIndex == 3)
                {
                    this.Exit();
                }
            }
        }
Beispiel #3
0
 private void HandleQuitScreen()
 {
     if (CheckKey(Keys.Enter))
     {
         if (quitScreen.SelectedIndex == 0)
         {
             this.Exit();
         }
         if (quitScreen.SelectedIndex == 1)
         {
             activeScreen.Hide();
             activeScreen = actionScreen;
             activeScreen.Show();
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// 
 /// </summary>
 private void HandleInstructionsScreen()
 {
     if (CheckKey(Keys.Escape))
     {
         activeScreen.Hide();
         activeScreen = startScreen;
         activeScreen.Show();
     }
 }
Beispiel #5
0
        /// <summary>
        /// 
        /// </summary>
        private void HandleActionScreen()
        {
            if (startLevelOneSong == true)
            {
                MediaPlayer.Play(levelOneSong);
                startLevelOneSong = false;
            }

            if (actionScreen.isBossActive)
            {
                MediaPlayer.Stop();
            }

            if (CheckKey(Keys.Escape))
            {
                activeScreen.Enabled = false;
                activeScreen = quitScreen;
                activeScreen.Show();
            }
            if (actionScreen.isOutOfLives)
            {
                finalScore = actionScreen.passScore;
                activeScreen.Hide(); // hide the active screen - the game screen
                activeScreen.Enabled = false; // deseable the active screen - the game screen
                activeScreen = startScreen; // set the active screen back to the start screen
                activeScreen.Enabled = true; // enable the active screen - now start screen - back
                actionScreen.Marron.Stop(); // stop enemy 2 sound effect before playing menu sound
                actionScreen.UltraMarron.Stop(); // stop enemy 2 sound effect before playing menu sound
                actionScreen.YouFiredSound.Stop(); // stop boss's sound effect before playing menu sound
                actionScreen.AlienSound.Stop(); // stop boss's phase "song" before playing menu sound (it is not a song it is a soundEffectInstance in a loop)
                actionScreen.DealSound.Stop(); // stop boss's sound effect before playing menu sound
                LoadContent(); // reset the game
                actionScreen.isOutOfLives = true;

                MediaPlayer.Play(gameOverSong); // play game over song
                activeScreen.Show(); // show screen
            }
            else if (actionScreen.isBossDefeated)
            {
                finalScore = actionScreen.passScore;
                activeScreen.Hide(); // hide the active screen - the game screen
                activeScreen.Enabled = false; // deseable the active screen - the game screen
                activeScreen = startScreen; // set the active screen back to the start screen
                activeScreen.Enabled = true; // enable the active screen - now start screen - back
                actionScreen.Marron.Stop(); // stop enemy 2 sound effect before playing menu sound
                actionScreen.UltraMarron.Stop(); // stop enemy 2 sound effect before playing menu sound
                actionScreen.YouFiredSound.Stop(); // stop boss's sound effect before playing menu sound
                actionScreen.AlienSound.Stop(); // stop boss's phase "song" before playing menu sound (it is not a song it is a soundEffectInstance in a loop)
                actionScreen.DealSound.Stop(); // stop boss's sound effect before playing menu sound
                LoadContent(); // reset the game
                actionScreen.isBossDefeated = true; // resetting the boss to defeated so the victory screen appears

                MediaPlayer.Play(victrySong); // play victory song
                activeScreen.Show(); // show screen
            }
        }
Beispiel #6
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //load song info
            mainMenuSong = Content.Load<Song>(@"Audio\Intro"); // load menu song
            levelOneSong = Content.Load<Song>(@"Audio\LevelOne"); // load level one song
            gameOverSong = Content.Load<Song>(@"Audio\GameOver"); // load game over song
            victrySong = Content.Load<Song>(@"Audio\Victory"); // load victory song
            MediaPlayer.IsRepeating = true; // define that long is to restart once it is over

            t2dGameScreen = Content.Load<Texture2D>(@"Textures\hud"); // load hud image
            spriteFont = Content.Load<SpriteFont>(@"Fonts\Pericles"); // load font type

            startScreen = new StartScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("menu"));
            Components.Add(startScreen);
            startScreen.Hide();

            actionScreen = new ActionScreen(this, spriteBatch, Content.Load<Texture2D>(@"Textures\PrimaryBackground"), Content);
            Components.Add(actionScreen);
            actionScreen.Hide();

            instructionsScreen = new InstructionsScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("InstructionBook"));
            Components.Add(instructionsScreen);
            instructionsScreen.Hide();

            creditScreen = new CreditScreen(this, spriteBatch, Content.Load<SpriteFont>("menufont"), Content.Load<Texture2D>("menu"));
            Components.Add(creditScreen);
            creditScreen.Hide();

            quitScreen = new PopUpScreen(
                this,
                spriteBatch,
                Content.Load<SpriteFont>("menufont"),
                Content.Load<Texture2D>("alienmetal"));
            Components.Add(quitScreen);
            quitScreen.Hide();

            gOverScreen = new GameOverScreen(
                this,
                spriteBatch,
                Content.Load<SpriteFont>("menufont"),
                Content.Load<Texture2D>(@"Textures\gameover"));
            Components.Add(gOverScreen);
            gOverScreen.Hide();

            victoryScreen = new VictoryScreen(this,spriteBatch,
                 Content.Load<SpriteFont>("menufont"),
                 Content.Load<Texture2D>(@"Textures\victory"));
            Components.Add(victoryScreen);
            victoryScreen.Hide();

            actionScreen.desiredHeight = 600; // set the height of the action screen
            actionScreen.desiredWidth = 800; // set the width of the action screen

            // set the display resolution
            graphics.PreferredBackBufferHeight = actionScreen.desiredHeight;
            graphics.PreferredBackBufferWidth = actionScreen.desiredWidth;
            graphics.ApplyChanges();
            actionScreen.lowerLimitShipPosition = actionScreen.desiredHeight - 53; // sets lowest position of the ship to be 53 pixels less than height of game because of the HUB
            actionScreen.upperLimitShipPosition = 36; // sets highest position that the ship can move 36 because of the HUB
            actionScreen.leftLimitShipPosition = 0; // does not allow ship to move outside of the screen in the left side
            actionScreen.rightLimitShipPosition = actionScreen.desiredWidth - 72; // 72 is the size of the ship sprite.
            actionScreen.pixelsToMoveInYPosition = 3; // it is how many pixels - how fast - i want the ship to move in the y position
            actionScreen.pixelsToMoveInXPosition = 3; // it is how many pixels - how fast - i want the ship to move in the x position
            actionScreen.pixelsToMoveBackgroundPosition = 6; // defines the speed that the background should be constantly moving
            activeScreen = startScreen; // set the active screen to the start screen - this is the first screen that will be shown for the user
            activeScreen.Show(); // show the first screen
        }