コード例 #1
0
        public override bool[,] movimetsPosible()
        {
            bool[,] array = new bool[Boar.Lines, Boar.Columns];
            Position pos = new Position(0, 0);


            //NorthEast
            pos.defineValue(Position.Line - 1, Position.Column + 1);
            while (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
                if (Boar.piece(pos) != null && Boar.piece(pos).Color != Color)
                {
                    break;
                }
                pos.Line   -= 1;
                pos.Column += 1;
            }

            //NorthWest
            pos.defineValue(Position.Line - 1, Position.Column - 1);
            while (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
                if (Boar.piece(pos) != null && Boar.piece(pos).Color != Color)
                {
                    break;
                }
                pos.Line   -= 1;
                pos.Column -= 1;
            }

            //SouthWest
            pos.defineValue(Position.Line + 1, Position.Column - 1);
            while (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
                if (Boar.piece(pos) != null && Boar.piece(pos).Color != Color)
                {
                    break;
                }
                pos.Line   += 1;
                pos.Column -= 1;
            }

            //SouthEast
            pos.defineValue(Position.Line + 1, Position.Column + 1);
            while (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
                if (Boar.piece(pos) != null && Boar.piece(pos).Color != Color)
                {
                    break;
                }
                pos.Line   += 1;
                pos.Column += 1;
            }

            return(array);
        }
コード例 #2
0
        public override bool[,] movimetsPosible()
        {
            bool[,] arrayGeneral = new bool[Boar.Lines, Boar.Columns];
            Position pos = new Position(0, 0);


            //up
            pos.defineValue(Position.Line - 2, Position.Column - 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //up
            pos.defineValue(Position.Line - 2, Position.Column + 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //Down
            pos.defineValue(Position.Line + 2, Position.Column + 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //Down
            pos.defineValue(Position.Line + 2, Position.Column - 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //Rith
            pos.defineValue(Position.Line + 1, Position.Column + 2);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //Rith
            pos.defineValue(Position.Line - 1, Position.Column + 2);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //Left
            pos.defineValue(Position.Line - 1, Position.Column - 2);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            //Left
            pos.defineValue(Position.Line + 1, Position.Column - 2);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                arrayGeneral[pos.Line, pos.Column] = true;
            }
            return(arrayGeneral);
        }
コード例 #3
0
ファイル: Pawn.cs プロジェクト: EmanuelDorigon/Xadrez-Game_2
        public override bool[,] movimetsPosible()
        {
            bool[,] array = new bool[Boar.Lines, Boar.Columns];
            Position pos = new Position(0, 0);

            if (Color == Color.White)
            {
                pos.defineValue(Position.Line - 2, Position.Column);
                if (Boar.positionValid(pos) && MovimentQuantity == 0)
                {
                    array[pos.Line, pos.Column] = true;
                }
                //up
                pos.defineValue(Position.Line - 1, Position.Column);
                if (Boar.positionValid(pos) && free(pos))
                {
                    array[pos.Line, pos.Column] = true;
                }

                //northEast
                pos.defineValue(Position.Line - 1, Position.Column + 1);
                if (Boar.positionValid(pos) && existEnemy(pos))
                {
                    array[pos.Line, pos.Column] = true;
                }

                //northeWest
                pos.defineValue(Position.Line - 1, Position.Column - 1);
                if (Boar.positionValid(pos) && existEnemy(pos))
                {
                    array[pos.Line, pos.Column] = true;
                }
            }
            else
            {
                pos.defineValue(Position.Line + 2, Position.Column);
                if (Boar.positionValid(pos) && MovimentQuantity == 0)
                {
                    array[pos.Line, pos.Column] = true;
                }
                //up
                pos.defineValue(Position.Line + 1, Position.Column);
                if (Boar.positionValid(pos) && free(pos))
                {
                    array[pos.Line, pos.Column] = true;
                }

                //northEast
                pos.defineValue(Position.Line + 1, Position.Column - 1);
                if (Boar.positionValid(pos) && existEnemy(pos))
                {
                    array[pos.Line, pos.Column] = true;
                }

                //northeWest
                pos.defineValue(Position.Line + 1, Position.Column + 1);
                if (Boar.positionValid(pos) && existEnemy(pos))
                {
                    array[pos.Line, pos.Column] = true;
                }
            }
            return(array);
        }
コード例 #4
0
        public override bool[,] movimetsPosible()
        {
            bool[,] array = new bool[Boar.Lines, Boar.Columns];
            Position pos = new Position(0, 0);


            //up
            pos.defineValue(Position.Line - 1, Position.Column);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //right
            pos.defineValue(Position.Line, Position.Column + 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //left
            pos.defineValue(Position.Line, Position.Column - 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //down
            pos.defineValue(Position.Line + 1, Position.Column);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //northwestern
            pos.defineValue(Position.Line - 1, Position.Column + 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //southeast
            pos.defineValue(Position.Line + 1, Position.Column + 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //sout-west
            pos.defineValue(Position.Line + 1, Position.Column - 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            //northewest
            pos.defineValue(Position.Line - 1, Position.Column - 1);
            if (Boar.positionValid(pos) && canMoviment(pos))
            {
                array[pos.Line, pos.Column] = true;
            }

            // Jogada especial Roque
            if (MovimentQuantity == 0)
            {
                // jogada especial roque pequeno
                Position posT1 = new Position(Position.Line, Position.Column + 3);
                if (towerTesttoRoque(posT1))
                {
                    Position p1 = new Position(Position.Line, Position.Column + 1);
                    Position p2 = new Position(Position.Line, Position.Column + 2);
                    if (Boar.piece(p1) == null && Boar.piece(p2) == null)
                    {
                        array[Position.Line, Position.Column + 2] = true;
                    }
                }
            }

            // #Jogadaespecial Roque grande
            if (MovimentQuantity == 0)
            {
                // #jogadaespecial roque pequeno
                Position posT2 = new Position(Position.Line, Position.Column - 4);
                if (towerTesttoRoque(posT2))
                {
                    Position p1 = new Position(Position.Line, Position.Column - 1);
                    Position p2 = new Position(Position.Line, Position.Column - 2);
                    Position p3 = new Position(Position.Line, Position.Column - 3);
                    if (Boar.piece(p1) == null && Boar.piece(p2) == null && Boar.piece(p3) == null)
                    {
                        array[Position.Line, Position.Column - 2] = true;
                    }
                }
            }

            return(array);
        }