Based on Nick's
informative article over at Ziggy's I have started revamping my level loading system in my game. I've run into a bit of a hassle though and I'm hoping there is a workaround.
Here is a sampling of my Level class:
public class Level
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int width;
public int Width
{
get { return width; }
set { width = value; }
}
private int height;
public int Height
{
get { return height; }
set { height = value; }
}
private string decription;
public string Description
{
get { return decription; }
set { decription = value; }
}
private List<ILevelObstacle> obstacles = new List<ILevelObstacle>();
public List<ILevelObstacle> Obstacles
{
get { return obstacles; }
set { obstacles = value; }
}
// bunch of useful methods below here ...
}
The tricky part is the last property which needs populated. I'm not sure how to write the LevelContentWriter and LevelContentReader (or even the XML for that matter) to get this data into the Level object.
My current non-PipeLine XML look like this:
<level>
<Name>Test Level 04</Name>
<Description>Wonderful info included here</Description>
<Width>1500</Width>
<Height>1500</Height>
<obstacles>
<obstacle typeId="Start" positionX="250" positionY="400" mass="-1" rotation="0" radius="60" requiredIndex="0"/>
<obstacle typeId="Gate" positionX="1250" positionY="750" mass="-1" rotation="0" radius="60" requiredIndex="1"/>
<obstacle typeId="Finish" positionX="250" positionY="1100" mass="-1" rotation="0" radius="60" requiredIndex="0"/>
<obstacle typeId="Asteroid" positionX="900" positionY="750" mass="250" rotation="1" radius="180" requiredIndex="0"/>
</obstacles>
</level>
My new PipeLine XML is like this so far...
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="SpaceCourse.Level">
<Name>Construction Level</Name>
<Description>Level used to test stuff</Description>
<Width>800</Width>
<Height>800</Height>
</Asset>
</XnaContent>
Is there a way to get the obstacles into the list using the
List<ILevelObstacle>?