Пример #1
0
        }     //构造函数

        public lc_Object(lc_Object srcTag)
        {
            this.obj_id   = srcTag.obj_id;
            this.m_name   = srcTag.m_name;
            this.obj_type = srcTag.obj_type;
            this.m_desc   = srcTag.m_desc;
        }//拷贝构造函数
Пример #2
0
        } /*宗教删除规则*/

        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);
        } /*城市增加建筑*/
Пример #3
0
        } /*城市增加建筑*/

        public int CityDelBuilding(uint city_id, uint building_id)
        {
            uint        obj_id;
            int         typeint  = lc_ObjGather.GetRelNameMap("STU_CITY_BUILDING");
            lc_City     city     = GetObject <lc_City>(city_id);
            lc_Building building = GetObject <lc_Building>(building_id);

            if (city != null && building != null)
            {
                List <STU_CITY_BUILDING> stulist = objgather.GetAllRelShip <STU_CITY_BUILDING>(city_id);
                int index = stulist.FindIndex(delegate(STU_CITY_BUILDING temp) { return(temp.building_id == building_id); });
                if (index == -1)
                {
                    return(-1);
                }
                else
                {
                    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 = stulist[index].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);
                        stulist.RemoveAt(index);
                    }

                    return(1);
                }
            }
            else
            {
                return(-1);/*逻辑错误*/
            }
        }/*城市删除建筑*/