public static byte[] Serialize(object x) { RpPlayerData rpData = (RpPlayerData)x; byte[] res = new byte[4 + 2 + rpData.PlayerName.Length + 1]; int index = 0; SerializeUtils.WriteInt(res, ref index, rpData.PlayerId); SerializeUtils.WriteString(res, ref index, rpData.PlayerName); SerializeUtils.WriteBool(res, ref index, rpData.IsReady); return(res); }
public static Dictionary <byte, object> Serialization(int frameCount, List <BattleInstructionBase> battleInstructionList, bool isFrameFinish) { int totalByteLength = 4 + 2 + 1; for (int i = 0; i < battleInstructionList.Count; ++i) { totalByteLength += battleInstructionList[i].GetSerializationByteLength(); } byte[] byteArray = new byte[totalByteLength]; int index = 0; SerializeUtils.WriteInt(byteArray, ref index, frameCount); SerializeUtils.WriteShort(byteArray, ref index, (short)battleInstructionList.Count); SerializeUtils.WriteBool(byteArray, ref index, isFrameFinish); for (int i = 0; i < battleInstructionList.Count; ++i) { battleInstructionList[i].Serialization(byteArray, ref index); } Dictionary <byte, object> retDic = new Dictionary <byte, object>(); retDic[1] = byteArray; return(retDic); }