Exemplo n.º 1
0
 public void Update(GameKeyboard keyboard, TimeSpan elapsedTime)
 {
     if (keyboard.GetJustPressedKeys().Any())
     {
         NextScreen = true;
     }
 }
Exemplo n.º 2
0
        public void Update(GameKeyboard keyboard, TimeSpan elapsedTime)
        {
            IReadOnlyCollection <Keys> justPressedKeys = keyboard.GetJustPressedKeys();

            if (justPressedKeys.Contains(Keys.Enter))
            {
                topScores.InsertTopScore(new string(letters), playedScore);
                NextScreen = true;
            }
            else if (justPressedKeys.Contains(Keys.Up))
            {
                letters[currentLetterIndex]--;
                if (letters[currentLetterIndex] < 'A')
                {
                    letters[currentLetterIndex] = 'Z';
                }
            }
            else if (justPressedKeys.Contains(Keys.Down))
            {
                letters[currentLetterIndex]++;
                if (letters[currentLetterIndex] > 'Z')
                {
                    letters[currentLetterIndex] = 'A';
                }
            }
            else if (justPressedKeys.Contains(Keys.Right))
            {
                currentLetterIndex++;
                if (currentLetterIndex >= letters.Length)
                {
                    currentLetterIndex = 0;
                }
            }
            else if (justPressedKeys.Contains(Keys.Left))
            {
                currentLetterIndex--;
                if (currentLetterIndex < 0)
                {
                    currentLetterIndex = letters.Length - 1;
                }
            }
        }
Exemplo n.º 3
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;
            }
        }