public static new FloatStat fromXML(XElement xmlStat) { if(xmlStat == null) { return null; } float value = 0; if(xmlStat.Element("Amount") != null) { value = (float)xmlStat.Element("Amount"); } FloatStat newStat = new FloatStatExplicit(value); return newStat; }
public static ProjectileTemplate fromXML(XElement xmlProjectile) { //TODO: Remove the defaults from hard coding. string name = "UNNAMED PROJECTILE"; string spriteName = "NO_SPRITE"; FloatStat damageRatio = new FloatStatExplicit(1.0f); IntStat bounces = new IntStatExplicit(5); FloatStat lifespan = new FloatStatExplicit(10.0f); FloatStat speed = new FloatStatExplicit(1.0f); //Load in data from XML. if (xmlProjectile.Attribute("name") != null) { name = (string)xmlProjectile.Attribute("name"); } if (xmlProjectile.Element("Sprite") != null) { spriteName = (string)xmlProjectile.Element("Sprite"); } if (xmlProjectile.Element("DamageRatio") != null) { damageRatio = FloatStat.fromXML(xmlProjectile.Element("DamageRatio")); } if (xmlProjectile.Element("Bounces") != null) { bounces = IntStat.fromXML(xmlProjectile.Element("Bounces")); } if (xmlProjectile.Element("Lifespan") != null) { lifespan = FloatStat.fromXML(xmlProjectile.Element("Lifespan")); } if (xmlProjectile.Element("Speed") != null) { speed = FloatStat.fromXML(xmlProjectile.Element("Speed")); } ProjectileTemplate projectileTemplate = new ProjectileTemplate(name, spriteName, damageRatio, bounces, lifespan, speed); //Load in Behaviors from XML. //TODO: Load in behavior from XML. return projectileTemplate; }