コード例 #1
0
        /// <summary>
        /// XML から Map データを読み出す
        /// </summary>
        /// <returns>読み出した Map データ</returns>
        private IEnumerable <Map> GetRecords()
        {
            foreach (var dataset in _MapXml.Root.XPathSelectElements("dataset[not(starts-with(@macro, 'demo'))]/properties/identification/../.."))
            {
                var macro = dataset.Attribute("macro").Value;

                var id = dataset.XPathSelectElement("properties/identification");

                var name        = _Resolver.Resolve(id.Attribute("name").Value);
                var description = _Resolver.Resolve(id.Attribute("description").Value);

                yield return(new Map(macro, name, description));
            }
        }
コード例 #2
0
        /// <summary>
        /// XML から WareProduction データを読み出す
        /// </summary>
        /// <returns>読み出した WareProduction データ</returns>
        private IEnumerable <WareProduction> GetRecords()
        {
            foreach (var ware in _WaresXml.Root.XPathSelectElements("ware[contains(@tags, 'economy')]"))
            {
                var wareID = ware.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(wareID))
                {
                    continue;
                }

                foreach (var prod in ware.XPathSelectElements("production"))
                {
                    var method = prod.Attribute("method")?.Value;
                    if (string.IsNullOrEmpty(method))
                    {
                        continue;
                    }

                    var name   = _Resolver.Resolve(prod.Attribute("name")?.Value ?? "");
                    var amount = prod.Attribute("amount").GetInt();
                    var time   = prod.Attribute("time").GetDouble();

                    yield return(new WareProduction(wareID, method, name, amount, time));
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// XML から Equipment データを読み出す
        /// </summary>
        /// <returns>読み出した Equipment データ</returns>
        private IEnumerable <Equipment> GetRecords()
        {
            foreach (var equipment in _WaresXml.Root.XPathSelectElements("ware[@transport='equipment']"))
            {
                var equipmentID = equipment.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(equipmentID))
                {
                    continue;
                }

                var macroName = equipment.XPathSelectElement("component")?.Attribute("ref")?.Value;
                if (string.IsNullOrEmpty(macroName))
                {
                    continue;
                }

                var equipmentTypeID = equipment.Attribute("group")?.Value;
                if (string.IsNullOrEmpty(equipmentTypeID))
                {
                    continue;
                }

                var       macroXml = _CatFile.OpenIndexXml("index/macros.xml", macroName);
                XDocument componentXml;
                try
                {
                    componentXml = _CatFile.OpenIndexXml("index/components.xml", macroXml.Root.XPathSelectElement("macro/component").Attribute("ref").Value);
                }
                catch
                {
                    continue;
                }

                // 装備が記載されているタグを取得する
                var component = componentXml.Root.XPathSelectElement("component/connections/connection[contains(@tags, 'component')]");

                // サイズ一覧
                string[] sizes = { "extrasmall", "small", "medium", "large", "extralarge" };

                // 一致するサイズを探す
                var tags   = component?.Attribute("tags")?.Value.Split(" ");
                var sizeID = sizes.FirstOrDefault(x => tags?.Contains(x) == true);
                // 一致するサイズがなかった場合
                if (string.IsNullOrEmpty(sizeID))
                {
                    continue;
                }

                var name = _Resolver.Resolve(equipment.Attribute("name").Value);
                name = string.IsNullOrEmpty(name) ? macroName : name;

                yield return(new Equipment(equipmentID, macroName, equipmentTypeID, sizeID, name));
            }
        }
コード例 #4
0
        /// <summary>
        /// XML から Race データを読み出す
        /// </summary>
        /// <returns>読み出した Race データ</returns>
        private IEnumerable <Race> GetRecords()
        {
            foreach (var race in _RaceXml.Root.Elements())
            {
                var raceID = race.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(raceID))
                {
                    continue;
                }

                var name = _Resolver.Resolve(race.Attribute("name")?.Value ?? "");
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var shortName = _Resolver.Resolve(race.Attribute("shortname")?.Value ?? "");

                yield return(new Race(raceID, name, shortName));
            }
        }
コード例 #5
0
        /// <summary>
        /// XML から Ware データを読み出す
        /// </summary>
        /// <returns>読み出した Ware データ</returns>
        private IEnumerable <Ware> GetRecords()
        {
            foreach (var ware in _WaresXml.Root.XPathSelectElements("ware[contains(@tags, 'economy')]"))
            {
                var wareID = ware.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(wareID))
                {
                    continue;
                }

                var wareGroupID = ware.Attribute("group")?.Value;
                if (string.IsNullOrEmpty(wareGroupID))
                {
                    continue;
                }

                var transportTypeID = ware.Attribute("transport")?.Value;
                if (string.IsNullOrEmpty(transportTypeID))
                {
                    continue;
                }

                var name = _Resolver.Resolve(ware.Attribute("name")?.Value ?? "");
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var description = _Resolver.Resolve(ware.Attribute("description")?.Value ?? "");
                var factoryName = _Resolver.Resolve(ware.Attribute("factoryname")?.Value ?? "");
                var volume      = ware.Attribute("volume").GetInt();

                var price    = ware.Element("price");
                var minPrice = price.Attribute("min").GetInt();
                var avgPrice = price.Attribute("average").GetInt();
                var maxPrice = price.Attribute("max").GetInt();

                yield return(new Ware(wareID, wareGroupID, transportTypeID, name, description, factoryName, volume, minPrice, avgPrice, maxPrice));
            }
        }
