public static int[] TryCollectFullRows(this IGridManager gridManager) { var grid = gridManager.Grid; var dimensions = grid.Dimensions; var fullRows = gridManager.GetFullRows().ToArray(); foreach (var row in fullRows) { for (var x = 0; x < dimensions.x; x++) { Object.Destroy(gridManager.GetBlock(new Vector2Int(x, row))); for (var y = row; y >= 1; y--) { var currentRowCoordinate = new Vector2Int(x, y); var previousRowCoordinate = new Vector2Int(x, y - 1); var currentBlock = gridManager.GetBlock(previousRowCoordinate); gridManager.SetBlock(currentRowCoordinate, currentBlock); if (currentBlock != null) { currentBlock.transform.position = grid.GetWorldCoordinate(currentRowCoordinate); } gridManager.SetBlock(previousRowCoordinate, null); } } } return(fullRows); }