public static void FillAllTiles <T1, T2, T3> (ITilezoneTileDataStream tiles, int index, TileFunctionDelegate <T1, T2, T3> TileFunc, T1 arg1, T2 arg2, T3 arg3, bool writeEmptyTiles = false) { for (int x = 0; x < tiles.width; x++) { for (int y = 0; y < tiles.height; y++) { Tile newTile = TileFunc(x, y, arg1, arg2, arg3); if (writeEmptyTiles || newTile != Tile.empty) { tiles[x, y, index] = newTile; } } } }
public static void FillTiles <T1, T2, T3> (int x, int y, int width, int height, ITilezoneTileDataStream tiles, int index, Tile tile, TileFunctionBoolDelegate <T1, T2, T3> TileFunc, T1 arg1, T2 arg2, T3 arg3, bool useLocalCoordinates, bool writeEmptyTiles = false) { for (int xx = 0; xx < width; xx++) { for (int yy = 0; yy < height; yy++) { bool func = useLocalCoordinates ? TileFunc(xx, yy, arg1, arg2, arg3) : TileFunc(x + xx, y + yy, arg1, arg2, arg3); if (func) { tiles[x + xx, y + yy, index] = tile; } else if (writeEmptyTiles) { tiles[x + xx, y + yy, index] = Tile.empty; } } } }
MazeCell[,] SetUpGrid(ITilezoneTileDataStream dataStream, int mazeWidth, int mazeHeight) { MazeCell[,] result = new MazeCell[mazeWidth, mazeHeight]; for (int x = 0; x < mazeWidth; x++) { for (int y = 0; y < mazeWidth; y++) { int neighbourMask = 15; int xIndex = x * 2 + 1; int yIndex = y * 2 + 1; dataStream[xIndex, yIndex + 1, 0] = wallTile; dataStream[xIndex + 1, yIndex + 1, 0] = wallTile; dataStream[xIndex + 1, yIndex, 0] = wallTile; dataStream[xIndex, yIndex, 0] = floorTile; if (x == mazeWidth - 1) { neighbourMask &= 13; } if (y == mazeHeight - 1) { neighbourMask &= 11; } if (y == 0) { neighbourMask &= 14; dataStream[xIndex, yIndex - 1, 0] = wallTile; dataStream[xIndex + 1, yIndex - 1, 0] = wallTile; if (x == 0) { dataStream[xIndex - 1, yIndex - 1, 0] = wallTile; } } if (x == 0) { neighbourMask &= 7; dataStream[xIndex - 1, yIndex + 1, 0] = wallTile; dataStream[xIndex - 1, yIndex, 0] = wallTile; } result[x, y] = new MazeCell(neighbourMask, x, y); } } return(result); }
public static void StampTileData(ITilezoneTileDataStream dataFrom, int indexFrom, ITilezoneTileDataStream dataTo, int indexTo, int x, int y, bool writeEmptyTiles, bool overwrite = true) { if (!dataFrom.isDataReady) { return; } for (int xx = 0; xx < dataFrom.width; xx++) { for (int yy = 0; yy < dataFrom.height; yy++) { if (!overwrite && dataTo[x + xx, y + yy, indexTo] != Tile.empty) { continue; } Tile newTile = dataFrom[xx, yy, indexFrom]; if (writeEmptyTiles || newTile != Tile.empty) { dataTo[x + xx, y + yy, indexTo] = newTile; } } } }