Sunday 14 February 2010

Level & Content management

I've been prototyping several design concepts on how to manage my content and level data efficiently and easy. After a good day's work this is where I'm at:

- LevelCollection class manages a single LevelData class.
- LevelData class can hold all the game objects in the current scene.
- LevelCollection has control over Loading/Unloading (a particular scene) and XML LoadFromFile/SaveToFile methods (managing positions, rotations and scaling)

All the content is now being managed using Dictionaries. This provides great control over used and unused assets. In the current implementation a method is fired containing all the data of a particular scene. The current assets are compared with the assets required for the next scene. Unused data is unloaded. The remaining asset data is assigned to the proper game object.

That may sound either very straightforward or maybe you've completely lost it by now... Here's a quick summary:

LevelCollection.Load(*levelnametoload*) will know which scene you want to load, and will clear all current data present in the scene and loads all the new scene data as well as comparing current with new assets (models, textures etc.) to check if any new assets need to be loaded and if unused assets need to be unloaded to free memory.

When you're scene is loaded and visible on screen, you can either play it or start messing around with the positions. Changing a Position or Rotation will require LevelCollection.SaveToFile(*filename*) to persist after quiting the game.

I'd like to show a video about this very soon...So stay tuned!

Update: Video available HERE

4 comments:

  1. Would it be possible to see the source to the level editor save/load system?

    ReplyDelete
  2. Hi,

    The loading/saving of a level has changed dramatically over time. I use the IntermediateSerializer class (Available through XNA)to store all data inside my Level class (containing all the entities with their positions, rotations etc.)

    Maybe I'll make another post about this, explaining how it works with some code to look at. Anything in particular you're interested in concerning the level serialization?

    ReplyDelete
  3. breaking it down to a single object are you serializing the whole object or just properties of the object. Like name, position,rotation,scale, etc.

    If your willing to do a new post with some code samples I'd be very interested in seeing it.

    to be honest I'd be interested in seeing all of your engine's code as it looks amazing.

    ReplyDelete
  4. I serialize only the important properties, such as position and model path. The IntermediateSerializer is very dynamic and allows you to specify which properties you want included. Have a look at the following url: http://blogs.msdn.com/b/shawnhar/archive/2008/08/12/everything-you-ever-wanted-to-know-about-intermediateserializer.aspx

    I'll think about creating a post about it :) Got a lot coming up, including a huge new game project.

    ReplyDelete