public static WorldMap_RoleAlreadyEnterProto GetProto(byte[] buffer, bool isChild = false)
    {
        WorldMap_RoleAlreadyEnterProto proto = new WorldMap_RoleAlreadyEnterProto();

        MMO_MemoryStream ms = null;

        if (!isChild)
        {
            ms = GameEntry.Socket.SocketSendMS;
        }
        else
        {
            ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>();
        }
        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.TargetWorldMapSceneId = ms.ReadInt();
        proto.RolePosX   = ms.ReadFloat();
        proto.RolePosY   = ms.ReadFloat();
        proto.RolePosZ   = ms.ReadFloat();
        proto.RoleYAngle = ms.ReadFloat();

        if (isChild)
        {
            GameEntry.Pool.EnqueueClassObject(ms);
        }
        return(proto);
    }
    public static WorldMap_RoleAlreadyEnterProto GetProto(byte[] buffer)
    {
        WorldMap_RoleAlreadyEnterProto proto = new WorldMap_RoleAlreadyEnterProto();

        using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer))
        {
            proto.TargetWorldMapSceneId = ms.ReadInt();
            proto.RolePosX   = ms.ReadFloat();
            proto.RolePosY   = ms.ReadFloat();
            proto.RolePosZ   = ms.ReadFloat();
            proto.RoleYAngle = ms.ReadFloat();
        }
        return(proto);
    }
Ejemplo n.º 3
0
    public static WorldMap_RoleAlreadyEnterProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        WorldMap_RoleAlreadyEnterProto proto = new WorldMap_RoleAlreadyEnterProto();

        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.TargetWorldMapSceneId = ms.ReadInt();
        proto.RolePosX   = ms.ReadFloat();
        proto.RolePosY   = ms.ReadFloat();
        proto.RolePosZ   = ms.ReadFloat();
        proto.RoleYAngle = ms.ReadFloat();

        return(proto);
    }
Ejemplo n.º 4
0
        /// <summary>
        /// 客户端发送角色已经进入世界地图场景消息
        /// </summary>
        /// <param name="role"></param>
        /// <param name="buffer"></param>
        private void OnWorldMapRoleAlreadyEnter(Role role, byte[] buffer)
        {
            WorldMap_RoleAlreadyEnterProto proto = WorldMap_RoleAlreadyEnterProto.GetProto(role.SocketReceiveMS, buffer);

            int sceneId = proto.TargetWorldMapSceneId;

            Console.WriteLine("角色要离开的场景=" + role.LastInWorldMapId);

            //1.离开上一个场景
            RoleLeave(role.RoleId, role.PrevWorldMapId);

            role.PrevWorldMapId    = sceneId;
            role.LastInWorldMapId  = sceneId;
            role.LastInWorldMapPos = string.Format("{0}_{1}_{2}_{3}", proto.RolePosX, proto.RolePosY, proto.RolePosZ, proto.RoleYAngle);

            //2.发送当前场景中的其他玩家
            SendCurrSceneInitRole(role, sceneId);

            //3.进入当前场景
            RoleEnter(role, sceneId);

            //4.通知同场景的其他玩家 告诉他们我来了
            NotifyOtherRole_RoleEnter(sceneId, role.RoleId);
        }