private void PickNewCell(int row, int col) { int step = Map[row, col].ToString().EndsWith("_K") ? 8 : 2; for (int stepRow = -step; stepRow < step + 1; stepRow++) { for (int stepCol = -step; stepCol < step + 1; stepCol++) { if (stepRow == 0 || stepCol == 0 || Math.Abs(Math.Abs(stepCol) - Math.Abs(stepRow)) != 0) { continue; } if (InRange(row + stepRow, col + stepCol)) { if (Map[row + stepRow, col + stepCol] == CellType._EMPTY) { if ((stepRow > 0 && Map[row, col].ToString()[0] == 'B') || (stepRow < 0 && Map[row, col].ToString()[0] == 'R') || Map[row, col].ToString().EndsWith("_K") || CanHitBack(row, col)) { Map[row + stepRow, col + stepCol] = CellType._AVAILABLE; picked = new PickedCell { Row = row, Col = col, Type = Map[row, col] }; prev = Map[row, col]; curr = Map[row, col]; } } } } } for (row = 0; row < 8; row++) { for (col = 0; col < 8; col++) { if (Map[row, col] == CellType._AVAILABLE) { if (picked.Type.ToString().EndsWith("_K")) { if (!ClearPath(picked.Row, picked.Col, row, col)) { Map[row, col] = CellType._EMPTY; } } else { if (!Beside(picked.Row, picked.Col, row, col) && !ViaEnemy(picked.Row, picked.Col, row, col)) { Map[row, col] = CellType._EMPTY; } } } } } }
private void TryPickAgain(int row, int col) { CheckDirection(row, col, -1, -1); CheckDirection(row, col, -1, 1); CheckDirection(row, col, 1, -1); CheckDirection(row, col, 1, 1); if (MapList.Any(c => c == CellType._AVAILABLE)) { picked = new PickedCell { Row = row, Col = col, Type = Map[row, col] }; prev = Map[row, col]; curr = Map[row, col]; canPickAnother = false; ChangeOnFront?.Invoke(); } else { canPickAnother = true; } }