XNA serialization… Deciding which method to use

I'm making a 2D roguelike game (with procedurally generated levels) in XNA

Ive 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....

  1. Write all my xml.
  2. 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

  1. Read xml
  2. 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 room

The xml file might look something like this (this is only a rough indication, not meant to be real!)

<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>

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..

Answers


Need Your Help

Tornado streaming: flush() lagging on Safari & Chrome (Firefox is fine)

safari google-chrome comet long-polling tornado

On Safari and Chrome, I won't be able to see flush() updates updating live on my page until after a certain number of flushes, or sometimes it hangs altogether on Safari. Flush updates work immedi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.