Beispiel #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);
            }
        }
Beispiel #2
0
        public Section AddSectionFromData(int sectionid)
        {
            if (!DataMgr.Instacne.dic_Section.ContainsKey(sectionid))
            {
                LogTool.LogError("DataMgr not have id " + sectionid);
                return(null);
            }
            DSection   dsection = DataMgr.Instacne.dic_Section[sectionid];
            GameObject go       = new GameObject();

            go.transform.SetParent(sectionEntityParent);
            Section section = go.AddComponent <Section>();

            section.data = dsection;
            dic_Section.Add(section.ID, section);
            if (section.ID == DataMgr.Instacne.selSaveData.id_playerSection)
            {
                section.isPlayer = true;
            }
            return(section);
        }
Beispiel #3
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);
            }
        }