using System.Collections;
using System.Collections.Generic;
using System;
/// <summary>
/// 客户端发送进入游戏关卡消息
/// </summary>
public struct GameLevel_EnterProto : IProto
{
public ushort ProtoCode { get { return 12001; } }
public int GameLevelId; //游戏关卡Id
public byte Grade; //难度等级
public byte[] ToArray()
{
using (MMO_MemoryStream ms = new MMO_MemoryStream())
{
ms.WriteUShort(ProtoCode);
ms.WriteInt(GameLevelId);
ms.WriteByte(Grade);
return ms.ToArray();
}
}
public static GameLevel_EnterProto GetProto(byte[] buffer)
{
GameLevel_EnterProto proto = new GameLevel_EnterProto();
using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer))
{
proto.GameLevelId = ms.ReadInt();
proto.Grade = (byte)ms.ReadByte();
}
return proto;
}
}GameLevel_EnterProto
最新推荐文章于 2024-04-30 05:17:19 发布
本文介绍了一种用于客户端向服务器发送进入游戏关卡请求的消息协议实现方式,该协议包括游戏关卡ID和难度等级两个关键字段,并提供了序列化与反序列化的具体实现。
3916

被折叠的 条评论
为什么被折叠?



