Exemple #1
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();
        }
Exemple #2
0
        public Faction AddFactionFromData(int factionid)
        {
            if (!DataMgr.Instacne.dic_Faction.ContainsKey(factionid))
            {
                LogTool.LogError("DataMgr not have id " + factionid);
                return(null);
            }
            DFaction   dfaction = DataMgr.Instacne.dic_Faction[factionid];
            GameObject go       = new GameObject();

            go.transform.SetParent(factionEntityParent);
            Faction faction = go.AddComponent <Faction>();

            faction.Data = dfaction;
            dic_Faction.Add(faction.ID, faction);
            if (faction.ID == DataMgr.Instacne.selSaveData.id_playerFaction)
            {
                faction.isPlayer = true;
            }
            return(faction);
        }
Exemple #3
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);
        }
Exemple #4
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);
            }
        }