예제 #1
0
        private void LoadFaction(string fold)
        {
            string filePath = fold + "/faction.csv";

            factionFile = new CSVFile();
            factionFile.ReadCsv(filePath);
            dic_Faction.Clear();
            foreach (string[] arr in factionFile.valueLines)
            {
                if (arr.Length != 7)
                {
                    LogTool.LogError("faction arr.length" + arr.Length);
                    continue;
                }
                DFaction faction = new DFaction();
                faction.id             = int.Parse(arr[0]);
                faction.alias          = arr[1];
                faction.shortdesc      = arr[2];
                faction.fulldesc       = arr[3];
                faction.id_leadperson  = int.Parse(arr[4]);
                faction.idlist_section = CommonUtil.StringToListInt(arr[5], '#'); //只保存一级子类
                foreach (int sectionid in faction.idlist_section)                 //子对象的一级父类在这初始化
                {
                    if (sectionid != -1 && dic_Section.ContainsKey(sectionid))
                    {
                        DSection section = dic_Section[sectionid];
                        section.parentid_faction = faction.id;
                    }
                }
                faction.idlist_wbuilding = CommonUtil.StringToListInt(arr[6], '#');
                dic_Faction.Add(faction.id, faction);
                EntityMgr.Instacne.AddFactionFromData(faction.id);
            }
        }
예제 #2
0
        public bool hasInitAllData = false;// 初始化基础数据
        private IEnumerator LoadEsscentialData()
        {
            //首先加载不可变更数据
            LoadTroopType();
            yield return(null);

            string filePath = PathTool.DataFileRootFold + "/save/save.csv";

            saveFile = new CSVFile();
            saveFile.ReadCsv(filePath);
            dic_Save.Clear();
            foreach (string[] arr in saveFile.valueLines)
            {
                if (arr.Length != 12)
                {
                    continue;
                }
                DSaveData savedata = new DSaveData();
                savedata.id               = int.Parse(arr[0]);
                savedata.alias            = arr[1];
                savedata.shortdesc        = arr[2];
                savedata.fulldesc         = arr[3];
                savedata.id_playerFaction = int.Parse(arr[4]);
                savedata.id_playerSection = int.Parse(arr[5]);
                savedata.year             = int.Parse(arr[6]);
                savedata.month            = int.Parse(arr[7]);
                savedata.day              = int.Parse(arr[8]);
                savedata.season           = int.Parse(arr[9]);
                savedata.savetime         = arr[10];
                savedata.subfold          = arr[11];
                dic_Save.Add(savedata.id, savedata);
            }
            yield return(null);

            filePath      = PathTool.DataFileRootFold + "/scenerial/scenerial.csv";
            scenerialFile = new CSVFile();
            scenerialFile.ReadCsv(filePath);
            dic_Scenerial.Clear();
            foreach (string[] arr in scenerialFile.valueLines)
            {
                if (arr.Length != 9)
                {
                    continue;
                }
                DScenerialData scedata = new DScenerialData();
                scedata.id        = int.Parse(arr[0]);
                scedata.alias     = arr[1];
                scedata.shortdesc = arr[2];
                scedata.fulldesc  = arr[3];
                scedata.year      = int.Parse(arr[4]);
                scedata.month     = int.Parse(arr[5]);
                scedata.day       = int.Parse(arr[6]);
                scedata.season    = int.Parse(arr[7]);
                scedata.subfold   = arr[8];
                dic_Scenerial.Add(scedata.id, scedata);
            }
            yield return(null);

            hasInitAllData = true;
        }
예제 #3
0
        private void LoadTroopType()
        {
            string filePath = PathTool.DataFileRootFold + "/common/trooptype.csv";

            troopTypeFile = new CSVFile();
            troopTypeFile.ReadCsv(filePath);
            dic_TroopType.Clear();
            foreach (string[] arr in troopTypeFile.valueLines)
            {
                if (arr.Length != 10)
                {
                    continue;
                }
                DTroopType troopType = new DTroopType();
                troopType.id                 = int.Parse(arr[0]);
                troopType.alias              = arr[1];
                troopType.shortdesc          = arr[2];
                troopType.fulldesc           = arr[3];
                troopType.baseatk            = int.Parse(arr[4]);
                troopType.basedef            = int.Parse(arr[5]);
                troopType.baseremoteatkrange = int.Parse(arr[6]);
                troopType.basemovespeed      = float.Parse(arr[7]);
                troopType.baseatkfrequency   = float.Parse(arr[8]);
                troopType.resid              = int.Parse(arr[9]);
                dic_TroopType.Add(troopType.id, troopType);
            }
        }
예제 #4
0
        private IEnumerator LoadResData()
        {
            string filePath = PathTool.DataFileRootFold + "/common/Res.csv";

            resCsvfile = new CSVFile();
            resCsvfile.ReadCsv(filePath);
            foreach (string[] arr in resCsvfile.valueLines)
            {
                if (arr.Length != 7)
                {
                    continue;
                }
                int      id           = int.Parse(arr[0]);
                string   alias        = arr[1];
                EResType type         = (EResType)int.Parse(arr[2]);
                bool     inInspector  = bool.Parse(arr[3]);
                string   respath      = arr[4]; // Resouce.load 时路径
                string   bundlepath   = arr[5];
                string   inbundlepath = arr[6];
                if (inInspector)
                {
                    continue;             //已经在Inspector,不需要加载
                }
            }
            hasInitAllData = true;
            yield return(null);
        }
