Ejemplo n.º 1
0
    void Send_Operation()
    {
        msgNum++;
        UdpUpPlayerOperation _op = new UdpUpPlayerOperation(msgNum, BattleData.Instance.SelfOperation);

        clientUdp.SendMessage(new Protocol(_op));

        BattleData.Instance.ResetSelfOperation();
    }
Ejemplo n.º 2
0
    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;
        }
    }