/// <summary> /// Check if there are lines to be cleared on the board. /// Return the number of lines cleared. /// </summary> private int CheckLineClears(IEnumerable <int> rows) { // Sort the rows so things don't get messed up when we start clearing them. SortedSet <int> fullRows = new SortedSet <int>(Comparer <int> .Create( (i1, i2) => i2.CompareTo(i1) )); int clearCount = 0; foreach (int row in rows) { if (Board.LineIsFull(row)) { if (Board.FrozenTetromino != null) { foreach (Vector2Int relativeMino in Board.FrozenTetromino.MinoTiles) { Vector2Int absMino = Board.FrozenTetromino.Position + relativeMino; if (absMino.y == row) { Tetromino oldFrozen = Board.FrozenTetromino; Board.FrozenTetromino = null; Board.AddTetromino(oldFrozen); break; } } } fullRows.Add(row); } } foreach (int row in fullRows) { clearCount++; Board.ClearRow(row); } return(clearCount); }