void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     // weight [dynamic]
     foreach (SurfaceType surface in _surfacesDynamic)
     {
         _maskDynamic.value |= surface.Mask.value;
         _surfacesDictionary.Add((int)Mathf.Log(surface.Mask.value, 2), surface.Weight);
     }
 }
Esempio n. 2
0
 public Player()
 {
     pinfo = new pinfo();
     db_last_update_tm = 0;
     gmap = null;
     respawn_tm = 0;
     last_trace_target_tm = 0;
     bwantchangmap = false;
     //acupup_conf = null;
     leave_vip_line_tm_s = 0;
     //last_act_tm = sys.time();
     last_move_tm = 0;
     check_ol_tm = DateTime.Now.ToBinary();
 }
Esempio n. 3
0
        public void ply_change_map(IBaseUnit sprite, grid_map map)

        {
            throw new NotImplementedException();
        }
Esempio n. 4
0
        public game_err_code _create_group_map(group_map gp_map)
        {
            foreach (var mapconf in lvl_conf.level_map)
            {
                var map = new grid_map(mapconf.id);
                //sys.trace(sys.SLT_SYS, "sg_level instance id ["+llid+"] create map[" + lvl_conf.mapid +"]\n");

                if (map == null)
                {
                    Utility.trace_err("sg_level instance id [" + llid + "create gpmap[" + gp_map.gpid + "] create map[" + mapconf.id + "] failed!\n");
                    return game_err_code.LEVEL_CREATE_MAP_ERROR;
                }

                map.worldsvr = this;
                map.blvlmap = true;
                //map.init(mapconf.id);

                gp_map.maps[mapconf.id] = map;

                //    if ("trigger" in mapconf)
                //{
                //        map.init_trigger(mapconf.trigger, sys.time() - this.start_tm);
                //    }

                //    if ("path" in mapconf)
                //{
                //        map.init_path(mapconf.path);
                //    }

                //    if ("immrespawn" in mapconf )
                //{
                //        map.immrespawn = mapconf.immrespawn == 1;
                //    }

                //    if (("ignore_side" in mapconf) )
                //{
                //        map.ignore_side = mapconf.ignore_side == 1;
                //    }
            }

            //sys.trace(sys.SLT_DETAIL, "this.diff_lvl ["+this.diff_lvl+"]\n");

            var diff_fin_check = false;

            var diff_lvl_conf = this.lvl_conf.get_diff_lvl_conf(this.diff_lvl);
            if (diff_lvl_conf != null)
            {
                // 根据diff_lvl等级初始化额外增加的数据,如新增怪物等



                // 地图追加配置
                if (diff_lvl_conf.level_map.Count > 0)
                {
                    foreach (var mapconf in diff_lvl_conf.level_map)
                    {
                        if (!gp_map.maps.ContainsKey(mapconf.id))
                            continue;

                        var map = gp_map.maps[mapconf.id];
                        map.add_init(mapconf.map_mon, Utility.time() - this.start_tm);
                    }
                }

                // 增加地图怪物等级
                //        if ("mon_lvl_add" in diff_lvl_conf && diff_lvl_conf.mon_lvl_add > 0)
                //{
                //            foreach (map in gp_map.maps)
                //            {
                //                foreach (mon in map.map_mons)
                //                {
                //                    mon.setlevel(mon.mondata.level + diff_lvl_conf.mon_lvl_add);
                //                }
                //            }
                //        }

                if (diff_lvl_conf.fin_check != null)
                {
                    diff_fin_check = true;

                    if (diff_lvl_conf.fin_check.km.Count > 0)
                    {
                        foreach (var km in diff_lvl_conf.fin_check.km)
                        {
                            gp_map.kmfin[km.mid] = new kmfin() { cntleft = km.cnt };
                        }
                    }
                    if (diff_lvl_conf.fin_check.tm > 0)
                    {
                        gp_map.tmfin = true;
                    }
                }
            }

            if (lvl_conf.fin_check != null)
            {
                if (lvl_conf.fin_check.km.Count > 0)
                {
                    foreach (var km in lvl_conf.fin_check.km)
                    {
                        gp_map.kmfin[km.mid] = new kmfin() { cntleft = km.cnt };
                    }
                }
                if (lvl_conf.fin_check.tm > 0)
                {
                    gp_map.tmfin = true;
                }
            }
            return game_err_code.RES_OK;
        }
