Ejemplo n.º 1
0
        /// <summary>
        ///根据本地文件解析出能使用的NPC公司数据
        /// </summary>
        public static void ReadAndParseNpcCorpGroup()
        {
            var @default = YamlTools.Read <Dictionary <int, NpcCorporations> >("Resources/npcCorporations.yaml");

            //YamlFilter.NpcCorporations(@default, out var @new);
            FPS.FileReader.Read("Resources/npcCorporations.txt", out string contents);

            // 反转字典,用于反向构造映射关系
            Dictionary <string, int> @neww = new Dictionary <string, int>();

            foreach (var n in @default)
            {
                if ([email protected](n.Value.nameID.zh))
                {
                    @neww.Add(n.Value.nameID.zh, n.Key);
                }
            }

            var strs = contents.Split('\n');
            Dictionary <int, NewNpcCorporations> tmncc = new Dictionary <int, NewNpcCorporations>();
            List <TmpNc> tmncs = new List <TmpNc>();
            // nc用来存txt解析出来的数据
            // ncc用来构造新模板实例
            bool title      = true;
            int  tmncsIndex = 0;

            for (int i = 0; i < strs.Length; i++)
            {
                var name = strs[i].Replace("\r", "");
                if (title)
                {
                    title = false;
                    tmncs.Add(new TmpNc(name));
                    continue;
                }

                if (name.Contains("//"))
                {
                    title = true;
                    tmncsIndex++;
                    continue;
                }
                tmncs[tmncsIndex].AddSub(name, 0);
            }
            int tmnccIndex = 0;

            foreach (var n in tmncs)
            {
                var tmnc = new NewNpcCorporations(tmnccIndex, n.name);
                tmncc.Add(tmnccIndex, tmnc);
                foreach (var n1 in n.subs)
                {
                    @neww.TryGetValue(n1.Key, out int id);
                    tmnc.AddSub(new NewNpcCorporations(id, n1.Key));
                }
                tmnccIndex++;
            }

            YamlTools.Write(tmncc, "Resources/newNpcCorporations.yaml");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 本地配置文件修改翻译,typeIDs
 /// </summary>
 public static void ReadYaml_FilterToNewTypeID()
 {
     try
     {
         var @default = YamlTools.Read <Dictionary <int, TypeID> >("Resources/typeIDs.yaml");
         System.Windows.MessageBox.Show(@default.Count.ToString());
         YamlFilter.TypeIDs(@default, out var @new);
         YamlTools.Write(@new, "Resources/newTypeIDs.yaml");
     }
     catch (Exception e)
     {
         System.Windows.MessageBox.Show(e.Message);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 写星域星系,只负责主要的
        /// </summary>
        public static void WriteYaml_RegionGalaxy()
        {
            Dictionary <int, Galaxy> gxyFuerge = new Dictionary <int, Galaxy>
            {
                { 30000142, new Galaxy(30000142, "吉他") },
                { 30000144, new Galaxy(30000144, "皮尔米特") }
            };

            Dictionary <int, Galaxy> gxyDelve = new Dictionary <int, Galaxy>
            {
                { 30004759, new Galaxy(30004759, "1DQ-A") }
            };


            List <Region> regions = new List <Region>()
            {
                { new Region(10000002, "伏尔戈", gxyFuerge) },
                { new Region(10000060, "绝地之域", gxyDelve) }
            };

            YamlTools.Write(regions, "Resources/regionGalaxy.yaml");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 本地配置文件修改翻译,蓝图消耗
        /// </summary>
        public static void ReadYaml_FilterToNewBlueprints()
        {
            // 读取原始数据
            // 一级原始数据解析,反向产物存储,由蓝图ID key->实例 ,构造二级字典,produce-.实例,这个过程中实例引用不变,最佳新字典存储
            // 由正向字典数据,consumer追加蓝图实例,作为子节点实例,构造新树,保存新的实例
            // 读取解析
            try
            {
                var db       = LocalConfigLoadManager.GetConfigClass <TypeIDDBClass>();
                var @default = YamlTools.Read <Dictionary <int, Buleprints> >("Resources/blueprints.yaml");
                Dictionary <int, Buleprints> productsR = new Dictionary <int, Buleprints>(); // 反转产出与蓝图
                foreach (var blue in @default)
                {
                    if (blue.Value.activities.manufacturing != null)
                    {
                        if (db.TypeIDs.ContainsKey(blue.Key))
                        {
                            var id = blue.Value.activities.manufacturing.products[0].typeID;
                            if (db.TryGet(id, out NewTypeID value))
                            {
                                if (!productsR.ContainsKey(id))
                                {
                                    productsR.Add(id, blue.Value);
                                }
                            }
                        }
                    }
                }

                Dictionary <int, NewBuleprints> @new = new Dictionary <int, NewBuleprints>();
                foreach (var blue in productsR.Values)
                {
                    var manufact = blue.activities.manufacturing;

                    if (manufact == null)
                    {
                        continue;
                    }
                    NewBuleprints nb = new NewBuleprints();
                    nb.costProduct     = new List <Products>();
                    nb.costProductMap  = new List <int>();
                    nb.costmineral     = new List <Products>();
                    nb.product         = new Products();
                    nb.product.id      = manufact.products[0].typeID;
                    nb.product.count   = manufact.products[0].quantity;
                    nb.blueprintTypeID = blue.blueprintTypeID;
                    db.TryGet(nb.product.id, out string pname);
                    nb.product.name = pname;
                    db.TryGet(nb.blueprintTypeID, out string bname);
                    nb.name = bname;
                    if (manufact.materials == null)
                    {
                        @new.Add(blue.blueprintTypeID, nb);
                        continue;
                    }

                    foreach (var co in manufact.materials)
                    {
                        db.TryGet(co.typeID, out string cname);

                        productsR.TryGetValue(co.typeID, out var bp);
                        // 这里需要注意一点,有些原材料是矿石,需要单独处理
                        if (bp == null)
                        {
                            nb.costmineral.Add(new Products(co.typeID, cname, co.quantity));
                        }
                        else
                        {
                            nb.costProduct.Add(new Products(co.typeID, cname, co.quantity));
                            nb.costProductMap.Add(bp.blueprintTypeID);
                        }
                    }
                    @new.Add(blue.blueprintTypeID, nb);
                }

                System.Windows.MessageBox.Show(@new.Count.ToString());

                YamlTools.Write(@new, "Resources/newBlueprints.yaml");
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message);
            }
        }