Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            // background music
            startMusic      = Content.Load <Song>("Sounds/StartMusic");
            backgroundMusic = Content.Load <Song>("Sounds/BackgroundMusic");
            click           = Content.Load <SoundEffect>("Sounds/Click");

            // Instantiate all scenes
            startScene = new StartScene(this, spriteBatch, startMusic, click);
            this.Components.Add(startScene);

            playScene = new PlayScene(this, spriteBatch, backgroundMusic);
            this.Components.Add(playScene);

            helpScene = new HelpScene(this, spriteBatch);
            this.Components.Add(helpScene);

            highScoreScene = new HighScoreScene(this, spriteBatch);
            this.Components.Add(highScoreScene);

            aboutScene = new AboutScene(this, spriteBatch);
            this.Components.Add(aboutScene);

            // Show only startScene and play start music
            startScene.Show();
            SwitchMusic(startMusic);
        }
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)
        {
            // TODO: Add your update logic here

            int selectedIndex = 0;

            ks = Keyboard.GetState();

            if (startScene.Enabled)
            {
                selectedIndex = startScene.Menu.SelectedIndex; //* StartScene.cs > MenuComponent > SelectedIndex
                if (ks.IsKeyDown(Keys.Enter))
                {
                    HideAllScenes();
                    switch (selectedIndex)
                    {
                    case 0:
                        levelScene.Show();
                        break;

                    case 1:
                        helpScene.Show();
                        break;

                    case 2:
                        highScoreScene.Show();
                        break;

                    case 3:
                        aboutScene.Show();
                        break;

                    case 4:
                        this.Exit();
                        break;

                    default:
                        //* ERROR CATCH
                        break;
                    }
                }
            }
            else if (levelScene.Enabled && oldState.IsKeyUp(Keys.Enter))
            {
                selectedIndex = levelScene.Menu.SelectedIndex;
                if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter))
                {
                    HideAllScenes();
                    playScene1.Show();
                    SwitchMusic(backgroundMusic);
                }
                if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter))
                {
                    HideAllScenes();
                    playScene2.Show();
                    SwitchMusic(backgroundMusic);
                }
            }

            if (levelScene.Enabled || playScene1.Enabled || playScene2.Enabled ||
                helpScene.Enabled || highScoreScene.Enabled || aboutScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    HideAllScenes();
                    startScene.Show();
                    LoadContent();
                    SwitchMusic(startMusic);
                    //ScoreManager.Compare(Shared.scoreArr[5], Shared.playerArr[5]);
                }
            }

            oldState = ks;
            base.Update(gameTime);
        }
Ejemplo n.º 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)
        {
            // TODO: Add your update logic here

            int           selectedIndex = 0;
            KeyboardState ks            = Keyboard.GetState();

            if (startScene.Enabled)
            {
                selectedIndex = startScene.Menu.SelectedIndex; //* StartScene.cs > MenuComponent > SelectedIndex
                if (ks.IsKeyDown(Keys.Enter))
                {
                    HideAllScenes();
                    // sound effect when selecting menu
                    click.Play();
                    switch (selectedIndex)
                    {
                    case 0:
                        playScene.Show();
                        SwitchMusic(backgroundMusic);
                        break;

                    case 1:
                        helpScene.Show();
                        break;

                    case 2:
                        highScoreScene.Show();
                        break;

                    case 3:
                        aboutScene.Show();
                        break;

                    case 4:
                        this.Exit();
                        break;

                    default:
                        //* ERROR CATCH
                        break;
                    }
                }
                //* changed this if block to switch
                //if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter))
                //{
                //    HideAllScenes();
                //    playScene.Show();
                //}
                //if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter))
                //{
                //    HideAllScenes();
                //    helpScene.Show();
                //}
                //if (selectedIndex == 4 && ks.IsKeyDown(Keys.Enter)) // QUIT
                //{
                //    this.Exit();
                //}
            }

            if (playScene.Enabled || helpScene.Enabled || highScoreScene.Enabled || aboutScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    HideAllScenes();
                    startScene.Show();
                    SwitchMusic(startMusic);
                }
            }

            base.Update(gameTime);
        }