Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }