private static MegaTileVictimConfig ReadMegaTileVictimConfig(XmlTextReader reader, ContentManager content)
{
string attName;
MegaTileVictimConfig mtvConfig = new MegaTileVictimConfig();
reader.MoveToFirstAttribute();
//Loop through all attributes for the Level config
do
{
try
{
//Get the attribute name
attName = reader.Name.ToUpper();
//Look for definied attributes for level
if (attName == "NAME")
{
mtvConfig.VictimConfig = getVictimTypeByName(reader.Value);
}
else if (attName == "MAX")
{
mtvConfig.MaxPopulation = int.Parse(reader.Value);
}
else if (attName == "REQUIREDNUM")
{
mtvConfig.RequiredPopulation = int.Parse(reader.Value);
}
//Handle undefined MTVC attributes
else
{
throw new ApplicationException("Invalid Mega tile victim config attribute '" + attName + "' on line " + reader.LineNumber);
}
}
catch (Exception e)
{
throw new ApplicationException("Error parsing Level Config attribute on line " + reader.LineNumber +
": " + e.Message);
}
//Santity check
if (mtvConfig.RequiredPopulation > mtvConfig.MaxPopulation)
{
throw new Exception("requiredNum must be smaller than max in TornadoGameConfig.xml line: " + reader.LineNumber);
}
} while (reader.MoveToNextAttribute());
//Add the level config object to the list
return mtvConfig;
}