public static void Main()
var tileSourceX = new StringBuilder();
var tileSourceY = new StringBuilder();
var layerData = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
for(int layerRowIndex = 0; layerRowIndex < layerHeight; layerRowIndex++)
var layerRowData = layerData.Skip(layerWidth * layerRowIndex).Take(layerWidth);
for(int layerColIndex = 0; layerColIndex < layerWidth; layerColIndex++)
var data = layerRowData.ElementAt(layerColIndex);
var tilesetRowIndex = tileId / columns;
var tilesetColIndex = tileId - (tilesetRowIndex * columns);
tileSourceX.Append("["+tileId+"] " + (tileWidth * tilesetColIndex) + "\t|\t");
tileSourceY.Append("["+tileId+"] " + tileHeight * tilesetRowIndex + "\t|\t");
tileSourceX.AppendLine();
tileSourceY.AppendLine();
Console.WriteLine("TileSourceX \n{0}\n", tileSourceX);
Console.WriteLine("TileSourceY \n{0}\n", tileSourceY);