public void CheckBlock() { if (FallingBlock != null) { dynamic overlapBlock = false; for (var row = 0; row <= 3; row++) { for (var column = 0; column <= 3; column++) { if (FallingBlock.FilledCell(column, row)) { var pt = BlockToBoard(new CellPoint(row, column)); if (Cells[pt.ToString()].Fixed) { overlapBlock = true; break; } } } if (overlapBlock) { break; } } if (overlapBlock) { GameOver?.Invoke(this, new EventArgs()); } else { dynamic fixBlock = false; for (var column = 0; column <= 3; column++) { for (var row = 3; row >= 0; row += -1) { if (FallingBlock.FilledCell(column, row)) { var pt = BlockToBoard(new CellPoint(row, column)); if (pt.Row.Equals(Rows - 1) || Cells[new CellPoint(pt.Row + 1, pt.Column).ToString()].Fixed) { fixBlock = true; } break; } } if (fixBlock) { break; } } if (fixBlock) { for (var row = 0; row <= 3; row++) { for (var column = 0; column <= 3; column++) { if (FallingBlock.FilledCell(column, row)) { var pt = BlockToBoard(new CellPoint(row, column)); Cells[pt.ToString()].Fixed = true; Cells[pt.ToString()].Color = FallingBlock.Color; } } } FallingBlock = null; CheckFullRows(); } } } }