/// <summary> /// Flood fill the matrix with the given type /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="type"></param> private void Flood(MapCellDetail cell, BasicMapPiece type) { if (cell.Filled || !cell.IsSpace) { return; } cell.Filled = true; cell.BasicType = type; if (cell.X > 0) { Flood(cell.CellLeft, type); } if (cell.X < _width - 1) { Flood(cell.CellRight, type); } if (cell.Y > 0) { Flood(cell.CellAbove, type); } if (cell.Y < _height - 1) { Flood(cell.CellBelow, type); } }
public MapCellDetail(MapCellDetail[,] map, int x, int y, BasicMapPiece basicType) { _map = map; Y = y; X = x; BasicType = basicType; }
/// <summary> /// Change all single walls that are touching the given type to the new wall type /// </summary> /// <param name="touchType"></param> /// <param name="wallType"></param> private void ChangeSingleWallTouching(BasicMapPiece touchType, BasicMapPiece wallType) { for (int y = 1; y < _height - 1; y++) { for (int x = 1; x < _width - 1; x++) { var cell = _map[x, y]; if (cell.BasicType == BasicMapPiece.SingleWall) { if (cell.CellAbove.BasicType == touchType || cell.CellBelow.BasicType == touchType || cell.CellLeft.BasicType == touchType || cell.CellRight.BasicType == touchType || cell.CellTopLeft.BasicType == touchType || cell.CellTopRight.BasicType == touchType || cell.CellBottomLeft.BasicType == touchType || cell.CellBottomRight.BasicType == touchType) { cell.BasicType = wallType; } } } } }