private void flipSurroundedOpponentPieces(int i_BoardRow, int i_BoardColumn, Direction.eVertical i_VerticalDirection, Direction.eHorizontal i_HorizontalDirection) { int nextRow = i_BoardRow + (int)i_VerticalDirection; int nextColumn = i_BoardColumn + (int)i_HorizontalDirection; Player.ePlayerNumber opponentPlayerNumber = m_CurrentGameState.CurrentPlayer.getOpponentPlayer(); // Check if move is valid in this direction int opponentPiecesSurroundedInDirection = getMoveValueInDirection(i_BoardRow, i_BoardColumn, i_VerticalDirection, i_HorizontalDirection); if (opponentPiecesSurroundedInDirection > 0) { while (m_CurrentGameState.GameBoard[nextRow, nextColumn].OccupyingPlayer == opponentPlayerNumber) { m_CurrentGameState.GameBoard.FlipCell(nextRow, nextColumn); nextRow = nextRow + (int)i_VerticalDirection; nextColumn = nextColumn + (int)i_HorizontalDirection; } } }
private GraphicBoardCell.eBoardCellType getBoardCellTypeFromOccupyingPlayer(Player.ePlayerNumber i_OccupyingPlayer) { GraphicBoardCell.eBoardCellType cellType = GraphicBoardCell.eBoardCellType.Empty; switch (i_OccupyingPlayer) { case Player.ePlayerNumber.None: cellType = GraphicBoardCell.eBoardCellType.Empty; break; case Player.ePlayerNumber.Player1: cellType = GraphicBoardCell.eBoardCellType.BlackPlayer; break; case Player.ePlayerNumber.Player2: cellType = GraphicBoardCell.eBoardCellType.WhitePlayer; break; } return(cellType); }
private int countSequenceOfEatableOpponentPieces(int i_BoardRow, int i_BoardColumn, Direction.eVertical i_VerticalDirection, Direction.eHorizontal i_HorizontalDirection) { int numberOfEatenOpponentPieces = 0; int nextRow = i_BoardRow; int nextColumn = i_BoardColumn; Player.ePlayerNumber opponentPlayer = m_CurrentGameState.CurrentPlayer.getOpponentPlayer(); while (isLocationInBoardRange(nextRow, nextColumn) && opponentPlayer == m_CurrentGameState.GameBoard[nextRow, nextColumn].OccupyingPlayer) { numberOfEatenOpponentPieces++; nextRow = nextRow + (int)i_VerticalDirection; nextColumn = nextColumn + (int)i_HorizontalDirection; } if (!isLocationInBoardRange(nextRow, nextColumn) || m_CurrentGameState.GameBoard[nextRow, nextColumn].OccupyingPlayer == Player.ePlayerNumber.None) { numberOfEatenOpponentPieces = 0; } return(numberOfEatenOpponentPieces); }
public BoardCell(BoardCell i_Other) { this.r_Row = i_Other.r_Row; this.r_Column = i_Other.r_Column; this.m_OccupyingPlayer = i_Other.m_OccupyingPlayer; }
public BoardCell(int i_Row, int i_Column, Player.ePlayerNumber i_OccupyingPlayer = Player.ePlayerNumber.None) { r_Row = i_Row; r_Column = i_Column; m_OccupyingPlayer = i_OccupyingPlayer; }