Hi, i'm working on a Client-Server Game with a tilebased map. If the user changes the visible section of the map (i.e. scrolls in any direction) i query the server for info about the new section giving X, Y, Width and Height.
The Map info is stored as 2D array
MapTile[,]
(MapTile is a simple Struct)
When the client requests a new section i want to read the section from the map tile array, for that i defined a method
public MapTile[,] GetMapSection(Rectangle area)
{
[... snip validation ...]
MapTile[,] result = new MapTile[area.Width, area.Height];
for (Int32 y = 0; y < area.Height; ++y)
{
for (Int32 x = 0; x < area.Width; ++x)
{
result[x, y] = this.map[x + area.X, y + area.Y];
}
}
return result;
}
Is there an easier (=> easier to read, understand and maintain, not necessarily faster) way to get the section from the Array?