private bool CheckWinVertical(CellStateCondition playerMove, CellStateCondition[,] GameField) { int slipHorizontal = 0; int countForVerticalCheck = 0; while (slipHorizontal < GAME_HEIGTH_FIELD) { for (int i = 0; i < GAME_HEIGTH_FIELD; i++) { if (GameField[i, slipHorizontal] == playerMove) { countForVerticalCheck++; } } if ((countForVerticalCheck == GAME_HEIGTH_FIELD) || (CheckFieldHaveEmptyCells() == false)) { return(true); } else { slipHorizontal++; countForVerticalCheck = 0; } } return(false); }
public bool CheckWinOrNotEnded(CellStateCondition playerMove, CellStateCondition[,] GameField) { if (CheckWinVertical(playerMove, GameField) || CheckWinHorizontal(playerMove, GameField) || CheckWinFirstDiagonal(playerMove, GameField) || CheckWinSecondDiagonal(playerMove, GameField)) { return(true); } return(false); }
private bool CheckWinSecondDiagonal(CellStateCondition playerMove, CellStateCondition[,] GameField) { int countSecondDiagonal = 0; for (int i = 0; i < GAME_HEIGTH_FIELD; i++) { if (GameField[i, GAME_WIDTH_FIELD - 1 - i] == playerMove) { countSecondDiagonal++; } } if ((countSecondDiagonal == GAME_HEIGTH_FIELD) || (CheckFieldHaveEmptyCells() == false)) { return(true); } return(false); }
private bool CheckWinFirstDiagonal(CellStateCondition playerMove, CellStateCondition[,] GameField) { int countFirstDiagonal = 0; for (int i = 0; i < GAME_WIDTH_FIELD; i++) { for (int j = 0; j < GAME_WIDTH_FIELD; j++) { if ((i == j) && (GameField[i, j] == playerMove)) { countFirstDiagonal++; } } } if ((countFirstDiagonal == GAME_HEIGTH_FIELD) || (CheckFieldHaveEmptyCells() == false)) { return(true); } return(false); }