public static void DumpBuffer(GenericBuffer <bool> buffer) { for (int y = 0; y < buffer.Height; y++) { for (int x = 0; x < buffer.Width; x++) { Position pos = new Position(x, y); bool dat = buffer.Get(pos); Console.Write(dat ? " " : "/"); } Console.WriteLine(""); } }
public virtual bool GenerateSelf(List <MapData> mapDatas, GenericBuffer <bool> buffer, int depth, Random random) { try { for (int x = 0; x < MapData.Width; x++) { for (int y = 0; y < MapData.Height; y++) { if (0 < x && x < Math.Max(MapData.Width - 1, 0) && 0 < y && y < Math.Max(MapData.Height - 1, 0)) { Position pos = new Position(x, y); bool dat1 = MapData.Get(pos); bool dat2 = buffer.Get(Position + pos); if (dat1 == true && dat2 == true) { return(false); } } } } for (int x = 0; x < MapData.Width; x++) { for (int y = 0; y < MapData.Height; y++) { Position pos = new Position(x, y); bool dat = MapData.Get(pos); if (dat == true) { buffer.Set(Position + pos, true); } } } return(true); } catch (GenericBufferPositionOutOfRangeException) { // out of ranged return(false); } }