コード例 #6
0
        /// <summary>
        /// XML から Faction データを読み出す
        /// </summary>
        /// <returns>読み出した Faction データ</returns>
        private IEnumerable <Faction> GetRecords()
        {
            foreach (var faction in _FactionsXml.Root.XPathSelectElements("faction[@name]"))
            {
                var factionID = faction.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(factionID))
                {
                    continue;
                }

                var name = _Resolver.Resolve(faction.Attribute("name")?.Value ?? "");
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var raceID    = faction.Attribute("primaryrace")?.Value ?? "";
                var shortName = _Resolver.Resolve(faction.Attribute("shortname")?.Value ?? "");

                yield return(new Faction(factionID, name, raceID, shortName));
            }
        }
コード例 #7
0
        /// <summary>
        /// XML から WareGroup データを読み出す
        /// </summary>
        /// <returns>読み出した WareGroup データ</returns>
        internal IEnumerable <WareGroup> GetRecords()
        {
            foreach (var wareGroup in _WareGroupXml.Root.XPathSelectElements("group[@tags='tradable']"))
            {
                var wareGroupID = wareGroup.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(wareGroupID))
                {
                    continue;
                }

                var name = _Resolver.Resolve(wareGroup.Attribute("name")?.Value ?? "");
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var factoryName = _Resolver.Resolve(wareGroup.Attribute("factoryname")?.Value ?? "");
                var icon        = wareGroup.Attribute("icon")?.Value ?? "";
                var tier        = wareGroup.Attribute("tier")?.GetInt() ?? 0;

                yield return(new WareGroup(wareGroupID, name, factoryName, icon, tier));
            }
        }
コード例 #8
0
        /// <summary>
        /// EquipmentType データを読み出す
        /// </summary>
        /// <returns>EquipmentType データ</returns>
        private IEnumerable <EquipmentType> GetRecords()
        {
            // TODO: 可能ならファイルから抽出する
            yield return(new EquipmentType("countermeasures", _Resolver.Resolve("{20215, 1701}")));

            yield return(new EquipmentType("drones", _Resolver.Resolve("{20215, 1601}")));

            yield return(new EquipmentType("engines", _Resolver.Resolve("{20215, 1801}")));

            yield return(new EquipmentType("missiles", _Resolver.Resolve("{20215, 1901}")));

            yield return(new EquipmentType("shields", _Resolver.Resolve("{20215, 2001}")));

            yield return(new EquipmentType("software", _Resolver.Resolve("{20215, 2101}")));

            yield return(new EquipmentType("thrusters", _Resolver.Resolve("{20215, 2201}")));

            yield return(new EquipmentType("turrets", _Resolver.Resolve("{20215, 2301}")));

            yield return(new EquipmentType("weapons", _Resolver.Resolve("{20215, 2401}")));
        }
コード例 #9
0
        /// <summary>
        /// ModuleType データを読み出す
        /// </summary>
        /// <returns>EquipmentType データ</returns>
        private IEnumerable <ModuleType> GetRecords()
        {
            // TODO: 可能ならファイルから抽出する
            yield return(new ModuleType("buildmodule", _Resolver.Resolve("{20104,  69901}")));

            yield return(new ModuleType("connectionmodule", _Resolver.Resolve("{20104,  59901}")));

            yield return(new ModuleType("defencemodule", _Resolver.Resolve("{20104,  49901}")));

            yield return(new ModuleType("dockarea", _Resolver.Resolve("{20104,  70001}")));

            yield return(new ModuleType("habitation", _Resolver.Resolve("{20104,  39901}")));

            yield return(new ModuleType("pier", _Resolver.Resolve("{20104,  71101}")));

            yield return(new ModuleType("production", _Resolver.Resolve("{20104,  19901}")));

            yield return(new ModuleType("storage", _Resolver.Resolve("{20104,  29901}")));

            yield return(new ModuleType("ventureplatform", _Resolver.Resolve("{20104, 101901}")));
        }
コード例 #10
0
        /// <summary>
        /// XML から Module データを読み出す
        /// </summary>
        /// <returns>読み出した Module データ</returns>
        internal IEnumerable <Module> GetRecords()
        {
            foreach (var module in _WaresXml.Root.XPathSelectElements("ware[contains(@tags, 'module')]"))
            {
                var moduleID = module.Attribute("id").Value;
                if (string.IsNullOrEmpty(moduleID))
                {
                    continue;
                }

                var macroName = module.XPathSelectElement("component").Attribute("ref").Value;
                if (string.IsNullOrEmpty(macroName))
                {
                    continue;
                }

                var macroXml     = _CatFile.OpenIndexXml("index/macros.xml", macroName);
                var moduleTypeID = macroXml.Root.XPathSelectElement("macro").Attribute("class").Value;
                if (string.IsNullOrEmpty(moduleTypeID))
                {
                    continue;
                }

                // 従業員数/最大収容人数取得
                var workForce  = macroXml?.Root?.XPathSelectElement("macro/properties/workforce");
                var maxWorkers = workForce?.Attribute("max")?.GetInt() ?? 0;
                var capacity   = workForce?.Attribute("capacity")?.GetInt() ?? 0;

                var name = _Resolver.Resolve(module.Attribute("name")?.Value ?? "");
                name = string.IsNullOrEmpty(name) ? macroName : name;

                var noBluePrint = module.Attribute("tags").Value.Contains("noblueprint");

                yield return(new Module(moduleID, moduleTypeID, name, macroName, maxWorkers, capacity, noBluePrint));
            }
        }