Jump to content
  • Advertisement
Sign in to follow this  
Armigus2

[XNA] Composite list of XML objects

This topic is 2952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have several similar types of XML-based content I want to combine into a map level object:

Player

<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="TileLibrary.Elements.PlayerContent">
<Picture>
<Name>mage0</Name>
<Origin>32 32</Origin>
<ThumbGrid>6 1</ThumbGrid>
</Picture>
<Status>
<Depth>0.5</Depth>
<Blend>ffffff00</Blend>
<Opacity>1</Opacity>
<Solid>true</Solid>
</Status>
<Transform>
<Position>400 400</Position>
<ThumbPos>0 0</ThumbPos>
<Angle>-25</Angle>
</Transform>
<PaceAnim>.8</PaceAnim>
<LengthAnim>6</LengthAnim>
<Speed>0 0</Speed>
</Asset>
</XnaContent>


Background

<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="TileLibrary.Graphics.SpriteBlockContent">
<Picture>
<Name>grass7</Name>
<Origin>0 0</Origin>
<ThumbGrid>0 0</ThumbGrid>
</Picture>
<Status>
<Depth>1.0</Depth>
<Blend>FFFFFF00</Blend>
<Opacity>1</Opacity>
<Solid>false</Solid>
</Status>
<Transform>
<Position>0 0</Position>
<ThumbPos>0 0</ThumbPos>
<Angle>0</Angle>
</Transform>
<Block>10 10</Block>
</Asset>
</XnaContent>


Flora

<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="TileLibrary.Graphics.SpriteDecorContent">
<Picture>
<Name>Flora</Name>
<Origin>0 0</Origin>
<ThumbGrid>8 8</ThumbGrid>
</Picture>
<Status>
<Depth>0.9</Depth>
<Blend>ffffffff</Blend>
<Opacity>1</Opacity>
<Solid>false</Solid>
</Status>
<Transform>
<Item>
<Position>342 90</Position>
<ThumbPos>0 3</ThumbPos>
<Angle>0</Angle>
</Item>
<Item>
<Position>1352 590</Position>
<ThumbPos>1 1</ThumbPos>
<Angle>0</Angle>
</Item>
<Item>
<Position>783 504</Position>
<ThumbPos>7 2</ThumbPos>
<Angle>0</Angle>
</Item>
<Item>
<Position>4023 124</Position>
<ThumbPos>3 4</ThumbPos>
<Angle>0</Angle>
</Item>
<Item>
<Position>2208 3516</Position>
<ThumbPos>3 4</ThumbPos>
<Angle>0</Angle>
</Item>
</Transform>
</Asset>
</XnaContent>


All of these objects share a common interface, IEntities, that requires them to know how to build a list of Sprite objects for the engine.

The map object is actually very simple:

namespace TileLibrary.Elements
{
public class MapContent : IEntities
{
#region Fields
protected List<IEntities> entries;
#endregion

#region Properties
public List<IEntities> Entries
{
get { return entries; }
set { entries = value; }
}
#endregion

#region Implementation
public void FillEntities(List<Sprite> ent, ContentManager cm)
{
foreach (IEntities entry in Entries) entry.FillEntities(ent, cm);
}

public void ReadContent(ContentReader input)
{
foreach (IEntities entry in Entries) entry.ReadContent(input);
}

public void WriteContent(ContentWriter output)
{
foreach (IEntities entry in Entries) entry.WriteContent(output);
}
#endregion
}
}


How can map.xml tell the content pipeline what type to use for each element in the list? Is this composite list even feasible in the content pipeline or am I going to have to maintain a list of each content type in the map object?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!