public void DrawAsMap(SpriteBatch spriteBatch, int scale)
{
foreach (var l in Layers)
{
if (!l.Visible)
continue;
TileLayer tileLayer = l as TileLayer;
if (tileLayer != null)
{
for (int y = 0; y < Height; y++)
{
for (int x = 0;x<Width ; x++)
{
if (x >= 0 && x < tileLayer.Width && y >= 0 && y < tileLayer.Height)
{
Tile tile = tileLayer.Tiles[x, y];
if (tile != null && tile.Texture != null)
{
spriteBatch.Draw(tile.Texture, new Rectangle(x * (int)(TileWidth / scale), y * (int)(TileHeight / scale), (int)(TileWidth / scale), (int)(TileHeight / scale)), tile.Source, Color.White);
}
}
}
}
}
}
}