XNA serialization… Deciding which method to use

floryn77

New Member
I'm making a 2D roguelike game (with procedurally generated levels) in XNAIve just started looking at serialization/deserialization...Ive been reading a bit about the built-in xml serializer and the intermediate serializer...They sound like more trouble than their worth tbh.. with various foibles. eg. built in xml serializer will only serialize public fields (I have tried to be a good programmer and have as much stuff as possible private or protected) and will make multiple copies of references unless you take special steps to prevent it and so on..I feel like just using the basic .net xml writer/reader and give each of my objects a serialize/deserialize function where I save exactly the details needed..For example, this would be the sequence for exiting a lvl....[*]Write all my xml.[*]Purge everything. (I'll have to write purge functions too that empty out all the lists, components and so on (actually should I bother to "dispose" things??))and for loading a lvl[*]Read xml[*]Instantiate all new objects using paramaters from xml...My game has a list of levels, which each have lists of rooms, which each have lists of the sprites and solids and whatnot making up each roomThe xml file might look something like this (this is only a rough indication, not meant to be real!)\[code\]<LevelList> <Level> <RoomList> <Room> <colour>255,105,76<colour> <spritelist> <sprite> <ObjectType>WallBlock01</ObjectType> <position>18673,34345</position> </sprite> </spritelist> <solidsList> <solid>2342,2342,23423,3453</solid> </solidsList> </Room> </RoomList> </Level></LevelList>\[/code\]My rooms already contain functions that will take the raw data (rectangles, colours and so on and add all the necessary drawable game components, physics objects, shadow hulls and so on)So, do you think this is crazy or is it a good idea..? I think it will be a lot of work, but also I should be able to work through it steadily and when I'm finished it will work as expected, whereas I fear that by using one of the auto-serializers I will be constantly fighting with it and changing my code in order to get it to work properly..
 
Back
Top