Пример #1
0
        public override bool[,] PossibleMoviment()
        {
            bool[,] mat = new bool[Board.Lines, Board.Columns];

            Position pos = new Position(0, 0);

            //N
            pos.SetValues(Position.Line - 1, Position.Column);
            while (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Line = pos.Line - 1;
            }

            //S
            pos.SetValues(Position.Line + 1, Position.Column);
            while (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Line = pos.Line + 1;
            }

            //R
            pos.SetValues(Position.Line, Position.Column + 1);
            while (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Column = pos.Column + 1;
            }

            //L
            pos.SetValues(Position.Line, Position.Column - 1);
            while (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (Board.Piece(pos) != null && Board.Piece(pos).Color != Color)
                {
                    break;
                }
                pos.Column = pos.Column - 1;
            }

            return(mat);
        }
Пример #2
0
        public override bool[,] PossibleMoviment()
        {
            bool[,] mat = new bool[Board.Lines, Board.Columns];

            Position pos = new Position(0, 0);

            // N
            pos.SetValues(Position.Line - 1, Position.Column);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // NE
            pos.SetValues(Position.Line - 1, Position.Column + 1);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // R
            pos.SetValues(Position.Line, Position.Column + 1);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // SE
            pos.SetValues(Position.Line + 1, Position.Column + 1);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // S
            pos.SetValues(Position.Line + 1, Position.Column);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // SW
            pos.SetValues(Position.Line + 1, Position.Column - 1);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // L
            pos.SetValues(Position.Line, Position.Column - 1);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // NW
            pos.SetValues(Position.Line - 1, Position.Column - 1);
            if (Board.RightPosition(pos) && CanMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            return(mat);
        }