Exemplo n.º 1
0
        public override void Move()
        {
            if (!(SW.ElapsedMilliseconds > Speed))
            {
                return;
            }

            PreviousCoordinates = Utilities.SystemObjectManipulation.DeepClone(Coordinates);

            if ((Direction & Direction.Up) == Direction.Up)
            {
                Coordinates.Row--;
            }

            else if ((Direction & Direction.Down) == Direction.Down)
            {
                Coordinates.Row++;
            }

            if ((Direction & Direction.Left) == Direction.Left)
            {
                Coordinates.Column--;
            }

            else if ((Direction & Direction.Right) == Direction.Right)
            {
                Coordinates.Column++;
            }

            base.Move();

            SW.Restart();
        }
Exemplo n.º 2
0
        public override void Move()
        {
            if (!(SW.ElapsedMilliseconds > Speed))
            {
                return;
            }

            PreviousCoordinates = Utilities.SystemObjectManipulation.DeepClone(Coordinates);

            DeltaX = Player.Coordinates.Column - Coordinates.Column;
            DeltaY = Player.Coordinates.Row - Coordinates.Row;
            int absDeltaX = Math.Abs(DeltaX);
            int absDeltaY = Math.Abs(DeltaY);

            void moveX()
            {
                if (DeltaX > 0)
                {
                    Coordinates.Column++;
                }

                else
                {
                    Coordinates.Column--;
                }
            }

            void moveY()
            {
                if (DeltaY > 0)
                {
                    Coordinates.Row++;
                }

                else
                {
                    Coordinates.Row--;
                }
            }

            if (absDeltaX == absDeltaY)
            {
                moveX();
                moveY();
            }

            else if (absDeltaX > absDeltaY)
            {
                moveX();
            }

            else
            {
                moveY();
            }

            base.Move();

            SW.Restart();
        }
Exemplo n.º 3
0
        public override void Move()
        {
            if (!(SW.ElapsedMilliseconds > Speed))
            {
                return;
            }

            PreviousCoordinates = Utilities.SystemObjectManipulation.DeepClone(Coordinates);
            Direction direction = Direction.None;

            if (Keyboard.IsKeyDown(Key.Up))
            {
                Coordinates.Row--;
                direction = Direction.Up;
            }

            else if (Keyboard.IsKeyDown(Key.Down))
            {
                Coordinates.Row++;
                direction = Direction.Down;
            }

            if (Keyboard.IsKeyDown(Key.Left))
            {
                Coordinates.Column--;
                direction = direction | Direction.Left;
            }

            else if (Keyboard.IsKeyDown(Key.Right))
            {
                Coordinates.Column++;
                direction = direction | Direction.Right;
            }

            if (Keyboard.IsKeyDown(Key.Space))
            {
                //Bullet bullet = new Bullet(this, 25, direction, Game, new Style("*", 1, 1));
                Bullet bullet1 = new Bullet(this, 12, Direction.Up, Game, new Style("*", 1, 1));
                Bullet bullet2 = new Bullet(this, 12, Direction.Down, Game, new Style("*", 1, 1));
                Bullet bullet3 = new Bullet(this, 12, Direction.Left, Game, new Style("*", 1, 1));
                Bullet bullet4 = new Bullet(this, 12, Direction.Right, Game, new Style("*", 1, 1));
                Bullet bullet5 = new Bullet(this, 12, Direction.Up | Direction.Left, Game, new Style("*", 1, 1));
                Bullet bullet6 = new Bullet(this, 12, Direction.Up | Direction.Right, Game, new Style("*", 1, 1));
                Bullet bullet7 = new Bullet(this, 12, Direction.Down | Direction.Left, Game, new Style("*", 1, 1));
                Bullet bullet8 = new Bullet(this, 12, Direction.Down | Direction.Right, Game, new Style("*", 1, 1));
            }

            base.Move();

            SW.Restart();
        }