public void AnalyzeMessage(CSID messageId, byte[] bodyData) { switch (messageId) { case CSID.UDP_BATTLE_READY: { //接收战斗准备 UdpBattleReady _mes = CSData.DeserializeData <UdpBattleReady> (bodyData); CheckBattleBegin(_mes.battleID); dic_udp [_mes.battleID].RecvClientReady(_mes.uid); } break; case CSID.UDP_UP_PLAYER_OPERATIONS: { UdpUpPlayerOperations pb_ReceiveMes = CSData.DeserializeData <UdpUpPlayerOperations>(bodyData); UpdatePlayerOperation(pb_ReceiveMes.operation, pb_ReceiveMes.mesID); } break; case CSID.UDP_UP_DELTA_FRAMES: { UdpUpDeltaFrames pb_ReceiveMes = CSData.DeserializeData <UdpUpDeltaFrames>(bodyData); UdpDownDeltaFrames _downData = new UdpDownDeltaFrames(); for (int i = 0; i < pb_ReceiveMes.frames.Count; i++) { int framIndex = pb_ReceiveMes.frames [i]; UdpDownFrameOperations _downOp = new UdpDownFrameOperations(); _downOp.frameID = framIndex; _downOp.operations = dic_gameOperation [framIndex]; _downData.framesData.Add(_downOp); } byte[] _data = CSData.GetSendMessage <UdpDownDeltaFrames> (_downData, SCID.UDP_DOWN_DELTA_FRAMES); dic_udp [pb_ReceiveMes.battleID].SendMessage(_data); } break; case CSID.UDP_UP_GAME_OVER: { UdpUpGameOver pb_ReceiveMes = CSData.DeserializeData <UdpUpGameOver>(bodyData); UpdatePlayerGameOver(pb_ReceiveMes.battleID); UdpDownGameOver _downData = new UdpDownGameOver(); byte[] _data = CSData.GetSendMessage <UdpDownGameOver> (_downData, SCID.UDP_DOWN_GAME_OVER); dic_udp [pb_ReceiveMes.battleID].SendMessage(_data); } break; default: break; } }
void Message_Delta_Frame_Data(UdpDownDeltaFrames _mes) { if (_mes.framesData.Count > 0) { foreach (var item in _mes.framesData) { BattleData.Instance.AddLackFrameData(item.frameID, item.operations); } } }
void Message_Delta_Frame_Data(UdpDownDeltaFrames msg) { if (msg.FramesData.Count > 0) { foreach (var item in msg.FramesData) { BattleData.Instance.AddLackFrameData(item.FrameID, item.Ops); } } }
private void HandleMsg(ServerClientUdp udp, Protocol proto) { switch (proto.ClassName) { case nameof(UdpBattleReadyMessage): { UdpBattleReadyMessage msg = proto.Decode <UdpBattleReadyMessage>(); Debug.Log("客户端完成战斗加载"); // 接收战斗准备 CheckBattleBegin(msg.BattleID); dic_udp[msg.BattleID].RecvClientReady(msg.UID); } break; case nameof(UdpUpPlayerOperation): { UdpUpPlayerOperation msg = proto.Decode <UdpUpPlayerOperation>(); //Debug.Log("服务器接收到玩家的操作信息"); UpdatePlayerOperation(msg.PlayerOperation, msg.MsgID); } break; case nameof(UdpUpDeltaFrames): { UdpUpDeltaFrames msg = proto.Decode <UdpUpDeltaFrames>(); UdpDownDeltaFrames _downData = new UdpDownDeltaFrames(); for (int i = 0; i < msg.Frames.Count; i++) { int frameIndex = msg.Frames[i]; UdpDownFrameOperations _downOps = new UdpDownFrameOperations(); _downOps.FrameID = frameIndex; _downOps.Ops = dic_gameOperation[frameIndex]; _downData.FramesData.Add(_downOps); } dic_udp[msg.BattleID].SendMessage(new Protocol(_downData)); } break; default: { Debug.LogError("未知客户端UDP信息"); } break; } }
public void AnalyzeMessage(SCID messageId, byte[] bodyData) { switch (messageId) { case SCID.UDP_BATTLE_START: { UdpBattleStart pb_ReceiveMes = CSData.DeserializeData <UdpBattleStart>(bodyData); NetGlobal.Instance().AddAction(() => { mes_battle_start(pb_ReceiveMes); }); } break; case SCID.UDP_DOWN_FRAME_OPERATIONS: { UdpDownFrameOperations pb_ReceiveMes = CSData.DeserializeData <UdpDownFrameOperations>(bodyData); NetGlobal.Instance().AddAction(() => { mes_frame_operation(pb_ReceiveMes); }); } break; case SCID.UDP_DOWN_DELTA_FRAMES: { UdpDownDeltaFrames pb_ReceiveMes = CSData.DeserializeData <UdpDownDeltaFrames>(bodyData); NetGlobal.Instance().AddAction(() => { mes_delta_frame_data(pb_ReceiveMes); }); } break; case SCID.UDP_DOWN_GAME_OVER: { UdpDownGameOver pb_ReceiveMes = CSData.DeserializeData <UdpDownGameOver>(bodyData); NetGlobal.Instance().AddAction(() => { mes_down_game_over(pb_ReceiveMes); }); } break; default: break; } }
private void HandleMsg(Protocol protocol) { switch (protocol.ClassName) { case nameof(UdpBattleStartMessage): { Debug.Log("服务器知道了客户端完成了加载"); ClientGlobal.Instance.AddAction(() => { msg_battle_start(protocol.Decode <UdpBattleStartMessage>()); }); } break; case nameof(UdpDownFrameOperations): { //Debug.Log("客户端收到服务器转发的帧操作信息"); ClientGlobal.Instance.AddAction(() => { msg_frame_operation(protocol.Decode <UdpDownFrameOperations>()); }); } break; case nameof(UdpDownDeltaFrames): { Debug.Log("客户端根据服务器转发的旧帧信息处理"); UdpDownDeltaFrames msg = protocol.Decode <UdpDownDeltaFrames>(); ClientGlobal.Instance.AddAction(() => { msg_delta_frame(msg); }); } break; default: Debug.Log("未查找到udp信息处理函数:" + protocol.ClassName); break; } }