Example #1
0
        public uint SetCityRel(uint city_id, uint rel_id, int rel_num)
        {
            int typeint = lc_ObjGather.GetRelNameMap("STU_CITY_INF");
            int index   = objgather.relship_list[typeint].FindIndex(delegate(STU_RELATION temp) {
                STU_CITY_INF substu = (STU_CITY_INF)temp;
                if (substu.city_id == city_id)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (index != -1)
            {
                STU_CITY_INF stu      = (STU_CITY_INF)objgather.relship_list[typeint][index];
                int          subindex = stu.rel_rat.FindIndex(delegate(SUBSTU_REL_RAT temp) { return(temp.rel_id == rel_id); });
                if (subindex == -1)
                {
                    SUBSTU_REL_RAT substu = new SUBSTU_REL_RAT(rel_id, rel_num);
                    stu.rel_rat.Add(substu);
                    return(stu.relship_id);
                }
                else
                {
                    stu.rel_rat[subindex].rel_num += rel_num;
                    return(stu.relship_id);
                }
            }
            return(0);
        }
Example #2
0
        //public uint AddSeer(string name, int age, int life, uint rel_id) {
        //    lc_People peo = new lc_Seer(name, age, life);
        //    obj_list[(int)LISTTYPE.PEOLIST].Add(peo);
        //    gameRel.SetPeoRel(peo.obj_id, rel_id, 100);
        //    return peo.obj_id;
        //} /*新增预言家*/
        //public uint AddPerson(string name, int age, int life, uint country_id, uint pro_id) {
        //    lc_Personality peo = new lc_Personality(name, age, life);
        //    peo.belong_cty = country_id; //设置国家
        //    peo.m_profession = pro_id; //设置职业
        //    obj_list[(int)LISTTYPE.PEOLIST].Add(peo);
        //    gameRel.SetPeoRel(peo.obj_id, lc_ObjRel.DEFREL, 0); //设置默认信仰
        //    return peo.obj_id;
        //} /*新增名人*/
        //public uint AddRel(string name) {
        //    lc_Religion rel = new lc_Religion(name);
        //    obj_list[(int)LISTTYPE.RELLIST].Add(rel);
        //    return rel.obj_id;
        //} /*新增宗教*/
        //public uint AddCity(string name, int map_id, int city_peonum, uint country_id) {
        //    lc_City city = new lc_City(name, map_id);
        //    obj_list[(int)LISTTYPE.CITYLIST].Add(city);
        //    //创建默认城市关系
        //    gameRel.SetCityPeoNum(city.obj_id, city_peonum);
        //    gameRel.setCiytBel(city.obj_id, country_id);
        //    return city.obj_id;
        //} /*新增城市*/
        //public uint AddCountry(string name) {
        //    lc_Country country = new lc_Country(name);
        //    obj_list[(int)LISTTYPE.COUNTRYLIST].Add(country);
        //    return country.obj_id;
        //} /*新增国家*/
        //public uint AddCanon(string name, int theorypt_num, VarChg[] invarchg) {
        //    lc_Canon canon = new lc_Canon(name, theorypt_num, invarchg);
        //    obj_list[(int)LISTTYPE.CANONLIST].Add(canon);
        //    return canon.obj_id;
        //} /*新增教规*/
        //public uint AddBuilding(string name, int cost, VarChg[] invarchg) {
        //    lc_Building building = new lc_Building(name, cost, invarchg);
        //    obj_list[(int)LISTTYPE.BUILDINGLIST].Add(building);
        //    return building.obj_id;
        //} /*新增建筑*/



        //查询对象
        //public lc_People GetPeo(uint obj_id) {
        //    int index = obj_list[(int)LISTTYPE.PEOLIST].FindIndex(delegate (lc_Object temp) { return temp.obj_id == obj_id; });
        //    if (index == -1) return null;
        //    else return (lc_People)obj_list[(int)LISTTYPE.PEOLIST][index];
        //}
        //public lc_Religion GetRel(uint obj_id) {
        //    int index = obj_list[(int)LISTTYPE.RELLIST].FindIndex(delegate (lc_Object temp) { return temp.obj_id == obj_id; });
        //    if (index == -1) return null;
        //    else return (lc_Religion)obj_list[(int)LISTTYPE.RELLIST][index];
        //}
        //public lc_City GetCity(uint obj_id) {
        //    int index = obj_list[(int)LISTTYPE.CITYLIST].FindIndex(delegate (lc_Object temp) { return temp.obj_id == obj_id; });
        //    if (index == -1) return null;
        //    else return (lc_City)obj_list[(int)LISTTYPE.CITYLIST][index];
        //}
        //public lc_Country GetCountry(uint obj_id) {
        //    int index = obj_list[(int)LISTTYPE.COUNTRYLIST].FindIndex(delegate (lc_Object temp) { return temp.obj_id == obj_id; });
        //    if (index == -1) return null;
        //    else return (lc_Country)obj_list[(int)LISTTYPE.COUNTRYLIST][index];
        //}
        //public lc_Canon GetCanon(uint obj_id) {
        //    int index = obj_list[(int)LISTTYPE.CANONLIST].FindIndex(delegate (lc_Object temp) { return temp.obj_id == obj_id; });
        //    if (index == -1) return null;
        //    else return (lc_Canon)obj_list[(int)LISTTYPE.CANONLIST][index];
        //}
        //public lc_Building GetBuilding(uint obj_id) {
        //    int index = obj_list[(int)LISTTYPE.BUILDINGLIST].FindIndex(delegate (lc_Object temp) { return temp.obj_id == obj_id; });
        //    if (index == -1) return null;
        //    else return (lc_Building)obj_list[(int)LISTTYPE.BUILDINGLIST][index];
        //}

        //查询教派总人数
        public int GetRelCount(uint rel_id)
        {
            int count   = 0;
            int typeint = lc_ObjGather.GetRelNameMap("STU_CITY_INF");

            for (int i = 0; i < relship_list[typeint].Count; i++)
            {
                STU_CITY_INF stu = (STU_CITY_INF)relship_list[typeint][i];
                count += stu.GetRelNum(rel_id);
            }
            return(count);
        }//查询教派总人数
Example #3
0
        public uint SetCityRelNum(uint city_id, int city_peonum)
        {
            int typeint = lc_ObjGather.GetRelNameMap("STU_CITY_INF");
            int index   = objgather.relship_list[typeint].FindIndex(delegate(STU_RELATION temp) {
                STU_CITY_INF substu = (STU_CITY_INF)temp;
                if (substu.city_id == city_id)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (index == -1)
            {
                List <SUBSTU_REL_RAT> list_rel_rat = new List <SUBSTU_REL_RAT>();
                list_rel_rat.Add(new SUBSTU_REL_RAT(DEFREL, city_peonum));
                STU_CITY_INF stu = new STU_CITY_INF(city_id, city_peonum, list_rel_rat);
                objgather.relship_list[typeint].Add(stu);
                return(stu.relship_id);
            }
            else   //调整每个子模块数量
            {
                STU_CITY_INF substu     = (STU_CITY_INF)objgather.relship_list[typeint][index];
                int          old_num    = substu.city_peonum;
                int          chg_sumnum = old_num - city_peonum;
                if (chg_sumnum < 0)
                {
                    int defindex    = substu.rel_rat.FindIndex(delegate(SUBSTU_REL_RAT temp) { return(temp.rel_id == DEFREL); });
                    int old_rel_num = substu.rel_rat[defindex].rel_num;
                    substu.rel_rat[defindex].rel_num = old_rel_num + System.Math.Abs(chg_sumnum);
                }
                else if (chg_sumnum > 0)
                {
                    int sumnum = substu.rel_rat.Sum(delegate(SUBSTU_REL_RAT temp) { return(temp.rel_num); });
                    for (int i = 0; i < substu.rel_rat.Count(); i++)
                    {
                        int old_rel_num = substu.rel_rat[i].rel_num;

                        substu.rel_rat[i].rel_num = old_rel_num - (int)(chg_sumnum * ((float)old_rel_num / sumnum));
                    }
                }
                else
                {
                }

                substu.city_peonum = city_peonum;
                return(substu.relship_id);
            }
        }
Example #4
0
 public STU_CITY_INF(STU_CITY_INF temp) : base(temp)
 {
     this.city_id     = temp.city_id;
     this.city_peonum = temp.city_peonum;
     this.rel_rat     = new List <SUBSTU_REL_RAT>(temp.rel_rat);
 }