Exemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            keyboard.Update();

            if (keyboard.GetPressedKeys().Contains(Keys.Escape))
            {
                Exit();
            }

            activeScreen.Update(keyboard, gameTime.ElapsedGameTime);

            if (activeScreen.NextScreen)
            {
                activeScreen = CreateNextScreen();
                keyboard.Update(); // Fixes keyboard.lastState for Android where keyboard.Update() depends on active screen.
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
        public void Update(GameKeyboard keyboard, TimeSpan elapsedTime)
        {
            IReadOnlyCollection <Keys> pressedKeys     = keyboard.GetPressedKeys();
            IReadOnlyCollection <Keys> justPressedKeys = keyboard.GetJustPressedKeys();

            if (justPressedKeys.Contains(Keys.P))
            {
                paused = !paused;
            }
            if (paused)
            {
                return;
            }

            timer.Update(elapsedTime);

            switch (state)
            {
            case GameState.Running:
                UpdateRunning(pressedKeys, justPressedKeys);
                break;

            case GameState.RowClearing:
                UpdateRowClearing();
                break;

            case GameState.LevelUp:
                if (timer.TickCompleted)
                {
                    timer.RequestGameMessageTick();
                    state = GameState.RowClearing;
                }
                break;

            case GameState.GameOver:
                if (timer.TickCompleted)
                {
                    NextScreen = true;
                }
                break;
            }
        }