} /*宗教删除规则*/ public int CityAddBuilding(uint city_id, uint peo_id, uint building_id) { uint rel_belong; uint obj_id; int index = lc_ObjGather.GetRelNameMap("STU_CITY_BUILDING"); lc_City city = GetObject <lc_City>(city_id); lc_Building building = GetObject <lc_Building>(building_id); lc_Seer seer = GetObject <lc_Seer>(peo_id); if (peo_id != 0) { if (seer.m_wealth < building.m_cost) { return(0); } seer.m_wealth -= building.m_cost; } if (building.m_belong) { STU_PEO_REL stu_peo_rel = GetRelShip <STU_PEO_REL>(peo_id); rel_belong = stu_peo_rel.rel_id; } else { rel_belong = 0; } STU_CITY_BUILDING stu_city_build = new STU_CITY_BUILDING(city_id, building.obj_id, rel_belong); objgather.relship_list[index].Add(stu_city_build); foreach (var chgnum in building.chglist) { int typeindex = lc_ObjGather.GetObjNameMap(chgnum.objtype); switch (chgnum.objtype) { case "BUILDING": obj_id = building.obj_id; break; case "RELIGION": obj_id = stu_city_build.rel_belong_id; break; default: return(-1); } lc_Object obj = objgather.obj_list[typeindex].Find(delegate(lc_Object temp) { return(temp.obj_id == obj_id); }); obj.ChangeVar <int>(chgnum.varname, chgnum.chgnum); } return(1); } /*城市增加建筑*/
public int SetPeoRel(uint peo_id, uint rel_id, int rel_num) { int typeint = lc_ObjGather.GetRelNameMap("STU_PEO_REL"); int index = objgather.relship_list[typeint].FindIndex(delegate(STU_RELATION temp) { STU_PEO_REL substu = (STU_PEO_REL)temp; if (substu.peo_id == peo_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(rel_id, rel_num)); STU_PEO_REL stu = new STU_PEO_REL(peo_id, rel_id, list_rel_rat); objgather.relship_list[typeint].Add(stu); return((int)stu.relship_id); /*1-新增人物*/ } else { STU_PEO_REL substu = (STU_PEO_REL)objgather.relship_list[typeint][index]; int subindex = substu.rel_rat.FindIndex(delegate(SUBSTU_REL_RAT temp) { return(temp.rel_id == rel_id); }); if (index == -1) { substu.rel_rat.Add(new SUBSTU_REL_RAT(rel_id, rel_num)); return((int)substu.relship_id); /*新增宗教*/ } else { substu.rel_rat[subindex].rel_num += rel_num; if (substu.rel_rat[subindex].rel_num >= MAXRATNUM) { substu.rel_id = substu.rel_rat[subindex].rel_id; return((int)substu.relship_id);/*该人物信仰改变*/ } else { return((int)substu.relship_id); /*增加宗教偏好*/ } } } }
public STU_PEO_REL(STU_PEO_REL temp) : base(temp) { this.peo_id = temp.peo_id; this.rel_id = temp.rel_id; this.rel_rat = new List <SUBSTU_REL_RAT>(temp.rel_rat); }