private int Get8DirMask(Array2D <int> input, int x, int y, TilerPattern p) { // 0 1 2 // 3 4 // 5 6 7 int m = 0; if (p.Connects(GetCell(input, x - 1, y - 1))) { m |= 1; } if (p.Connects(GetCell(input, x, y - 1))) { m |= 2; } if (p.Connects(GetCell(input, x + 1, y - 1))) { m |= 4; } if (p.Connects(GetCell(input, x - 1, y))) { m |= 8; } if (p.Connects(GetCell(input, x + 1, y))) { m |= 16; } if (p.Connects(GetCell(input, x - 1, y + 1))) { m |= 32; } if (p.Connects(GetCell(input, x, y + 1))) { m |= 64; } if (p.Connects(GetCell(input, x + 1, y + 1))) { m |= 128; } //if (x != 0) //{ // if (y != 0 && p.Connects(mapInput[input[x - 1, y - 1]])) // m |= (1 << 0); // if (y != input.sizeY - 1 && p.Connects(mapInput[input[x - 1, y + 1]])) // m |= (1 << 5); // if (p.Connects(mapInput[input[x - 1, y]])) // m |= (1 << 3); //} //if (x != input.sizeX - 1) //{ // if (y != 0 && p.Connects(mapInput[input[x + 1, y - 1]])) // m |= (1 << 2); // if (y != input.sizeY - 1 && p.Connects(mapInput[input[x + 1, y + 1]])) // m |= (1 << 7); // if (p.Connects(mapInput[input[x + 1, y]])) // m |= (1 << 4); //} //if (y != 0 && p.Connects(mapInput[input[x, y - 1]])) // m |= (1 << 1); //if (y != input.sizeY - 1 && p.Connects(mapInput[input[x, y + 1]])) // m |= (1 << 6); return(m); }
public void CreateAndSaveImage(Array2D <T> a, string path) { Image image = CreateImage(a); image.SaveToFile(path); }
private int ProcessTilePath(Array2D <int> input, int x, int y, int tt) { TilerPattern p = patterns[tt]; return(p.tiles[Get4DirMask(input, x, y, p)]); }