Example #1
0
 public DTroop AddNewTroopData(int trooptypeid, int personid1, int personid2, int personid3)
 {
     if (dic_TroopType.ContainsKey(trooptypeid))
     {
         DTroop troop = new DTroop();
         int    id    = 1;
         for (int i = 1; i < 9999; i++)
         {
             if (dic_Troop.ContainsKey(i))
             {
                 id = i;
             }
         }
         troop.id           = id;
         troop.id_trooptype = trooptypeid;
         troop.id_person1   = personid1;
         troop.id_person2   = personid2;
         troop.id_person3   = personid3;
         dic_Troop.Add(id, troop);
         return(troop);
     }
     else
     {
         LogTool.LogError("can not find typeid" + trooptypeid);
         return(null);
     }
 }
Example #2
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);
            }
        }
Example #3
0
 public bool LoadSaveData(int id)
 {
     dataPrepared = false;
     if (dic_Save.ContainsKey(id))
     {
         selSaveData = dic_Save[id];
         string fold = PathTool.DataFileRootFold + "/save/" + selSaveData.subfold;
         StartCoroutine(LoadSaveData(fold));
         return(true);
     }
     else
     {
         loadPercent = 0;
         LogTool.LogError("can not find save id" + id);
         return(false);
     }
 }
Example #4
0
        public Person AddPersonFromData(int personid)
        {
            if (!DataMgr.Instacne.dic_Person.ContainsKey(personid))
            {
                LogTool.LogError("DataMgr not have id " + personid);
                return(null);
            }
            DPerson    dfaction = DataMgr.Instacne.dic_Person[personid];
            GameObject go       = new GameObject("person_" + personid);

            go.transform.SetParent(personEntityParent);
            Person person = go.AddComponent <Person>();

            person.Data = dfaction;
            dic_Person.Add(person.ID, person);
            return(person);
        }
Example #5
0
 //City 不建议new ,建议直接固定在场景当中,位置也不会变,所以只能初始化数据.而且不能摧毁
 public void  InitAllCityData()
 {
     CityBuilding[] cities = cityEntityParent.GetComponentsInChildren <CityBuilding>();
     foreach (CityBuilding city in cities)
     {
         if (DataMgr.Instacne.dic_City.ContainsKey(city.initid))
         {
             city.Data = DataMgr.Instacne.dic_City[city.initid];
             dic_City.Add(city.ID, city);
             HudMgr.Instacne.AddHudCity(city.ID);
         }
         else
         {
             LogTool.LogError("DataMgr not have id " + city.initid);
         }
     }
 }
Example #6
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);
            }
        }
Example #7
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();
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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);
            }
        }