コード例 #1
0
 public XElement ProcessGunListFile(string nation)
 {
     return(ProcessModuleListFile(_paths.GetGunListFile(nation), "gun", g => BigworldXmlPreprocessor.ProcessGunNode(g, this.CommonVehicleData, true)));
 }
コード例 #2
0
        public XElement ProcessTankFile(string nation, string key)
        {
            var element = BigworldXmlPreprocessor.LoadFile(_paths.GetTankFile(nation, key));

            element.TrimNameTail()
            .NameToAttribute("tank")
            .RenameElement("crew", "crews")
            .RenameElement("camouflage", "camouflageInfo")
            .ProcessElements("crews",
                             e => e.NameToAttribute("crew", "role")
                             .TextToElement("secondaryRoles")
                             .Select("secondaryRoles",
                                     s =>
                                     s.TextToElementList("secondaryRole")))
            .Select("hull",
                    e =>
            {
                e.ProcessArmorList(this.CommonVehicleData)
                .Select("armor",
                        a => a.AppendCommonArmorGroup(this.CommonVehicleData, "surveyingDevice")
                        .AppendCommonArmorGroup(this.CommonVehicleData, "turretRotator"));

                BigworldXmlPreprocessor.ProcessHitTester(e);
            })
            .ProcessTankModuleListNode("chassis",
                                       "chassis",
                                       _localization,
                                       e =>
            {
                e.ProcessArmorList(this.CommonVehicleData)
                .Select("terrainResistance",
                        t => t.TextToElements("hard", "medium", "soft"));

                BigworldXmlPreprocessor.ProcessHitTester(e);
            })
            .RenameElement("turrets0", "turrets")
            .ProcessTankModuleListNode("turrets",
                                       "turret",
                                       _localization,
                                       e =>
            {
                e.ProcessArmorList(this.CommonVehicleData)
                .Select("armor", a => a.AppendCommonArmorGroup(this.CommonVehicleData, "surveyingDevice"))
                .ProcessTankModuleListNode("guns",
                                           "gun",
                                           _localization,
                                           g => BigworldXmlPreprocessor.ProcessGunNode(g, this.CommonVehicleData, false));


                BigworldXmlPreprocessor.ProcessHitTester(e);
            })
            .ProcessTankModuleListNode("engines",
                                       "engine",
                                       _localization,
                                       BigworldXmlPreprocessor.ProcessEngineNode)
            .ProcessTankModuleListNode("fuelTanks", "fuelTank", _localization)
            .ProcessTankModuleListNode("radios", "radio", _localization);

            var unlockNodes = element.XPathSelectElements("(chassis/chassis|turrets/turret|turrets/turret/guns/gun|engines/engine|radios/radio)/unlocks/*");

            foreach (var unlockNode in unlockNodes)
            {
                string searchRootPath;
                switch (unlockNode.Name.LocalName)
                {
                case "gun":
                    searchRootPath = "turrets/turret/guns/gun";
                    break;

                case "chassis":
                    searchRootPath = "chassis/chassis";
                    break;

                case "turret":
                    searchRootPath = "turrets/turret";
                    break;

                case "engine":
                    searchRootPath = "engines/engine";
                    break;

                case "radio":
                    searchRootPath = "radios/radio";
                    break;

                default:
                    continue;
                }

                var targetElements = element.XPathSelectElements(string.Format("{0}[@key='{1}']",
                                                                               searchRootPath,
                                                                               unlockNode.Attribute("key").Value));

                foreach (var targetElement in targetElements)
                {
                    var costElement = unlockNode.Element("cost");
                    Debug.Assert(costElement != null, "costElement != null");
                    targetElement.SetElementValue("experience", costElement.Value);
                }
            }

            return(element);
        }