- Home /
Store list in an XML list?
I'm trying to build a body parts system for my game, similar to but nowhere near the scope of Dwarf Fortress. I previously built a simple XML list for the items in my game which stored a name, description, and damage dealt, but I don't know how to store System.Collections lists inside an XML list, and how to add elements to it.
For my body parts I'm building a class. (Not my actual code, just pseudo.)
[XmlType("BodyPart")
public class BodyPart()
{
[XmlAttribute("Name")]
public string partName;
[XmlElement("Health")]
public float partHealth;
}
And in my class for the creatures, I plan to have a list like this for every creature.
List<BodyPart> bodyParts;
I understand that I probably need to make the bodyParts list an XmlElement, but how do I reference and add body parts to the list from the Xml file, including filling in those body part's variables (name and health).
Your answer
Follow this Question
Related Questions
Storing list aka "save function" 3 Answers
A node in a childnode? 1 Answer
Performance question - Loading large-ish amounts of text data in a mobile game? 1 Answer
How to import Long and Lat (GPS Info) from a flat file and render the points. 1 Answer
DataContract serialization not compatible with Unity? 0 Answers