예제 #1
0
    public void add_player_to_map(IService game_ref, int clientid, IBaseUnit sgplayer)
    {
        // 中断打坐
        //sgplayer.try_stop_recover();

        long cur_tm_s = DateTime.Now.ToBinary();

        var players_info = game_ref.sgplayers;

        sgplayer.gmap = this;

        IMapUnit pl = sgplayer.get_pack_data();

        pl.iid = this.add_player(clientid, pl.x, pl.y, sgplayer);

        this.map_sprites[pl.iid] = sgplayer;
        this.map_players[pl.iid] = sgplayer;

        this.map_players_bysid[clientid] = sgplayer;
        this.map_players_bycid[pl.cid] = sgplayer;

        if (this.blvlmap)
        {   //玩家在副本切换地图通知
            game_ref.ply_change_map(sgplayer, this);
        }
        // send map change msg
        //var map_change_data = {mpid=pl.map_id, iid=pl.iid, x=pl.x, y=pl.y,
        //                        speed=pl.speed, maxhp=pl.max_hp, maxmp=pl.max_mp,in_pczone=pl.in_pczone};

        //sys.dumpobj(dpitms);

        if (this.map_dpitms.Count > 0)
        {
            List<int> removed_items = new List<int>();
            foreach (var drop_item in map_dpitms)
            {
                drop_item.Value.left_tm = drop_item.Value.dis_tm - cur_tm_s;
                if (drop_item.Value.left_tm <= 0)
                    removed_items.Add(drop_item.Key);
            }
            foreach (int k in removed_items)
                this.map_dpitms.Remove(k);

            //map_change_data.dpitms < -this.map_dpitms;
        }
        //::send_rpc(clientid, 58, map_change_data);

        //// 尝试召唤战斗宠物
        //if (pl.pet_mon.mid > 0)
        //{
        //    if (pl.pet_mon.fintm > cur_tm_s)
        //    {
        //        sgplayer.call_petmon(pl.pet_mon.mid, pl.pet_mon.fintm);
        //    }
        //    else
        //    {
        //        pl.pet_mon.mid = 0;
        //        pl.pet_mon.fintm = 0;
        //    }
        //}

    }