/// <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)
        {
            var keyState = Keyboard.GetState();

            if (State == "playing")
            {
                // Restart
                if (keyState.IsKeyDown(Keys.R))
                {
                    LoadLevel(LevelName, CurrentLevelIndex);
                }

                float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
                Multiverse.Update(dt);

                if (Multiverse.HasWon && keyState.IsKeyDown(Keys.N) && HasNextLevel())
                {
                    LoadLevel(LevelNames[CurrentLevelIndex + 1], CurrentLevelIndex + 1);
                }
            }

            if (keyState.IsKeyDown(Keys.Escape))
            {
                if (InitialLevelName == null)
                {
                    SetState("levelselection");
                }
                else
                {
                    Exit();
                }
            }

            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)
        {
            var keyState = Keyboard.GetState();

            if (keyState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Restart
            if (keyState.IsKeyDown(Keys.R))
            {
                LoadLevel(LevelName);
            }

            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Multiverse.Update(dt);

            base.Update(gameTime);
        }