예제 #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            int selectedIndex = 0;

            KeyboardState ks = Keyboard.GetState();

            if (startScene.Enabled)
            {
                //MediaPlayer.Stop();
                selectedIndex = startScene.Menu.SelectedIndex;
                if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter))
                {
                    MediaPlayer.Stop();
                    hideAllScenes();
                    MediaPlayer.Play(bg);
                    actionScene.Enabled = true;
                }
                else if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter))
                {
                    MediaPlayer.Stop();
                    hideAllScenes();
                    MediaPlayer.Play(howToScreenSong);
                    howToPlayScreen.show();
                }
                else if (selectedIndex == 2 && ks.IsKeyDown(Keys.Enter))
                {
                    MediaPlayer.Stop();
                    hideAllScenes();
                    MediaPlayer.Play(helpScreenSong);
                    helpScene.show();
                }
                else if (selectedIndex == 3 && ks.IsKeyDown(Keys.Enter))
                {
                    MediaPlayer.Stop();
                    hideAllScenes();
                    MediaPlayer.Play(creditScreenSong);
                    creditScreen.show();
                }
                //handle other menu options
                else if (selectedIndex == 4 && ks.IsKeyDown(Keys.Enter))
                {
                    Exit();
                }
            }

            if (actionScene.Enabled || helpScene.Enabled || creditScreen.Enabled || howToPlayScreen.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    MediaPlayer.Play(homeScreenSong);
                    hideAllScenes();
                    startScene.show();
                }
            }
            // TODO: Add your update logic here

            base.Update(gameTime);
        }
예제 #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            int selectedIndex = 0;

            KeyboardState ks = Keyboard.GetState();

            if (!isSceneAvail && ((int)gameTime.TotalGameTime.TotalMilliseconds - lastNewScene) > sceneDelay)
            {
                isSceneAvail = true;
            }

            if (startScene.Enabled)
            {
                selectedIndex = startScene.Menu.SelectedIndex;
                if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter) && isSceneAvail)
                {
                    hideAllScenes();
                    actionScene.Components.Clear();
                    actionScene = new ActionScene(this);
                    this.Components.Add(actionScene);
                    actionScene.show();
                }
                else if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    helpScene.show();
                }
                else if (selectedIndex == 2 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    scoreScene.show();
                }
                else if (selectedIndex == 3 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    creditScene.show();
                }
                else if (selectedIndex == 4 && ks.IsKeyDown(Keys.Enter))
                {
                    Exit();
                }
            }

            if (actionScene.Enabled || helpScene.Enabled || creditScene.Enabled || scoreScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    hideAllScenes();
                    startScene.show();
                }
            }


            // TODO: Add your update logic here

            base.Update(gameTime);
        }
예제 #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            int selectedIndex = 0;


            KeyboardState ks = Keyboard.GetState();


            if (startScene.Enabled)
            {
                selectedIndex = startScene.Menu.SelectedIndex;
                if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter))
                {
                    //creates the gamescene when it is entered
                    actionScene = new ActionScene(this, spriteBatch);
                    this.Components.Add(actionScene);

                    hideAllScenes();
                    actionScene.show();

                    //plays background music
                    MediaPlayer.Play(song);
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Volume      = 0.1f;
                    gameStateActive         = true;
                }
                else if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    aboutScene.show();
                }
                else if (selectedIndex == 2 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    helpScene.show();
                }
                else if (selectedIndex == 3 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    howToPlayScene.show();
                }
                else if (selectedIndex == 4 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    highScoreScene.show();
                }
                else if (selectedIndex == 5 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    creditScene.show();
                }
                //handle other menu options
                else if (selectedIndex == 6 && ks.IsKeyDown(Keys.Enter))
                {
                    Exit();
                }
            }

            if (actionScene.Enabled || helpScene.Enabled || aboutScene.Enabled || howToPlayScene.Enabled || creditScene.Enabled || highScoreScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    hideAllScenes();
                    startScene.show();
                    gameStateActive = false;
                    MediaPlayer.Stop();
                }
            }

            // TODO: Add your update logic here

            base.Update(gameTime);
        }