Exemple #1
0
 public void AddModifier(ModifierDefinition def)
 {
     this.modifiers.Add(def);
 }
Exemple #2
0
        public static List<SpeciesDefinition> LoadSpecies(string xmlfile)
        {
            List<SpeciesDefinition> species = new List<SpeciesDefinition>();
            XPathDocument doc = new XPathDocument(xmlfile);
            XPathNavigator nav = doc.CreateNavigator();

            foreach (XPathNavigator n in nav.Select("/battle/speciess/species"))
            {
                string name = n.GetAttribute("name", "");
                string descr = n.GetAttribute("description", "");
                SpeciesDefinition d = new SpeciesDefinition();
                d.Name = name;
                d.Description = descr;
                /*
                foreach (XPathNavigator n1 in n.Select("origin"))
                {
                    string oriname = n.GetAttribute("name", "");

                    //d.AddOrigin(n.GetAttribute("name",""));
                }
                */
                foreach (XPathNavigator n2 in n.Select("provides"))
                {
                    d.Provide(n2.GetAttribute("value", ""));
                }
                foreach (XPathNavigator n3 in n.Select("requires"))
                {
                    d.Require(n3.GetAttribute("value", ""));
                }
                foreach (XPathNavigator n4 in n.Select("modifier"))
                {
                    string modname = n4.GetAttribute("name", "");
                    string description = n4.GetAttribute("description", "");
                    string val = n4.GetAttribute("value", "");
                    string target = n4.GetAttribute("target", "");
                    string type = n4.GetAttribute("type", "");
                    ModifierDefinition mod = new ModifierDefinition();
                    mod.Name = modname;
                    mod.Description = description;
                    mod.ModValue = double.Parse(val);
                    mod.EntityType = BattleEntity.ParseEntity(type);
                    mod.TargetName = target;
                    d.AddModifier(mod);
                }
                species.Add(d);
            }

            return species;
        }