public int    Equip_RingTableId;     //穿戴戒指

    public byte[] ToArray()
    {
        using (MemoryStreamUtil ms = new MemoryStreamUtil())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteBool(IsSuccess);
            if (IsSuccess)
            {
                ms.WriteInt(RoldId);
                ms.WriteUTF8String(RoleNickName);
                ms.WriteByte(ClassId);
                ms.WriteInt(Level);
                ms.WriteInt(VIPLevel);
                ms.WriteInt(TotalRechargeGem);
                ms.WriteInt(Gem);
                ms.WriteInt(Gold);
                ms.WriteInt(CurrEnergy);
                ms.WriteInt(MaxEnergy);
                ms.WriteInt(Exp);
                ms.WriteInt(MaxHP);
                ms.WriteInt(MaxMP);
                ms.WriteInt(CurrHP);
                ms.WriteInt(CurrMP);
                ms.WriteInt(Attack);
                ms.WriteInt(Defense);
                ms.WriteInt(Hit);
                ms.WriteInt(Dodge);
                ms.WriteInt(Cri);
                ms.WriteInt(Res);
                ms.WriteInt(SumDPS);
                ms.WriteInt(LastPassGameQuestId);
                ms.WriteInt(LastInWorldMapId);
                ms.WriteUTF8String(LastInWorldMapPos);
                ms.WriteInt(Equip_Weapon);
                ms.WriteInt(Equip_Pants);
                ms.WriteInt(Equip_Clothes);
                ms.WriteInt(Equip_Belt);
                ms.WriteInt(Equip_Cuff);
                ms.WriteInt(Equip_Necklace);
                ms.WriteInt(Equip_Shoe);
                ms.WriteInt(Equip_Ring);
                ms.WriteInt(Equip_WeaponTableId);
                ms.WriteInt(Equip_PantsTableId);
                ms.WriteInt(Equip_ClothesTableId);
                ms.WriteInt(Equip_BeltTableId);
                ms.WriteInt(Equip_CuffTableId);
                ms.WriteInt(Equip_NecklaceTableId);
                ms.WriteInt(Equip_ShoeTableId);
                ms.WriteInt(Equip_RingTableId);
            }
            else
            {
                ms.WriteInt(MsgCode);
            }
            return(ms.ToArray());
        }
    }
Ejemplo n.º 2
0
    public int    RoldId; //角色编号

    public byte[] ToArray()
    {
        using (MemoryStreamUtil ms = new MemoryStreamUtil())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteInt(RoldId);
            return(ms.ToArray());
        }
    }
    public int    GameServerId; //区服ID

    public byte[] ToArray()
    {
        using (MemoryStreamUtil ms = new MemoryStreamUtil())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteInt(AccountId);
            ms.WriteInt(GameServerId);
            return(ms.ToArray());
        }
    }
Ejemplo n.º 4
0
    public int    GameServerId; //角色所在区服ID

    public byte[] ToArray()
    {
        using (MemoryStreamUtil ms = new MemoryStreamUtil())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteByte(ClassId);
            ms.WriteUTF8String(RoleNickName);
            ms.WriteInt(GameServerId);
            return(ms.ToArray());
        }
    }
    public int    MsgCode;   //消息码

    public byte[] ToArray()
    {
        using (MemoryStreamUtil ms = new MemoryStreamUtil())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteBool(IsSuccess);
            if (!IsSuccess)
            {
                ms.WriteInt(MsgCode);
            }
            return(ms.ToArray());
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 制作一个数据包,该数据包是符合传给服务器的格式的(包头+包体)
    /// 当前工程的格式是包头:包体长度,包体:压缩标志+CRC校验码+加密的真正数据(异或算法)(协议编码+协议内容)
    /// 把private改为public,配合本机模式本地测试用
    /// </summary>
    /// <param name="data">真实数据</param>
    /// <returns></returns>
    public byte[] MakeDataPkg(byte[] data)
    {
        byte[] returnBuffer = null;
        data = SecurityUtil.XorAlgorithm(data);           //1、加密
        bool isCompress = data.Length > mCompressMinSize; //2、压缩

        if (isCompress)
        {
            //开始压缩
            data = ZlibHelper.CompressBytes(data);
        }
        ushort crc16 = Crc16.CalculateCrc16(data);  //3、CRC校验

        using (MemoryStreamUtil stream = new MemoryStreamUtil())
        {
            stream.WriteUShort((ushort)(data.Length + 3)); //写包头,+3是因为多了一个bool,一个ushort,一共3字节
            stream.WriteBool(isCompress);                  //写压缩标志
            stream.WriteUShort(crc16);                     //写CRC
            stream.Write(data, 0, data.Length);            //写加密后的真实数据
            returnBuffer = stream.ToArray();
        }
        Debug.Log("数据包构建完毕!");
        return(returnBuffer);
    }
 public byte[] ToArray()
 {
     using (MemoryStreamUtil ms = new MemoryStreamUtil())
     {
         ms.WriteUShort(ProtoCode);
         ms.WriteInt(RoleCount);
         for (int i = 0; i < RoleCount; i++)
         {
             ms.WriteInt(RoleList[i].RoleId);
             ms.WriteUTF8String(RoleList[i].RoleNickName);
             ms.WriteByte(RoleList[i].RoleClass);
             ms.WriteInt(RoleList[i].RoleLevel);
         }
         return(ms.ToArray());
     }
 }