public static void OnRole_ListTest(byte[] buffer)
    {
        Role_ListTestProto proto = Role_ListTestProto.GetProto(buffer);

#if DEBUG_LOG_PROTO
        Debug.Log("<color=#00eaff>接收消息:</color><color=#00ff9c>" + proto.ProtoEnName + " " + proto.ProtoCode + "</color>");
        Debug.Log("<color=#c5e1dc>==>>" + JsonUtility.ToJson(proto) + "</color>");
#endif
    }
Esempio n. 2
0
    public static Role_ListTestProto GetProto(byte[] buffer, bool isChild = false)
    {
        Role_ListTestProto proto = new Role_ListTestProto();

        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.RoleType = ms.ReadInt();

        int len_CurrRole = ms.ReadInt();

        if (len_CurrRole > 0)
        {
            byte[] buff_CurrRole = new byte[len_CurrRole];
            ms.Read(buff_CurrRole, 0, len_CurrRole);
            proto.CurrRole = Role_DataProto.GetProto(buff_CurrRole, true);
        }

        int len_RoleList = ms.ReadInt();

        if (len_RoleList > 0)
        {
            proto.RoleList = new List <Role_DataProto>();
            for (int i = 0; i < len_RoleList; i++)
            {
                int _len_RoleList = ms.ReadInt();
                if (_len_RoleList > 0)
                {
                    byte[] _buff_RoleList = new byte[_len_RoleList];
                    ms.Read(_buff_RoleList, 0, _len_RoleList);
                    proto.RoleList.Add(Role_DataProto.GetProto(_buff_RoleList, true));
                }
            }
        }

        if (isChild)
        {
            GameEntry.Pool.EnqueueClassObject(ms);
        }
        return(proto);
    }
Esempio n. 3
0
    public static Role_ListTestProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        Role_ListTestProto proto = new Role_ListTestProto();

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

        proto.RoleType = ms.ReadInt();

        int len_CurrRole = ms.ReadInt();

        if (len_CurrRole > 0)
        {
            byte[] buff_CurrRole = new byte[len_CurrRole];
            ms.Read(buff_CurrRole, 0, len_CurrRole);
            proto.CurrRole = Role_DataProto.GetProto(new MMO_MemoryStream(), buff_CurrRole);
        }

        int len_RoleList = ms.ReadInt();

        if (len_RoleList > 0)
        {
            proto.RoleList = new List <Role_DataProto>();
            for (int i = 0; i < len_RoleList; i++)
            {
                int _len_RoleList = ms.ReadInt();
                if (_len_RoleList > 0)
                {
                    byte[] _buff_RoleList = new byte[_len_RoleList];
                    ms.Read(_buff_RoleList, 0, _len_RoleList);
                    proto.RoleList.Add(Role_DataProto.GetProto(new MMO_MemoryStream(), _buff_RoleList));
                }
            }
        }

        return(proto);
    }