public override void Highlight_Legal_Moves(bool wannaVisuallyHighlight) { for (int sns = 0; sns < 8; ++sns) { Point temp = new Point(onBoardLocation.X + KnightPossibleSensesToMove[sns].X, onBoardLocation.Y + KnightPossibleSensesToMove[sns].Y); if (nonAbstract_Pieces.WithinBounds(temp.X, temp.Y) && Global.chessBoard[temp.Y, temp.X].pieceColor != Global.chessBoard[onBoardLocation.Y, onBoardLocation.X].pieceColor) { if (wannaVisuallyHighlight) { Draw_Highlight_Square(Global.HighLight_Color, temp); } else { Global.CoveredArea[Convert.ToInt32(getPieceColor), temp.Y, temp.X]++; this.AllPossibleMoves.Add(new Point(temp.X, temp.Y)); if (Global.AllPieces[temp.Y, temp.X] is King) { //MessageBox.Show("Knight"); Player.WhoAttacksTheKing WATK = new Player.WhoAttacksTheKing(); WATK.piece = Global.AllPieces[onBoardLocation.Y, onBoardLocation.X]; WATK.sense = KnightPossibleSensesToMove[sns]; Player.PiecesAttackingTheKing.Add(WATK); } } } } }
public void DFS(int sns, bool wannaVisuallyHighlight) { int currX = onBoardLocation.X + QueenPossibleSensesToMove[sns].X; int currY = onBoardLocation.Y + QueenPossibleSensesToMove[sns].Y; //Console.WriteLine("Nou DFS: " + currY + " " + currX); while (nonAbstract_Pieces.WithinBounds(currX, currY) && Global.chessBoard[currY, currX].pieceColor != Global.chessBoard[onBoardLocation.Y, onBoardLocation.X].pieceColor) { //Console.WriteLine("curr: " + currY + " " + currX); if (wannaVisuallyHighlight) { Draw_Highlight_Square(Global.HighLight_Color, new Point(currX, currY)); } else { Global.CoveredArea[Convert.ToInt32(getPieceColor), currY, currX]++; this.AllPossibleMoves.Add(new Point(currX, currY)); if (Global.AllPieces[currY, currX] is King) { //MessageBox.Show("Queen"); Player.WhoAttacksTheKing WATK = new Player.WhoAttacksTheKing(); WATK.piece = Global.AllPieces[onBoardLocation.Y, onBoardLocation.X]; WATK.sense = QueenPossibleSensesToMove[sns]; Player.PiecesAttackingTheKing.Add(WATK); } } if (wannaVisuallyHighlight && Global.chessBoard[currY, currX].pieceColor == 3 - Global.chessBoard[onBoardLocation.Y, onBoardLocation.X].pieceColor) { return; } if (!wannaVisuallyHighlight && Global.chessBoard[currY, currX].pieceType != Global.PIECE_TYPE.NULL && Global.chessBoard[currY, currX].pieceType != Global.PIECE_TYPE.KING) { return; } currX += QueenPossibleSensesToMove[sns].X; currY += QueenPossibleSensesToMove[sns].Y; } }