public ChessPiece(int x, int y, EnumChessPieceColor color, EnumChessPieceType type) { SetPosition(x, y); this.Color = color; this.Type = type; this.IsCaptured = false; }
public void changePlayerTurn() { if (playerTurn == EnumChessPieceColor.White) { playerTurn = EnumChessPieceColor.Black; } else { playerTurn = EnumChessPieceColor.White; } }
public BoardManager() { this.chessBoard = new IChessPiece[BOARD_SIZE, BOARD_SIZE]; this.chessPiecePrefab = new List <IChessPiece>(TOTAL_CHESS_PIECE_COUNT); InitializeChessPieces(); SpawnAllChessPieces(); playerTurn = EnumChessPieceColor.White; selectedChessPiece = null; checkMate = false; capturedChessPieces = new List <IChessPiece>(); }
public override bool[,] PossibleMove(IChessPiece[,] currentBoard) { int rookX = this.CurrentX; int rookY = this.CurrentY; bool[,] rookMoves = new bool[8, 8]; EnumChessPieceColor rookColor = this.Color; // Right. for (int movesY = rookY + 1; movesY >= 0 && movesY < 8; movesY++) { int movesX = rookX; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == rookColor) { rookMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != rookColor) { rookMoves[movesX, movesY] = true; break; } else { rookMoves[movesX, movesY] = true; } } // Bottom. for (int movesX = rookX - 1; movesX >= 0 && movesX < 8; movesX--) { int movesY = rookY; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == rookColor) { rookMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != rookColor) { rookMoves[movesX, movesY] = true; break; } else { rookMoves[movesX, movesY] = true; } } // Left. for (int movesY = rookY - 1; movesY >= 0 && movesY < 8; movesY--) { int movesX = rookX; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == rookColor) { rookMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != rookColor) { rookMoves[movesX, movesY] = true; break; } else { rookMoves[movesX, movesY] = true; } } // Top. for (int movesX = rookX + 1; movesX >= 0 && movesX < 8; movesX++) { int movesY = rookY; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == rookColor) { rookMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != rookColor) { rookMoves[movesX, movesY] = true; break; } else { rookMoves[movesX, movesY] = true; } } return(rookMoves); // Return bool rookMoves matrix. }
public Rook(int x, int y, EnumChessPieceColor color, EnumChessPieceType type) : base(x, y, color, type) { }
private void Selector(object sender, EventArgs e) { PictureBox control = (PictureBox)sender; string cordinates = control.Name; bool isSelected = false; int y = cordinates[0] - 'a'; int x = cordinates[1] - '1'; if (!Action) { isSelected = testBoard.SelectChessPiece(x, y); } PictureBox secondControl = (PictureBox)sender; if (isSelected) { control = (PictureBox)sender; } else { secondControl = (PictureBox)sender; } if (!Action) { if (isSelected) { Action = true; oldControl = (PictureBox)sender; oldColor = oldControl.BackColor; oldControl.BackColor = Color.Aqua; HightLight(); } } else { if (testBoard.isValidMove(x, y)) { testBoard.MoveChessPiece(x, y); EnumChessPieceColor turn = testBoard.GetPlayerTurn(); if (turn == EnumChessPieceColor.White) { WhitePlayerTurn.Checked = true; BlackPlayerTurn.Checked = false; } else { BlackPlayerTurn.Checked = true; WhitePlayerTurn.Checked = false; } Image newFigure = null; newFigure = oldControl.Image; testBoard.selectedChessPiece = null; oldControl.Image = null; oldControl.BackColor = oldColor; secondControl.Image = newFigure; Action = false; ReturnBoardToNormal(); } else { testBoard.selectedChessPiece = null; oldControl.BackColor = oldColor; Action = false; ReturnBoardToNormal(); } } }
public override bool[,] PossibleMove(IChessPiece[,] currentBoard) { int pawnX = this.CurrentX; int pawnY = this.CurrentY; bool[,] pawnMoves = new bool[8, 8]; EnumChessPieceColor pawnColor = this.Color; bool whitePawn = false; if (this.Color == EnumChessPieceColor.White) { whitePawn = true; } // WHITE PAWN LOGIC: // Top ^ Special move pawn - double forward move. int movesX = pawnX + 2; int movesY = pawnY; if (pawnX == 1 && whitePawn && movesX >= 0 && movesX < 8) { if (currentBoard[movesX, movesY] != null) { pawnMoves[movesX, movesY] = false; } else { pawnMoves[movesX, movesY] = true; } } // Top ^ if the pawn is white it can move upwards - no special exchange. movesX = pawnX + 1; movesY = pawnY; if (whitePawn && movesX >= 0 && movesX < 8) { if (currentBoard[movesX, movesY] != null) { pawnMoves[movesX, movesY] = false; } else { pawnMoves[movesX, movesY] = true; } } // Top Right diagonal. movesX = pawnX + 1; movesY = pawnY - 1; if (whitePawn && movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == pawnColor) { pawnMoves[movesX, movesY] = false; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != pawnColor) { pawnMoves[movesX, movesY] = true; } else { pawnMoves[movesX, movesY] = false; } } // Top Left diagonal. movesX = pawnX + 1; movesY = pawnY + 1; if (whitePawn && movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == pawnColor) { pawnMoves[movesX, movesY] = false; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != pawnColor) { pawnMoves[movesX, movesY] = true; } else { pawnMoves[movesX, movesY] = false; } } // BLACK PAWN LOGIC: // Bottom ^ Special move pawn - double forward move. movesX = pawnX - 2; if (pawnX == 6 && !whitePawn && movesX >= 0 && movesX < 8) { movesY = pawnY; if (currentBoard[movesX, movesY] != null) { pawnMoves[movesX, movesY] = false; } else { pawnMoves[movesX, movesY] = true; } } // Bottom ^ if the pawn is white it can move upwards - no special exchange. movesX = pawnX - 1; movesY = pawnY; if (!whitePawn && movesX >= 0 && movesX < 8) { if (currentBoard[movesX, movesY] != null) { pawnMoves[movesX, movesY] = false; } else { pawnMoves[movesX, movesY] = true; } } // Bottom Right diagonal. movesX = pawnX - 1; movesY = pawnY + 1; if (!whitePawn && movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == pawnColor) { pawnMoves[movesX, movesY] = false; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != pawnColor) { pawnMoves[movesX, movesY] = true; } else { pawnMoves[movesX, movesY] = false; } } // Bottom Left diagonal. movesX = pawnX - 1; movesY = pawnY - 1; if (!whitePawn && movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == pawnColor) { pawnMoves[movesX, movesY] = false; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != pawnColor) { pawnMoves[movesX, movesY] = true; } else { pawnMoves[movesX, movesY] = false; } } return(pawnMoves); }
public override bool[,] PossibleMove(IChessPiece[,] currentBoard) { int knightX = this.CurrentX; int knightY = this.CurrentY; bool[,] knightMoves = new bool[8, 8]; EnumChessPieceColor knightColor = this.Color; // 8 = top left. if (knightX + 2 < 8 && knightX + 2 >= 0 && knightY - 1 >= 0 && knightY - 1 < 8) { if (currentBoard[knightX + 2, knightY - 1] != null && currentBoard[knightX + 2, knightY - 1].Color == knightColor) { knightMoves[knightX + 2, knightY - 1] = false; } else if (currentBoard[knightX + 2, knightY - 1] != null && currentBoard[knightX + 2, knightY - 1].Color != knightColor) { knightMoves[knightX + 2, knightY - 1] = true; } else { knightMoves[knightX + 2, knightY - 1] = true; } } // 7 = left top. if (knightX + 1 < 8 && knightX + 1 >= 0 && knightY - 2 >= 0 && knightY - 2 < 8) { if (currentBoard[knightX + 1, knightY - 2] != null && currentBoard[knightX + 1, knightY - 2].Color == knightColor) { knightMoves[knightX + 1, knightY - 2] = false; } else if (currentBoard[knightX + 1, knightY - 2] != null && currentBoard[knightX + 1, knightY - 2].Color != knightColor) { knightMoves[knightX + 1, knightY - 2] = true; } else { knightMoves[knightX + 1, knightY - 2] = true; } } // 6 = left bottom. if (knightX - 1 < 8 && knightX - 1 >= 0 && knightY - 2 >= 0 && knightY - 2 < 8) { if (currentBoard[knightX - 1, knightY - 2] != null && currentBoard[knightX - 1, knightY - 2].Color == knightColor) { knightMoves[knightX - 1, knightY - 2] = false; } else if (currentBoard[knightX - 1, knightY - 2] != null && currentBoard[knightX - 1, knightY - 2].Color != knightColor) { knightMoves[knightX - 1, knightY - 2] = true; } else { knightMoves[knightX - 1, knightY - 2] = true; } } // 5 = bottom left. if (knightX - 2 < 8 && knightX - 2 >= 0 && knightY - 1 >= 0 && knightY - 1 < 8) { if (currentBoard[knightX - 2, knightY - 1] != null && currentBoard[knightX - 2, knightY - 1].Color == knightColor) { knightMoves[knightX - 2, knightY - 1] = false; } else if (currentBoard[knightX - 2, knightY - 1] != null && currentBoard[knightX - 2, knightY - 1].Color != knightColor) { knightMoves[knightX - 2, knightY - 1] = true; } else { knightMoves[knightX - 2, knightY - 1] = true; } } // 4 = bottom right. if (knightX - 2 < 8 && knightX - 2 >= 0 && knightY + 1 >= 0 && knightY + 1 < 8) { if (currentBoard[knightX - 2, knightY + 1] != null && currentBoard[knightX - 2, knightY + 1].Color == knightColor) { knightMoves[knightX - 2, knightY + 1] = false; } else if (currentBoard[knightX - 2, knightY + 1] != null && currentBoard[knightX - 2, knightY + 1].Color != knightColor) { knightMoves[knightX - 2, knightY + 1] = true; } else { knightMoves[knightX - 2, knightY + 1] = true; } } // 3 = right bottom. if (knightX - 1 < 8 && knightX - 1 >= 0 && knightY + 2 >= 0 && knightY + 2 < 8) { if (currentBoard[knightX - 1, knightY + 2] != null && currentBoard[knightX - 1, knightY + 2].Color == knightColor) { knightMoves[knightX - 1, knightY + 2] = false; } else if (currentBoard[knightX - 1, knightY + 2] != null && currentBoard[knightX - 1, knightY + 2].Color != knightColor) { knightMoves[knightX - 1, knightY + 2] = true; } else { knightMoves[knightX - 1, knightY + 2] = true; } } // 2 = right top. if (knightX + 1 < 8 && knightX + 1 >= 0 && knightY + 2 >= 0 && knightY + 2 < 8) { if (currentBoard[knightX + 1, knightY + 2] != null && currentBoard[knightX + 1, knightY + 2].Color == knightColor) { knightMoves[knightX + 1, knightY + 2] = false; } else if (currentBoard[knightX + 1, knightY + 2] != null && currentBoard[knightX + 1, knightY + 2].Color != knightColor) { knightMoves[knightX + 1, knightY + 2] = true; } else { knightMoves[knightX + 1, knightY + 2] = true; } } // 1 = top right. if (knightX + 2 < 8 && knightX + 2 >= 0 && knightY + 1 >= 0 && knightY + 1 < 8) { if (currentBoard[knightX + 2, knightY + 1] != null && currentBoard[knightX + 2, knightY + 1].Color == knightColor) { knightMoves[knightX + 2, knightY + 1] = false; } else if (currentBoard[knightX + 2, knightY + 1] != null && currentBoard[knightX + 2, knightY + 1].Color != knightColor) { knightMoves[knightX + 2, knightY + 1] = true; } else { knightMoves[knightX + 2, knightY + 1] = true; } } return(knightMoves); }
public King(int x, int y, EnumChessPieceColor color, EnumChessPieceType type) : base(x, y, color, type) { this.HasMoved = false; }
/// <summary> /// If King is checked possible moves will be calculated normaly. /// </summary> /// <param name="currentBoard"></param> /// <returns></returns> public override bool[,] PossibleMove(IChessPiece[,] currentBoard) { int kingX = this.CurrentX; int kingY = this.CurrentY; bool[,] kingMoves = new bool[8, 8]; EnumChessPieceColor kingColor = this.Color; // Top. if (kingX + 1 < 8) { if (currentBoard[kingX + 1, kingY] != null && currentBoard[kingX + 1, kingY].Color == kingColor) { kingMoves[kingX + 1, kingY] = false; } else if (currentBoard[kingX + 1, kingY] != null && currentBoard[kingX + 1, kingY].Color != kingColor) { kingMoves[kingX + 1, kingY] = true; } else { kingMoves[kingX + 1, kingY] = true; } } // Top left. if (kingX + 1 < 8 && kingY - 1 >= 0) { if (currentBoard[kingX + 1, kingY - 1] != null && currentBoard[kingX + 1, kingY - 1].Color == kingColor) { kingMoves[kingX + 1, kingY - 1] = false; } else if (currentBoard[kingX + 1, kingY - 1] != null && currentBoard[kingX + 1, kingY - 1].Color != kingColor) { kingMoves[kingX + 1, kingY - 1] = true; } else { kingMoves[kingX + 1, kingY - 1] = true; } } // Left. if (kingY - 1 >= 0) { if (currentBoard[kingX, kingY - 1] != null && currentBoard[kingX, kingY - 1].Color == kingColor) { kingMoves[kingX, kingY - 1] = false; } else if (currentBoard[kingX, kingY - 1] != null && currentBoard[kingX, kingY - 1].Color != kingColor) { kingMoves[kingX, kingY - 1] = true; } else { kingMoves[kingX, kingY - 1] = true; } } // Bottom left. if (kingX - 1 >= 0 && kingY - 1 >= 0) { if (currentBoard[kingX - 1, kingY - 1] != null && currentBoard[kingX - 1, kingY - 1].Color == kingColor) { kingMoves[kingX - 1, kingY - 1] = false; } else if (currentBoard[kingX - 1, kingY - 1] != null && currentBoard[kingX - 1, kingY - 1].Color != kingColor) { kingMoves[kingX - 1, kingY - 1] = true; } else { kingMoves[kingX - 1, kingY - 1] = true; } } // Bottom. if (kingX - 1 >= 0) { if (currentBoard[kingX - 1, kingY] != null && currentBoard[kingX - 1, kingY].Color == kingColor) { kingMoves[kingX - 1, kingY] = false; } else if (currentBoard[kingX - 1, kingY] != null && currentBoard[kingX - 1, kingY].Color != kingColor) { kingMoves[kingX - 1, kingY] = true; } else { kingMoves[kingX - 1, kingY] = true; } } // Bottom right. if (kingX - 1 >= 0 && kingY + 1 < 8) { if (currentBoard[kingX - 1, kingY + 1] != null && currentBoard[kingX - 1, kingY + 1].Color == kingColor) { kingMoves[kingX - 1, kingY + 1] = false; } else if (currentBoard[kingX - 1, kingY + 1] != null && currentBoard[kingX - 1, kingY + 1].Color != kingColor) { kingMoves[kingX - 1, kingY + 1] = true; } else { kingMoves[kingX - 1, kingY + 1] = true; } } // Right. if (kingY + 1 < 8) { if (currentBoard[kingX, kingY + 1] != null && currentBoard[kingX, kingY + 1].Color == kingColor) { kingMoves[kingX, kingY + 1] = false; } else if (currentBoard[kingX, kingY + 1] != null && currentBoard[kingX, kingY + 1].Color != kingColor) { kingMoves[kingX, kingY + 1] = true; } else { kingMoves[kingX, kingY + 1] = true; } } // Top right. if (kingX + 1 < 8 && kingY + 1 < 8) { if (currentBoard[kingX + 1, kingY + 1] != null && currentBoard[kingX + 1, kingY + 1].Color == kingColor) { kingMoves[kingX + 1, kingY + 1] = false; } else if (currentBoard[kingX + 1, kingY + 1] != null && currentBoard[kingX + 1, kingY + 1].Color != kingColor) { kingMoves[kingX + 1, kingY + 1] = true; } else { kingMoves[kingX + 1, kingY + 1] = true; } } return(kingMoves); }
/// <summary> /// The method Possible Moves takes "CurrentBoard" to see which squares are available and it applies logic to define /// the possible squares for moves as true of false. /// /// The logic /// /// Lets assume that bishop is white ( EnumColor BishopColor = this.Color; ). /// The Bishop can only move to its diagonals. The logic is the same for all four. /// Diagonal 1 up left diagonal - x increases and y increases /// we have 3 conditions : /// 1 - the space is taken by a figure with the same color - then this space is market as false, the cycle breaks and /// the logic starts checking the other 3 diagonals for possible moves. /// /// 2-the space is taken but the figure is from the oppossite color - then only an attack is possible, the space is marked /// as true and the cycle breaks. /// /// 3-the space is free, the cycle will continue to mark spots as free unless it meets condition 1 or 2. /// ///Bishop moves can be replicated elsewhere. /// </summary> /// <param name="currentBoard"></param> /// <returns> bool[,] bishopMoves </returns> public override bool[,] PossibleMove(IChessPiece[,] currentBoard) { int bishopX = this.CurrentX; int bishopY = this.CurrentY; bool[,] bishopMoves = new bool[8, 8]; EnumChessPieceColor BishopColor = this.Color; // bottom right diagonal for (int movesX = bishopX - 1, movesY = bishopY + 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX--, movesY++) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == BishopColor) { bishopMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != BishopColor) { bishopMoves[movesX, movesY] = true; break; } else { bishopMoves[movesX, movesY] = true; } } // top right for (int movesX = bishopX + 1, movesY = bishopY + 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX++, movesY++) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == BishopColor) { bishopMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != BishopColor) { bishopMoves[movesX, movesY] = true; break; } else { bishopMoves[movesX, movesY] = true; } } // Top Left for (int movesX = bishopX + 1, movesY = bishopY - 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX++, movesY--) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == BishopColor) { bishopMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != BishopColor) { bishopMoves[movesX, movesY] = true; break; } else { bishopMoves[movesX, movesY] = true; } } // bottom right for (int movesX = bishopX - 1, movesY = bishopY - 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX--, movesY--) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == BishopColor) { bishopMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != BishopColor) { bishopMoves[movesX, movesY] = true; break; } else { bishopMoves[movesX, movesY] = true; } } //return bool bishopMoves matrix return(bishopMoves); }
public override bool[,] PossibleMove(IChessPiece[,] currentBoard) { int queenX = this.CurrentX; int queenY = this.CurrentY; bool[,] queenMoves = new bool[8, 8]; EnumChessPieceColor queenColor = this.Color; // Bottom right diagonal. for (int movesX = queenX - 1, movesY = queenY + 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX--, movesY++) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Top right. for (int movesX = queenX + 1, movesY = queenY + 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX++, movesY++) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Top left. for (int movesX = queenX + 1, movesY = queenY - 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX++, movesY--) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Bottom right. for (int movesX = queenX - 1, movesY = queenY - 1; movesX < 8 && movesX >= 0 && movesY < 8 && movesY >= 0; movesX--, movesY--) { if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Right. for (int movesY = queenY + 1; movesY >= 0 && movesY < 8; movesY++) { int movesX = queenX; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Bottom. for (int movesX = queenX - 1; movesX >= 0 && movesX < 8; movesX--) { int movesY = queenY; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Left. for (int movesY = queenY - 1; movesY >= 0 && movesY < 8; movesY--) { int movesX = queenX; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } // Top. for (int movesX = queenX + 1; movesX >= 0 && movesX < 8; movesX++) { int movesY = queenY; if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color == queenColor) { queenMoves[movesX, movesY] = false; break; } else if (currentBoard[movesX, movesY] != null && currentBoard[movesX, movesY].Color != queenColor) { queenMoves[movesX, movesY] = true; break; } else { queenMoves[movesX, movesY] = true; } } return(queenMoves); }