public override void LoadXml(XElement node) { foreach (XElement weapon in node.Elements("Weapon")) { string name = weapon.RequireAttribute("name").Value; string entity = weapon.RequireAttribute("entity").Value; int ammo = weapon.TryAttribute <int>("ammo", -1); int usage = weapon.TryAttribute <int>("usage", 1); int?palette = weapon.TryAttribute <int?>("palette"); HealthMeter meter = null; XElement meterNode = weapon.Element("Meter"); if (meterNode != null) { var meterInfo = HandlerXmlReader.LoadMeter(meterNode, Game.CurrentGame.BasePath); meter = HealthMeter.Create(meterInfo, true); meter.MaxValue = ammo; meter.Reset(); } AddWeapon(name, entity, ammo, usage, meter, palette); } }
public override void LoadXml(XElement node) { XElement maxNode = node.Element("Max"); if (maxNode != null) { maxHealth = maxNode.GetValue <float>(); } StartHealth = node.TryAttribute <float>("startValue", MaxHealth); XElement meterNode = node.Element("Meter"); if (meterNode != null) { var meterInfo = HandlerXmlReader.LoadMeter(meterNode, Game.CurrentGame.BasePath); meter = HealthMeter.Create(meterInfo, true); meter.MaxValue = maxHealth; meter.IsPlayer = (Parent.Name == "Player"); } XElement flashNode = node.Element("Flash"); if (flashNode != null) { flashtime = flashNode.TryValue <int>(); } }