예제 #1
0
        public game_err_code _init_pvp(round_conf pvp_conf, long cur_tm_s)
        {
            ghost_cnt = 0;
            death_match = false;
            death_hold_map = 0;
            preptm = 0;
            rnk_batl = false;

            //this.sgplayersbyside = {};
            //this.sgplayerside_bycid = {};
            //this.sides_conf = null;

            //this.clansideid_ary = [];
            this.kmfin = new Dictionary<int, SceneTest.kmfin>();
            //this.kmfinbyside = {            };
            this.ptfinbyside = new Dictionary<int, SceneTest.ptfinbyside>();
            this.maxptside = -1;
            this.death_pts = new Dictionary<int, Death_Pt>();
            this.death_ptconf = null;
            //this.kumiteply = null;
            //this.kumite_conf = null;
            //this.kumitefight_ply = null;
            //this.kumite_waittm = 0;
            //this.cltwar = null;
            //this.clcqwar = null;

            //this.kprec = {
            //};
            //this.kpboard = [];

            //this.camp_side = {
            //};

            var linfo = Level.get_lvl_info(llid);
            if (linfo == null)
            {
                this.fin();
                return game_err_code.INTERNAL_ERR;
            }

            if (pvp_conf.side.Count > 0)
            {
                // 分阵营pvp副本

                // 初始化阵营
                foreach (var sideconf in pvp_conf.side)
                {
                    if (sideconf.born == null)
                    {
                        Utility.trace_err("sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] side [" + sideconf.id + "] without born!\n");

                        this.fin();
                        return game_err_code.CONFIG_ERR;
                    }

                    if (!this.sgplayersbyside.ContainsKey(sideconf.id))
                        this.sgplayersbyside[sideconf.id] = new Dictionary<int, IBaseUnit>();

                    //    if ("fin_check" in sideconf)
                    //{
                    //        if ("km" in sideconf.fin_check[0])
                    //    {
                    //            local kmside = { };
                    //            foreach (km in sideconf.fin_check[0].km)
                    //            {
                    //                kmside[km.mid] < - { cntleft = km.cnt};
                    //            }
                    //            this.kmfinbyside[sideconf.id] < -kmside;
                    //        }
                    //    else if ("pt" in sideconf.fin_check[0])
                    //    {
                    //            this.ptfinbyside[sideconf.id] < - { pt = 0, maxpt = sideconf.fin_check[0].pt};
                    //        }
                    //    }

                    //    if ("clan" in this.lvl_conf)
                    //{
                    //        this.clansideid_ary.push(sideconf.id);
                    //    }

                    //    if ("camp" in sideconf)
                    //{
                    //        this.camp_side[sideconf.camp] < -sideconf.id; // 按世界阵营分边
                    //    }
                    //}
                    this.sides_conf = pvp_conf.side;
                }
            }
            else if (pvp_conf.death_pt != null)
            {
                // 混战积分模式pvp副本
                this.death_pts = new Dictionary<int, Death_Pt>();
                this.death_ptconf = pvp_conf.death_pt;
                this.preptm = cur_tm_s + this.death_ptconf.preptm;
            }
            else if (pvp_conf.death_match != null)
            {
                // 死亡竞赛模式pvp副本
                var death_match_conf = pvp_conf.death_match;

                this.ghost_cnt = death_match_conf.die2ghost;
                this.death_match = true;
                this.preptm = cur_tm_s + death_match_conf.preptm;

                //foreach(cid, ply in this.sgplayersbycid)
                //{
                //    this.ghost_players[cid] <- ghost_cnt;
                //}

                if (death_match_conf.side.Count > 0)
                {
                    foreach (var sideconf in death_match_conf.side)
                    {
                        if (sideconf.born == null)
                        {
                            Utility.trace_err("sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] death_match side [" + sideconf.id + "] without born!\n");

                            this.fin();
                            return game_err_code.CONFIG_ERR;
                        }

                        if (!this.sgplayersbyside.ContainsKey(sideconf.id))

                            this.sgplayersbyside[sideconf.id] = new Dictionary<int, IBaseUnit>();
                    }

                    this.sides_conf = death_match_conf.side;
                }
            }
            //    else if ("death_hold_map" in pvp_conf )
            //{
            //        // 死亡占地图模式pvp副本
            //        local death_hold_map_conf = pvp_conf.death_hold_map[0];

            //        this.death_hold_map = death_hold_map_conf.mapid;
            //        this.preptm = cur_tm_s + death_hold_map_conf.preptm;

            //        if (("side" in death_hold_map_conf) && death_hold_map_conf.side.len() > 0)
            //    {
            //            foreach (sideconf in death_hold_map_conf.side)
            //            {
            //                if (!("born" in sideconf))
            //            {
            //                    sys.trace(sys.SLT_ERR, "sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] death_match side [" + sideconf.id + "] without born!\n");

            //                    this.fin();
            //                    return game_err_code.CONFIG_ERR;
            //                }

            //                if (!(sideconf.id in this.sgplayersbyside))
            //            {
            //                    this.sgplayersbyside[sideconf.id] < - { };
            //                }
            //            }

            //            this.sides_conf = death_hold_map_conf.side;
            //        }
            //    }
            //    else if ("kumite" in pvp_conf)
            //{
            //        // 车轮战模式
            //        kumite_conf = pvp_conf.kumite[0];
            //        kumiteply = [];
            //        kumitefight_ply = { };
            //        this.kumite_waittm = cur_tm_s + kumite_conf.waittm;
            //        this.preptm = this.end_tm; // 人数未满最低开始人数前,一直是准备时间
            //    }
            //else if ("cltwar" in pvp_conf)
            //{
            //        // 帮派领地争夺战
            //        local cltwar_conf = pvp_conf.cltwar[0];

            //        if (!("cltwarid" in lvl_conf))
            //    {
            //            sys.trace(sys.SLT_ERR, "sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] cltwar level without cltwarid!\n");

            //            this.fin();
            //            return game_err_code.CONFIG_ERR;
            //        }

            //        local clantrit_conf = get_clantrit_conf(lvl_conf.cltwarid);
            //        if (!clantrit_conf)
            //        {
            //            sys.trace(sys.SLT_ERR, "sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] cltwarid[" + lvl_conf.cltwarid + "] config not exist!\n");

            //            this.fin();
            //            return game_err_code.CONFIG_ERR;
            //        }

            //        foreach (sideconf in cltwar_conf.side)
            //        {
            //            if (!("born" in sideconf))
            //        {
            //                sys.trace(sys.SLT_ERR, "sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] cltwar_conf side [" + sideconf.id + "] without born!\n");

            //                this.fin();
            //                return game_err_code.CONFIG_ERR;
            //            }

            //            if (!(sideconf.id in this.sgplayersbyside))
            //        {
            //                this.sgplayersbyside[sideconf.id] < - { };
            //            }
            //        }

            //        this.sides_conf = cltwar_conf.side;
            //        this.preptm = cur_tm_s + cltwar_conf.preptm;

            //        this.cltwar = {
            //            atkside = cltwar_conf.atkside, 
            //         defside = cltwar_conf.defside, ptmon = cltwar_conf.ptmon, ptper = cltwar_conf.ptper,
            //        clanpts ={ }, plypts ={ }, max_clanid = 0, max_clanpt = 0, owner_clanid = 0 };


            //        if ("tar_mid" in cltwar_conf )
            //    {
            //            this.cltwar.kmfin < - { tar_mid = cltwar_conf.tar_mid, cntleft = cltwar_conf.tar_mon_cnt};
            //        }
            //    else if ("hold_map" in cltwar_conf )
            //    {
            //            if (!is_map_exist(cltwar_conf.hold_map))
            //            {
            //                sys.trace(sys.SLT_ERR, "sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] cltwar_conf hold_map [" + cltwar_conf.hold_map + "], map not exist!\n");
            //                this.fin();

            //                return game_err_code.CONFIG_ERR;
            //            }
            //            this.cltwar.hold_map < - { mapid = cltwar_conf.hold_map, hold_clan = 0 };
            //        }

            //        //统计消耗
            //        if ("stastic_cost" in clantrit_conf )
            //    {
            //            local stastic_cost_conf = clantrit_conf.stastic_cost[0];
            //            _init_stastic_lvl_cost(stastic_cost_conf.init_yb, stastic_cost_conf.init_gld);
            //        }

            //        local mon_hp_per_data = null;
            //        local glbdata_mgr = global_data_mgrs.glbdata;
            //        glbdata_mgr.lock_data(db_glbdata_datatype.DBGDT_CLAN_TER, server_const.GLOBAL_DATA_LOCK_TM); // 锁定数据对象,注意,所有跳出函数代码分支必须要有unlock
            //        local gld_clanter_data = _get_clanter_data();
            //        if (gld_clanter_data)
            //        {
            //            local glb_clanter_info = gld_clanter_data.get_data();
            //            if (lvl_conf.cltwarid in glb_clanter_info.data)
            //        {
            //                local clanter_info = glb_clanter_info.data[lvl_conf.cltwarid];
            //                this.cltwar.owner_clanid = clanter_info.clanid;

            //                clanter_info.onwar = true; // 标记该帮派领地开始争夺
            //                                           //消除 消耗
            //                if ("stastic_cost" in clanter_info )
            //            {
            //                    delete clanter_info.stastic_cost;
            //                }
            //                if ("mon_hp_per" in clanter_info )
            //            {
            //                    mon_hp_per_data = clanter_info.mon_hp_per;
            //                    delete clanter_info.mon_hp_per;
            //                }
            //            }
            //        else
            //        {
            //                glb_clanter_info.data[lvl_conf.cltwarid] < - { crttm = cur_tm_s, showinfo =[], clanid = 0, onwar = true };
            //            }
            //            gld_clanter_data.mod_data(glb_clanter_info); // 同步至全局管理器
            //        }
            //        glbdata_mgr.unlock_data(db_glbdata_datatype.DBGDT_CLAN_TER);  // 解锁

            //        if (this.cltwar.owner_clanid > 0)
            //        {// 有占领帮派                
            //            if ("hold_map" in this.cltwar )
            //        {
            //                this.cltwar.hold_map.hold_clan = this.cltwar.owner_clanid;
            //            }
            //            // 需要计算占领帮派怪物属性加成
            //            _calc_clantechmon_att(this.cltwar.owner_clanid, this.cltwar.defside);

            //            //调整 初始化怪的血量
            //            if (mon_hp_per_data && ("mon_hp_per" in clantrit_conf) )
            //        {
            //                foreach (mon_hp_per in mon_hp_per_data)
            //                {
            //                    if (mon_hp_per.mapid in this.maps )
            //                {
            //                        local map_mon_bymid = this.maps[mon_hp_per.mapid].map_mon_bymid;
            //                        //sys.dumpobj( map_mon_bymid );
            //                        foreach (adjust_hp in mon_hp_per.hp_pers)
            //                        {
            //                            if (adjust_hp.mid in map_mon_bymid )
            //                        {
            //                                local mons = map_mon_bymid[adjust_hp.mid];
            //                                if (mons.len() > 0)
            //                                {//每种怪 只能有一个
            //                                    mons[0].adjust_hp_per(adjust_hp.hp_per);
            //                                }
            //                            }
            //                        }
            //                    }
            //                }
            //            }
            //        }
            //    }
            //else if ("clcqwar" in pvp_conf)
            //{
            //        // 帮派奴役战
            //        local clcqwar_conf = pvp_conf.clcqwar[0];

            //        local clanch_info = _get_clanch_info_byid(this.creator);
            //        if (!clanch_info)
            //        {
            //            this.fin();
            //            return game_err_code.LEVEL_NO_CLANCHL_REC;
            //        }

            //        foreach (sideconf in clcqwar_conf.side)
            //        {
            //            if (!("born" in sideconf))
            //        {
            //                sys.trace(sys.SLT_ERR, "sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] clcqwar_conf side [" + sideconf.id + "] without born!\n");

            //                this.fin();
            //                return game_err_code.CONFIG_ERR;
            //            }

            //            if (!(sideconf.id in this.sgplayersbyside))
            //        {
            //                this.sgplayersbyside[sideconf.id] < - { };
            //            }
            //        }

            //        this.sides_conf = clcqwar_conf.side;
            //        this.preptm = cur_tm_s + clcqwar_conf.preptm;

            //        this.clcqwar = {
            //            tar_mid = clcqwar_conf.tar_mid, cntleft = clcqwar_conf.tar_mon_cnt, atkside = clcqwar_conf.atkside, 
            //        defside = clcqwar_conf.defside, atk_clanid = clanch_info.fclid, def_clanid = clanch_info.tclid};

            //        // 获取防守帮派怪物属性加成
            //        _calc_clantechmon_att(this.clcqwar.def_clanid, this.clcqwar.defside);
            //    }
            else
            {
                Utility.trace_err("sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] pvp config error!\n");

                this.fin();
                return game_err_code.CONFIG_ERR;
            }

            //    if ("rnk_awd" in pvp_conf)
            //{
            //        // 有排行奖励战场
            //        this.rnk_batl = true;
            //    }

            if (this.preptm > 0)
            {
                // 有准备时间,准备时间内不准pk
                foreach (var map in this.maps.Values)
                {
                    map.set_pk_seting(map_pk_setting_type.MPST_PEACE);
                }
                this.pkrest_tm = this.preptm;
            }

            return game_err_code.RES_OK;
        }
예제 #2
0
        public game_err_code _init_pvp(pvp_conf pvp_conf, long cur_mt_s)
        {
            round_conf r_conf = new round_conf()
            {
                death_match = pvp_conf.death_match,
                death_pt = pvp_conf.death_pt,
                side = pvp_conf.side,
            };

            return _init_pvp(r_conf, cur_mt_s);
        }