Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Method: Structure<CombinedCell<TCell>> CombineCells(params TCell[])

Declaration

public Structure<CombinedCell<TCell>> CombineCells(
    params TCell[] cells
)

Summary

Returns a new structure in which the specified set of cells is combined (merged) into a single cell.

Parameters

TCell[]cells Set of cells to combine into one.

Remarks

Note that the type of the structure changes from Structure<TCell> to Structure<CombinedCell<TCell>>. If you wish to combine multiple groups of cells, call this overload with zero parameters first just to change the type, then subsequently use GridUtils.CombineCells<TCell>(this Structure<CombinedCell<TCell>>, params TCell[]) to combine each group. The following example code illustrates this principle by creating a grid in which some horizontal or vertical pairs of cells are combined:

var grid = new Grid(12, 12).CombineCells();
foreach (var cell in grid.Cells.Select(cc => cc.First()))
    if ((cell.X % 4 == 0 && cell.Y % 4 < 2) || (cell.X % 4 == 2 && cell.Y % 4 > 1))
        grid = grid.CombineCells(new Coord[] { cell, cell.Move(GridDirection.Right) });
    else if ((cell.X % 4 > 1 && cell.Y % 4 == 0) || (cell.X % 4 < 2 && cell.Y % 4 == 2))
        grid = grid.CombineCells(new Coord[] { cell, cell.Move(GridDirection.Down) });