Ejemplo n.º 1
0
 public void ReloadLevel(string levelName, int score)
 {
     hideAllScenes();
     mainScene.hide();
     mainScene.Dispose();
     Components.Remove(mainScene);
     mainScene = new JumperMain(this, spriteBatch, _graphics, levelName, score);
     this.Components.Add(mainScene);
     mainScene.show();
 }
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)
        {
            /* if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
             *   Exit();*/

            // TODO: Add your update logic here

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

            if (menuScene.Enabled)
            {
                selectedIndex = menuScene.Menu.SelectedIndex;
                if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    //startScene.hide();
                    mainScene.show();
                }

                if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    //startScene.hide();
                    helpScene.show();
                }

                if (selectedIndex == 3 && ks.IsKeyDown(Keys.Enter))
                {
                    hideAllScenes();
                    //startScene.hide();
                    aboutScene.show();
                }

                //other scenes

                if (selectedIndex == 4 && ks.IsKeyDown(Keys.Enter))
                {
                    this.Exit();
                }
            }
            if (helpScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    helpScene.hide();
                    menuScene.show();
                }
            }

            if (aboutScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    aboutScene.hide();
                    menuScene.show();
                }
            }

            if (mainScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    BackToMenu();
                }
            }


            base.Update(gameTime);
        }