private static void ReadVictimType(XmlTextReader reader, ContentManager content)
{
string tempString;
//Move to first attribute for this victim
if (reader.MoveToFirstAttribute())
{
//Create a new victim type
VictimConfig tempVictimType = new VictimConfig();
//Loop through all attributes for Victim type
do{
try
{
//Get the attribute name
tempString = reader.Name.ToUpper();
if (tempString == "MASS")
{
tempVictimType.Mass = float.Parse(reader.Value);
}
else if(tempString == "GROUNDHEALTH"){
tempVictimType.GroundHealth = float.Parse(reader.Value);
}
else if(tempString == "TORNADOHEALTH"){
tempVictimType.TorontoHealth = float.Parse(reader.Value);
}
else if (tempString == "NAME")
{
tempVictimType.VictimName = reader.Value;
}
else if (tempString == "SOUNDEFFECT")
{
tempVictimType.VictimSound = reader.Value;
}
else if (tempString == "CLASS")
{
tempVictimType.VictimClass = (VictimClass)Enum.Parse(typeof(VictimClass), reader.Value.ToUpper());
}
else if (tempString == "SPEED")
{
tempVictimType.VictimSpeed = float.Parse(reader.Value);
}
//Handle undefined level attributes
else
{
throw new ApplicationException("Invalid Victim type attribute '" + tempString + "' on line " + reader.LineNumber);
}
}
catch (Exception e)
{
throw new ApplicationException("Error parsing Victim type attribute on line " + reader.LineNumber +
": " + e.Message);
}
} while (reader.MoveToNextAttribute());
//Look for nested elements
while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name.ToUpper() == "VICTIMTYPE"))
{
reader.Read();
reader.MoveToContent();
string animTypeName;
if (reader.NodeType == XmlNodeType.Element)
{
tempString = reader.Name.ToUpper();
//Look for valid Victim type sub-elements
if (tempString == "ANIMATION")
{
reader.MoveToFirstAttribute();
animTypeName = reader.Name.ToUpper();
//Make sure type attribute is defined first
if (animTypeName == "TYPE")
{
animTypeName = reader.Value.ToUpper();
}
else
{
throw new ApplicationException("Type attribute must be provided first for animation on line " + reader.LineNumber);
}
//Check which type of animation this is defining
if (animTypeName == "GROUND")
{
tempVictimType.GroundAnim = ReadAnimation(reader, content);
}
else if (animTypeName == "STUMP")
{
tempVictimType.StumpAnim = ReadAnimation(reader, content);
}
else if (animTypeName == "EXPLODE")
{
tempVictimType.ExplodeAnim = ReadAnimation(reader, content);
}
else if (animTypeName == "TORNADO")
{
tempVictimType.TornadoAnim = ReadAnimation(reader, content);
}
else
{
throw new ApplicationException("Invalid Victim Animation type '" + animTypeName + "' on line " + reader.LineNumber);
}
}
else
{
throw new ApplicationException("Invalid Victim Type Sub-Element '" + tempString + "' on line " + reader.LineNumber);
}
}
}
//Add the Victim type to the list
victimTypes.Add(tempVictimType);
}
}