public bool Match(Tile inputTile, out TileOrientation tileOrientation) { bool rotate = false, mirrorX = false, mirrorY = false; var result = Equals(inputTile); byte[,] mirrorXResult = null; // saving this incase I need it later // R0 X1 Y0 if (!result) { rotate = false; mirrorX = true; mirrorY = false; mirrorXResult = MirrorXMatrix(Pixels, MatrixDimension); result = MatchBytes(inputTile.Pixels, mirrorXResult); } // R0 X0 Y1 if (!result) { rotate = false; mirrorX = false; mirrorY = true; var mirrorYResult = MirrorYMatrix(Pixels, MatrixDimension); result = MatchBytes(inputTile.Pixels, mirrorYResult); } // R0 X1 Y1 if (!result) { rotate = false; mirrorX = true; mirrorY = true; // note: y mirror mirrorXResult var mirrorYResult = MirrorYMatrix(mirrorXResult, MatrixDimension); result = MatchBytes(inputTile.Pixels, mirrorYResult); } // now we need to rotate byte[,] rotateResult = null; // saving this incase I need it later // R1 X0 Y0 if (!result) { rotate = true; mirrorX = false; mirrorY = false; rotateResult = RotateMatrix(Pixels, MatrixDimension); result = MatchBytes(inputTile.Pixels, rotateResult); } // R1 X1 Y0 if (!result) { rotate = true; mirrorX = true; mirrorY = false; // reuse rotate result mirrorXResult = MirrorXMatrix(rotateResult, MatrixDimension); result = MatchBytes(inputTile.Pixels, mirrorXResult); } // R1 X0 Y1 if (!result) { rotate = true; mirrorX = false; mirrorY = true; // reuse rotate result var mirrorYResult = MirrorYMatrix(rotateResult, MatrixDimension); result = MatchBytes(inputTile.Pixels, mirrorYResult); } // R1 X1 Y1 if (!result) { rotate = true; mirrorX = true; mirrorY = true; // note: y mirror mirrorXResult var mirrorYResult = MirrorYMatrix(mirrorXResult, MatrixDimension); result = MatchBytes(inputTile.Pixels, mirrorYResult); } tileOrientation = new TileOrientation(rotate, mirrorX, mirrorY); return(result); }
public void PlaceTile(int row, int column, int tileIndex, TileOrientation orientation) { _tiles[row, column] = new TileMapEntry(tileIndex, orientation); }
public TileMapEntry(int index, TileOrientation orientation) { Index = index; Orientation = orientation; }
public void PlaceTile(int row, int column, int tileIndex) { PlaceTile(row, column, tileIndex, TileOrientation.Default()); }