示例#1
0
        private bool ProcessKeyboardRunning(SadConsole.Input.Keyboard 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);
        }
        public override void ProcessKeyboard(SadConsole.Console consoleObject, SadConsole.Input.Keyboard info, out bool handled)
        {
            // Upcast this because we know we're only using it with a Console type.
            var console = (ScrollingConsole)consoleObject;

            if (info.IsKeyDown(Keys.Left))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left - 1, console.ViewPort.Top, _originalWidth, _originalHeight);
            }

            if (info.IsKeyDown(Keys.Right))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left + 1, console.ViewPort.Top, _originalWidth, _originalHeight);
            }

            if (info.IsKeyDown(Keys.Up))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left, console.ViewPort.Top - 1, _originalWidth, _originalHeight);
            }

            if (info.IsKeyDown(Keys.Down))
            {
                console.ViewPort = new Rectangle(console.ViewPort.Left, console.ViewPort.Top + 1, _originalWidth, _originalHeight);
            }

            handled = true;
        }
示例#3
0
        public override bool ProcessKeyboard(SadConsole.Input.Keyboard info)
        {
            if (info.IsKeyDown(Keys.Left))
            {
                ViewPort = new Rectangle(ViewPort.Left - 1, ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Right))
            {
                ViewPort = new Rectangle(ViewPort.Left + 1, ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Up))
            {
                ViewPort = new Rectangle(ViewPort.Left, ViewPort.Top - 1, 80, 23);
            }

            if (info.IsKeyDown(Keys.Down))
            {
                ViewPort = new Rectangle(ViewPort.Left, ViewPort.Top + 1, 80, 23);
            }

            if (info.IsKeyReleased(Keys.Space))
            {
                NextAnsi();
                LoadAnsi();
            }

            if (info.IsKeyReleased(Keys.L))
            {
                if (writer == null || lineCounter == lines.Length)
                {
                    NextAnsi();
                    lineCounter = 0;
                    Clear();
                    lines  = doc.AnsiString.Split('\n');
                    writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                }

                writer.AnsiReadLine(lines[lineCounter], true);

                lineCounter++;

                if (lineCounter > lines.Length)
                {
                    writer = null;
                }
            }

            return(true);
        }
示例#4
0
        private void ProcessMovement(Keyboard info)
        {
            if (info.IsKeyDown(Keys.Up))
            {
                Player.Transform.Direction = Direction.Up;
                Player.IsMoving            = true;
            }
            if (info.IsKeyDown(Keys.Right))
            {
                Player.Transform.Direction = Direction.Right;
                Player.IsMoving            = true;
            }
            if (info.IsKeyDown(Keys.Left))
            {
                Player.Transform.Direction = Direction.Left;
                Player.IsMoving            = true;
            }
            if (info.IsKeyDown(Keys.Down))
            {
                Player.Transform.Direction = Direction.Down;
                Player.IsMoving            = true;
            }

            if (info.IsKeyReleased(Keys.Up) && Player.Transform.Direction == Direction.Up)
            {
                Player.IsMoving = false;
            }
            if (info.IsKeyReleased(Keys.Left) && Player.Transform.Direction == Direction.Left)
            {
                Player.IsMoving = false;
            }
            if (info.IsKeyReleased(Keys.Right) && Player.Transform.Direction == Direction.Right)
            {
                Player.IsMoving = false;
            }
            if (info.IsKeyReleased(Keys.Down) && Player.Transform.Direction == Direction.Down)
            {
                Player.IsMoving = false;
            }

            if (info.IsKeyUp(Keys.Up) && info.IsKeyUp(Keys.Left) && info.IsKeyUp(Keys.Right) && info.IsKeyUp(Keys.Down))
            {
                Player.IsMoving = false;
            }
        }
示例#5
0
 private void ProcessAttack(Keyboard info)
 {
     if (info.IsKeyDown(Keys.Space))
     {
         Player.IsAttacking = true;
     }
     else
     {
         Player.IsAttacking = false;
     }
 }
示例#6
0
        public bool ProcessKeyboard(SadConsole.Input.Keyboard 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);
        }
        public override void ProcessKeyboard(Console console, Keyboard info, out bool handled)
        {
            game.Keys.ForwardPressed  = info.IsKeyDown(Keys.W);
            game.Keys.BackwardPressed = info.IsKeyDown(Keys.S);

            game.Keys.LeftPressed  = info.IsKeyDown(Keys.A);
            game.Keys.RightPressed = info.IsKeyDown(Keys.D);

            game.Keys.StrafeLeftPressed  = info.IsKeyDown(Keys.Q);
            game.Keys.StrafeRightPressed = info.IsKeyDown(Keys.E);

            if (info.IsKeyDown(Keys.Space))
            {
                console.Print(1, 1, "SPACE");
            }
            handled = true;
        }
示例#8
0
        public bool ProcessKeyboard(SadConsole.Input.Keyboard 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);
        }