Esempio n. 5
0
        public game_err_code init(int llid)
        {
            //::g_debug( "====>>> on sg_level init(), llid:" + llid );

            //this.service = s;

            Level_Info linfo = Level.get_lvl_info(llid);

            //::g_dump( "====>>> 副本信息:", linfo );

            if (linfo == null)
            {
                this.fin();
                Utility.trace_err("lvl init err on linfo is null!");
                return game_err_code.INTERNAL_ERR;
            }

            ltpid = linfo.ltpid;
            this.diff_lvl = linfo.diff_lvl;
            this.creator = linfo.creator;

            this.lvl_conf = Utility.get_level_conf(ltpid);
            if (lvl_conf == null)
            {
                this.fin();
                Utility.trace_err("lvl init err on lvl_conf is null!");
                return game_err_code.CONFIG_ERR;
            }

            //this.is_score_km = (_get_score_conf("score_awd_km") != null);

            var diff_lvl_conf = lvl_conf.get_diff_lvl_conf(linfo.diff_lvl);
            if (null == diff_lvl_conf)
            {
                this.fin();
                Utility.trace_err("lvl init err on lvl_conf.diff_lvl is null!");
                return game_err_code.CONFIG_ERR;
            }


            long cur_tm_s = DateTime.Now.ToBinary();

            this.start_tm = cur_tm_s;
            if (this.lvl_conf.lctp == (int)level_checkin_type.LCT_AUTO_CREATE)
            {
                //    if ("tmchk" in this.lvl_conf )
                //{//计算准确开服时间
                //        local today_near_opntm = get_curr_open_tm(cur_tm_s, this.lvl_conf.tmchk);
                //        if (today_near_opntm != 0)
                //        {
                //            this.start_tm = today_near_opntm;
                //        }
                //    }
            }

            this.end_tm = this.start_tm + lvl_conf.tm * 60;

            if (diff_lvl_conf.born != null)
            {
                born_map_conf = diff_lvl_conf.born;//只有 idx=0 的配置生效
            }

            //::g_debug( "====>>副本 ltpid:" + ltpid );
            //::g_debug( "====>>副本 diff_lvl:" +  linfo.diff_lvl );
            //::g_dump( "====>>副本 diff_lvl_conf:",  diff_lvl_conf );
            //::g_dump( "====>>副本 born_map_conf 初始化出生点:",  born_map_conf );

            foreach (var mapconf in lvl_conf.level_map)
            {
                grid_map map = new grid_map(mapconf.id);
                //sys.trace(sys.SLT_SYS, "sg_level instance id ["+llid+"] create map[" + lvl_conf.mapid +"]\n");
                if (map == null)
                {
                    Utility.trace_err("sg_level instance id [" + llid + "] create map[" + mapconf.id + "] failed!\n");

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

                map.worldsvr = this;
                map.blvlmap = true;
                //map.init(mapconf.id);

                this.maps[mapconf.id] = map;

                if (born_map_conf == null && mapconf.born != null)
                {
                    var binfo = mapconf.born;
                    born_map_conf = binfo;
                    //::g_dump( "====>>副本 默认 born:", born_map_conf );
                }


                //    if ("trigger" in mapconf)
                //{
                //        //sys.trace( sys.SLT_DETAIL, "cur_tm_s-this.start_tm=" + cur_tm_s-this.start_tm + "\n");
                //        map.init_trigger(mapconf.trigger, cur_tm_s - this.start_tm);
                //    }

                //    if ("path" in mapconf)
                //{
                //        map.init_path(mapconf.path);
                //    }

                //    if ("skill" in mapconf)
                //{
                //        map.add_map_skills(mapconf.skill);
                //    }

                //    if ("immrespawn" in mapconf )
                //{
                //        map.immrespawn = mapconf.immrespawn == 1;
                //    }

                //    if (("ignore_side" in mapconf) )
                //{
                //        map.ignore_side = mapconf.ignore_side == 1;
                //    }
                //}

                //sys.trace(sys.SLT_DETAIL, "this.diff_lvl ["+this.diff_lvl+"]\n");
            }
            bool diff_fin_check = false;

            if (diff_lvl_conf != null)
            {
                // 根据diff_lvl等级初始化额外增加的数据,如新增怪物等


                if (diff_lvl_conf.level_map.Count > 0)
                {
                    // 地图追加配置
                    foreach (var map in diff_lvl_conf.level_map)
                    {
                        if (this.maps.ContainsKey(map.id))
                            continue;

                        this.maps[map.id].add_init(map.map_mon, Utility.time() - this.start_tm);
                    }
                }

                // 增加地图怪物等级
                //        if ("mon_lvl_add" in diff_lvl_conf && diff_lvl_conf.mon_lvl_add > 0)
                //{
                //            foreach (map in this.maps)
                //            {
                //                foreach (mon in map.map_mons)
                //                {
                //                    mon.setlevel(mon.mondata.level + diff_lvl_conf.mon_lvl_add);
                //                }
                //            }
                //        }

                if (diff_lvl_conf.fin_check != null)
                {
                    diff_fin_check = true;

                    if (diff_lvl_conf.fin_check.km.Count > 0)
                    {
                        foreach (var km in diff_lvl_conf.fin_check.km)
                        {
                            this.kmfin[km.mid] = new kmfin() { cntleft = km.cnt };
                        }
                    }

                    if (diff_lvl_conf.fin_check.tm > 0)
                        this.tmfin = true;

                }
            }

            if (born_map_conf == null)
            {
                Utility.trace_err("sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] without born map!\n");

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

            if (!diff_fin_check && lvl_conf.fin_check != null)
            {
                if (lvl_conf.fin_check.km.Count > 0)
                {
                    foreach (var km in lvl_conf.fin_check.km)
                    {
                        this.kmfin[km.mid] = new kmfin() { cntleft = km.cnt };
                    }
                }
                if (lvl_conf.fin_check.tm > 0)
                    this.tmfin = true;
            }

            if (lvl_conf.gpmap_maxply > 0)
            {
                if (this.lvl_conf.gpmap_maxply < this.lvl_conf.maxply)
                {
                    this.gpmap_maxply = this.lvl_conf.gpmap_maxply;
                    this.gp_maps = new List<SceneTest.group_map>();
                    this.cid2gpid = new Dictionary<int, int>();

                    group_map group_map = new group_map()
                    {
                        gpid = 1,
                        maps = this.maps,
                        kmfin = this.kmfin,
                        tmfin = this.tmfin
                    };

                    gp_maps.Add(group_map);
                }
            }

            this.llid = llid;

            //        if (("no_kp_hexp" in this.lvl_conf) && (this.lvl_conf.no_kp_hexp == 1))
            //{
            //            no_kp_hexp = true;
            //        }

            var pvp = lvl_conf.pvp;
            if (pvp != null)
            {
                if (pvp.ignore_clan > 0)
                    this.ignore_clan = true;

                if (pvp.ignore_team > 0)
                    this.ignore_team = true;

                if (pvp.plyside > 0)
                    this.plyside = pvp.plyside;

                if (pvp.round != null)
                {
                    // 有多个回合的pvp副本,初始化回合
                    foreach (var round in pvp.round)
                    {
                        this.rounds_conf[round.id] = round;
                    }

                    this.cur_round = 1;
                    if (!this.rounds_conf.ContainsKey(this.cur_round))
                    {
                        Utility.trace_err("sg_level instance id [" + llid + "] tpid[" + lvl_conf.tpid + "] pvp round without round 1!\n");
                        return game_err_code.CONFIG_ERR;
                    }

                    var res = _init_pvp(this.rounds_conf[this.cur_round], cur_tm_s); // 初始化第一回合配置
                    if (res != game_err_code.RES_OK)
                    {
                        return res;
                    }

                    this.round_tm = cur_tm_s + (this.rounds_conf[this.cur_round].tm * 60);
                }
                else
                {
                    var res = _init_pvp(pvp, cur_tm_s);
                    if (res != game_err_code.RES_OK)
                    {
                        return res;
                    }
                }
            }

            //        if ("dota" in lvl_conf)
            //{
            //            // 增加dota类的战场配置解析功能,初始化dota类战场数据
            //            local dota_conf = get_dota_conf(lvl_conf.dota);
            //            if (!dota_conf)
            //            {
            //                Utility.trace_err("invalid dota_conf[" + lvl_conf.dota + "]\n");
            //            }
            //            else
            //            {
            //                this.dota = { plys ={ }, conf = dota_conf};
            //            }
            //        }

            //if (this.clanmon_aff)
            //{
            //    // 帮派怪物加成
            //    foreach (map in this.maps)
            //    {
            //        foreach (mon in map.map_mons)
            //        {
            //            if (mon.mondata.lvlsideid != this.clanmon_att_add.sideid)
            //            {
            //                continue;
            //            }

            //            if (!("clanmon" in mon.monconf))
            //    {
            //                continue;
            //            }

            //            if (!(mon.monconf.clanmon in this.clanmon_att_add.atts))
            //    {
            //                continue;
            //            }

            //            mon.setclanatts(this.clanmon_att_add.atts[mon.monconf.clanmon]);
            //        }
            //    }
            //}

            if (lvl_conf.rmv_leave_ply == 1)
                this.rmv_leave_ply = true;

            //        if ("cltid" in lvl_conf)
            //{
            //            this.clter_conf = get_clantrit_conf(lvl_conf.cltid);
            //        }
            if (lvl_conf.plyrespawn_tm > 0)
            {
                this.plyrespawn_tm = lvl_conf.plyrespawn_tm;
                //this.plyrespawn_tms = { };
            }

            if (lvl_conf.immrespawn == 1)
            {
                this.immrespawn = true;
            }

            //        if ("team_exdrop" in lvl_conf)
            //{
            //            this.team_exdrop = lvl_conf.team_exdrop;
            //        }

            //        if ("tm_cost" in lvl_conf )
            //{
            //            this.tm_cost = true;
            //            total_tm_cost = { };
            //        }

            if (lvl_conf.tm_out > 0)
            {
                this.tm_out = lvl_conf.tm_out;
                this.joininfo = new Dictionary<int, JoinInfo>();
            }

            var diffs = lvl_conf.diff_lvl;

            //foreach (var dx in lvl_conf.diff_lvl)
            //{
            //    local map_km = { };
            //    foreach (map in diff_lvl.map)
            //    {
            //        if ("dir_enter" in map)
            //    {
            //            local dir_enter = map.dir_enter[0];
            //            if ("km" in dir_enter)
            //        {
            //                local km = dir_enter.km[0];
            //                map_km[map.id] < - { mid = km.mid, mapid = km.mapid};
            //            }
            //        }
            //    }
            //    map_need_km[diff_lvl.lv] < -map_km;
            //}

            //        if ("trig_finchk" in lvl_conf )
            //{
            //            this.active_finchk = false;
            //        }

            this.state = level_state_type.LST_PROCEED;

            Level.set_lvl_end_tm(llid, end_tm);

            this.sid_ary = new HashSet<int>();

            return game_err_code.RES_OK;
        }