Exemple #1
0
        private bool ProcessKeyboardRunning(SadConsole.Input.KeyboardInfo info)
        {
            bool processedKeyboard = false;

            if (player.ProcessKeyboard(info))
            {
                processedKeyboard = true;
                if (info.IsKeyDown(Keys.Up))
                {
                    upKeyAnimation.Run();
                }
                else if (info.IsKeyDown(Keys.Down))
                {
                    downKeyAnimation.Run();
                }
                else if (info.IsKeyDown(Keys.Left))
                {
                    leftKeyAnimation.Run();
                }
                else if (info.IsKeyDown(Keys.Right))
                {
                    rightKeyAnimation.Run();
                }
            }

            return(processedKeyboard);
        }
Exemple #2
0
        public bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
        {
            // Process logic for moving the entity.
            bool keyHit = false;

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

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

            return(keyHit);
        }
Exemple #3
0
        public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info)
        {
            if (info == null)
            {
                return(false);
            }

            // 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);
        }