示例#1
0
 public Hero(XElement e)
     : base(e)
 {
     Name        = e.Attribute("Name").Value.Replace("UnitProfile", string.Empty);
     DisplayName = new XmlProperty(e.Element("UserDefinedName"));
     Abilities   = e.Elements("ProfileAbilityReferences").Select(x => new Ability(x)).ToList();
 }
        public Empire(XElement e)
            : base(e)
        {
            Name = e.Element("SimulationObject").Attribute("Name").Value;
            var properties = e.Element("SimulationObject").Element("Properties").Elements("Property");

            Account            = new XmlProperty(properties.First(x => x.Attribute("Name").Value == "BankAccount"));
            Power              = new XmlProperty(properties.First(x => x.Attribute("Name").Value == "EmpirePointStock"));
            StrategicResources = properties.Where(x => x.Attribute("Name").Value.StartsWith("Strategic"))
                                 .Select(x => new XmlProperty(x)).ToList();
            Perals          = new XmlProperty(properties.First(x => x.Attribute("Name").Value == "OrbStock"));
            LuxuryResources = properties.Where(x => x.Attribute("Name").Value.StartsWith("Luxury"))
                              .Select(x => new XmlProperty(x)).ToList();
            Heroes =
                e.XPathSelectElement("./Agencies/DepartmentOfDefense/UnitDesigns/Hidden")
                .Elements("UnitDesign")
                .Where(
                    x =>
                    x.Elements("SimulationDescriptorReference")
                    .Any(y => y.Attribute("Name").Value == "UnitHero"))
                .Select(x => new Hero(x))
                .ToList();
            var empirePlans = e.XPathSelectElement("./Agencies/DepartmentOfPlanificationAndDevelopment/EmpirePlans");

            NextPlanTurn = new XmlProperty(empirePlans.Element("EmpirePlanChoiceRemainingTurn"));
            Plans        = empirePlans.Element("CurrentEmpirePlan").Elements("KeyValuePair")
                           .Select(x => new EmpirePlan(x))
                           .ToList();
            Armies = e.XPathSelectElement("./Agencies/DepartmentOfDefense/Armies")
                     .Elements("Army").Select(x => new Army(x)).ToList();
        }