public void OnReceive() { if (messageQueue.Count > 0) { MarsMessage message = messageQueue.Dequeue(); if (message == null) { Debug.LogFormat("消息={)},消息队列情况长度={1}", message, messageQueue.Count); return; } switch (message.cmd) { case MessageConst.Battle.RESP_MOVE_CHESS: Debug.Log("移动棋子"); RespMoveChess respMoveChess = ProtobufTool.DeSerialize <RespMoveChess>(message.data); ReceiveChessMove(respMoveChess); break; case MessageConst.Battle.RESP_CURRENT_GO_INFO: Debug.Log("当前行动信息"); RespCurrentGoInfo respCurrentGoInfo = ProtobufTool.DeSerialize <RespCurrentGoInfo>(message.data); ReceiveGoInfo(respCurrentGoInfo); break; default: break; } } }
public void ReceiveGoInfo(RespCurrentGoInfo rcgi) { goInfo = rcgi; //如果是新的一个回合,显示回合 if (goInfo.newRound) { } }
public void Handle(int cmd, byte[] data) { switch (cmd) { case MessageConst.Battle.RESP_GAME_INIT: //初始化游戏 Debug.Log("开始初始化游戏..."); RespGameInit respGameInit = ProtobufTool.DeSerialize <RespGameInit>(data); BattleStatus.INSTANCE.respGameInit = respGameInit; PlayerManager.self.statusManager.Switch(BattleStatus.INSTANCE); actions.Enqueue(GameInit); break; case MessageConst.Battle.RESP_MOVE_CHESS: RespMoveChess respMoveChess = ProtobufTool.DeSerialize <RespMoveChess>(data); break; case MessageConst.Battle.RESP_CURRENT_GO_INFO: RespCurrentGoInfo respCurrentGoInfo = ProtobufTool.DeSerialize <RespCurrentGoInfo>(data); break; default: break; } }