예제 #5
0
        private void LoadPerson(string fold)
        {
            string filePath = fold + "/person.csv";

            personFile = new CSVFile();
            personFile.ReadCsv(filePath);
            dic_Person.Clear();
            foreach (string[] arr in cityFile.valueLines)
            {
                if (arr.Length != 16)
                {
                    LogTool.LogError("city arr.length" + arr.Length);
                    continue;
                }
                DPerson person = new DPerson();
                person.id           = int.Parse(arr[0]);
                person.alias        = arr[1];
                person.shortdesc    = arr[2];
                person.fulldesc     = arr[3];
                person.firstname    = arr[4];
                person.secondname   = arr[5];
                person.thirdname    = arr[6];
                person.bornyear     = int.Parse(arr[7]);
                person.bornmonth    = int.Parse(arr[8]);
                person.bornday      = int.Parse(arr[9]);
                person.isfreeperson = bool.Parse(arr[10]);
                person.isprison     = bool.Parse(arr[11]);
                person.canhire      = bool.Parse(arr[12]);
                person.curleftexp   = int.Parse(arr[13]);

                person.tong = int.Parse(arr[14]);
                person.wu   = int.Parse(arr[15]);
                person.zhi  = int.Parse(arr[16]);
                person.zhen = int.Parse(arr[17]);
                person.mei  = int.Parse(arr[18]);

                person.level_bubing    = int.Parse(arr[19]);
                person.level_qibing    = int.Parse(arr[20]);
                person.level_gongbing  = int.Parse(arr[21]);
                person.level_shuibing  = int.Parse(arr[22]);
                person.level_gongcheng = int.Parse(arr[23]);
                dic_Person.Add(person.id, person);
                EntityMgr.Instacne.AddPersonFromData(person.id);
            }
        }
예제 #6
0
        private void LoadCity(string fold)
        {
            string filePath = fold + "/city.csv";

            cityFile = new CSVFile();
            cityFile.ReadCsv(filePath);
            dic_City.Clear();
            foreach (string[] arr in cityFile.valueLines)
            {
                if (arr.Length != 16)
                {
                    LogTool.LogError("city arr.length" + arr.Length);
                    continue;
                }
                DCityBuilding city = new DCityBuilding();
                city.id                 = int.Parse(arr[0]);
                city.alias              = arr[1];
                city.shortdesc          = arr[2];
                city.fulldesc           = arr[3];
                city.food               = int.Parse(arr[4]);
                city.money              = int.Parse(arr[5]);
                city.population         = int.Parse(arr[6]);
                city.curhp              = int.Parse(arr[7]);
                city.curtotalsoldiernum = int.Parse(arr[8]);
                city.mingxin            = int.Parse(arr[9]);
                city.zhian              = int.Parse(arr[10]);
                city.id_leadperson      = int.Parse(arr[11]);
                city.idlist_pbuilding   = CommonUtil.StringToListInt(arr[12], '#');
                city.idlist_troop       = CommonUtil.StringToListInt(arr[13], '#'); //只保存一级子类
                foreach (int troopid in city.idlist_troop)                          //子对象的一级父类在这初始化
                {
                    if (troopid != -1 && dic_Troop.ContainsKey(troopid))
                    {
                        DTroop troop = DataMgr.Instacne.dic_Troop[troopid];
                        troop.parentid_city = city.id;
                    }
                }
                city.idlist_person     = CommonUtil.StringToListInt(arr[14], '#');
                city.idlist_freeperson = CommonUtil.StringToListInt(arr[15], '#');
                dic_City.Add(city.id, city);
            }
            EntityMgr.Instacne.InitAllCityData();
        }
예제 #7
0
        private void LoadSection(string fold)
        {
            string filePath = fold + "/section.csv";

            sectionFile = new CSVFile();
            sectionFile.ReadCsv(filePath);
            dic_Section.Clear();
            foreach (string[] arr in sectionFile.valueLines)
            {
                if (arr.Length != 6)
                {
                    LogTool.LogError("section arr.length" + arr.Length);
                    continue;
                }
                DSection dsection = new DSection();
                dsection.id            = int.Parse(arr[0]);
                dsection.alias         = arr[1];
                dsection.shortdesc     = arr[2];
                dsection.fulldesc      = arr[3];
                dsection.id_leadperson = int.Parse(arr[4]);
                dsection.idlist_city   = CommonUtil.StringToListInt(arr[5], '#'); //只保存一级子类
                foreach (int cityid in dsection.idlist_city)                      //子对象的一级父类在这初始化
                {
                    if (cityid != -1 && dic_City.ContainsKey(cityid))
                    {
                        DCityBuilding city = dic_City[cityid];
                        city.parentid_section = dsection.id;
                    }
                    else
                    {
                        LogTool.LogError("can not find city id" + cityid);
                    }
                }
                dic_Section.Add(dsection.id, dsection);
                EntityMgr.Instacne.AddSectionFromData(dsection.id);
            }
        }