This is my current code:
List<Tile> listTiles = new List<Tile>();
for (int i = 0; i < Width; i++)
for (int j = 0; j < Height; j++)
{
//Load each tile into the list
listTiles.Add(mapbox.RenderedMap.Tiles[i, j]);
}
XmlSerializer serializer = new XmlSerializer(listTiles.GetType(), new XmlRootAttribute("Map"));
StreamWriter writer = new StreamWriter(@"savedmap.xml");
serializer.Serialize(writer.BaseStream, listTiles);
What it basically does is it loads every current tile onto a list, which is then serialized in the format:
<Map>
<Tile>TileData</Tile>
</Map>
With Map being the root node.
My question is: How can I make it so instead of what I have now, I have the following?
<GameSave>
<Map>
<Tile>TileData</Tile>
</Map>
<Options>
</Options>
</GameSave>
So basically, add a root node and put my Map node into it (which contains the Tile nodes), alongside an options node. Would I have to change the way im doing it and not use a list since, the list only contains tiles?
No comments:
Post a Comment