public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
        {
            // Forward the keyboard data to the entity to handle the movement code.
            // We could detect if the users hit ESC and popup a menu or something.
            // By not setting the entity as the active object, twe let this
            // "game level" (the console we're hosting the entity on) determine if
            // the keyboard data should be sent to the entity.

            // Process logic for moving the entity.
            bool keyHit = false;

            if (info.IsKeyReleased(Keys.Up))
            {
                player.Position = new Point(player.Position.X, player.Position.Y - 1);
                keyHit = true;
            }
            else if (info.IsKeyReleased(Keys.Down))
            {
                player.Position = new Point(player.Position.X, player.Position.Y + 1);
                keyHit = true;
            }

            if (info.IsKeyReleased(Keys.Left))
            {
                player.Position = new Point(player.Position.X - 1, player.Position.Y);
                keyHit = true;
            }
            else if (info.IsKeyReleased(Keys.Right))
            {
                player.Position = new Point(player.Position.X + 1, player.Position.Y);
                keyHit = true;
            }

            if (keyHit)
            {
                // Entity moved. Let's draw a trail of where they moved from.

                // We are not detecting when the player tries to move off the console area.
                // We could detected that though and then move the player back to where they were.
                SetGlyph(playerPreviousPosition.X, playerPreviousPosition.Y, 250);
                playerPreviousPosition = player.Position;

                return true;
            }

            // You could have multiple entities in the game for example, and change
            // which entity gets keyboard commands.
            return false;
        }
Exemple #2
0
 public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
 {
     if(info.IsKeyReleased(Keys.P))
     {
         if (PlayGame != null)
         {
             PlayGame(this, new EventArgs());
         }
         return true;
     }
     if (info.IsKeyReleased(Keys.I))
     {
         PrintInstructions();
         return true;
     }
     return false;
 }
Exemple #3
0
        public bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
        {
            // Process logic for moving the entity.
            bool keyHit = false;

            if (info.IsKeyDown(Keys.Up))
            {
                this.CurrentDirection = Direction.Up;
                keyHit = true;
            }
            else if (info.IsKeyDown(Keys.Down))
            {
                this.CurrentDirection = Direction.Down;
                keyHit = true;
            }

            if (info.IsKeyDown(Keys.Left))
            {
                this.CurrentDirection = Direction.Left;
                keyHit = true;
            }
            else if (info.IsKeyDown(Keys.Right))
            {
                this.CurrentDirection = Direction.Right;
                keyHit = true;
            }

            switch(CurrentDirection)
            {
                case Direction.Up:
                    if(info.IsKeyReleased(Keys.Up))
                    {
                        this.CurrentDirection = Direction.None;
                        keyHit = true;
                    }
                    break;
                case Direction.Down:
                    if (info.IsKeyReleased(Keys.Down))
                    {
                        this.CurrentDirection = Direction.None;
                        keyHit = true;
                    }
                    break;
                case Direction.Left:
                    if (info.IsKeyReleased(Keys.Left))
                    {
                        this.CurrentDirection = Direction.None;
                        keyHit = true;
                    }
                    break;
                case Direction.Right:
                    if (info.IsKeyReleased(Keys.Right))
                    {
                        this.CurrentDirection = Direction.None;
                        keyHit = true;
                    }
                    break;
            }

            return keyHit;
        }
Exemple #4
0
 private bool ProcessKeyboardMenu(SadConsole.Input.KeyboardInfo info)
 {
     bool processedKeyboard = false;
     if (info.IsKeyReleased(Keys.Multiply))
     {
         astrickKeyAnimation.Run();
         ResetGame();
         processedKeyboard = true;
     }
     return processedKeyboard;
 }
            public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
            {
                // Process logic for moving the entity.
                bool keyHit = false;

                if (info.IsKeyReleased(Keys.Up))
                {
                    _position.Y -= 1;
                    keyHit = true;
                }
                else if (info.IsKeyReleased(Keys.Down))
                {
                    _position.Y += 1;
                    keyHit = true;
                }

                if (info.IsKeyReleased(Keys.Left))
                {
                    _position.X -= 1;
                    keyHit = true;
                }
                else if (info.IsKeyReleased(Keys.Right))
                {
                    _position.X += 1;
                    keyHit = true;
                }

                return keyHit;

            }
        public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
        {
            if(info.KeysReleased.Count > 0)
            {
                if (releaseCount > 0)
                {
                    releaseCount--;
                    return true;
                }
                if (playAgain == false)
                {
                    this.CellData.Print(8, 24, "PLAY AGAIN (Y/N)?     ", Color.White);
                    playAgain = true;
                    return true;
                }
                if(info.IsKeyReleased(Keys.Y))
                {
                    if (RestartGame != null)
                    {
                        RestartGame(this, new EventArgs());
                    }
                    return true;
                }

                if (info.IsKeyReleased(Keys.N))
                {
                    if (QuitGame != null)
                    {
                        QuitGame(this, new EventArgs());
                    }
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }