示例#1
0
    public void FixedUpdate()
    {
        if (net_manager.Connected())
        {
            net_manager.Receive(buffer_recv, out se);
        }
        //Debug.Log("!!!!!!" + buffer_recv.GetDataSize() + " " + buffer_recv.GetStart() + " " + buffer_recv.GetEnd());
        while (true)
        {
            if (buffer_recv.IsHeaderReadable(3 * sizeof(Int32)) == false)
            {
                break;
            }

            msgInfo = buffer_recv.Decode();

            if (buffer_recv.IsHeaderAndPayloadReadable(3 * sizeof(Int32) + msgInfo.GetPacLen()) == false)
            {
                break;
            }


            buffer_recv.GetPayload(msgInfo);
            switch (msgInfo.GetMsgID())
            {
            case 1006:
                msgtemp = MSG_PLAYER_MOVE.Parser.ParseFrom(msgInfo.GetPayload());
                Debug.LogError("Recv mov: x = " + msgtemp.X + ", z = " + msgtemp.Z + ".    ry = " + msgtemp.Ry);

                update_player(msgtemp.Playerid, ((float)msgtemp.X) / 100000, ((float)msgtemp.Z) / 100000, ((float)msgtemp.Ry) / 100000, msgtemp.State);
                break;

            case 1008:
                msgtemp_register_recv = MSG_PLAYER_REGISTER.Parser.ParseFrom(msgInfo.GetPayload());
                Debug.LogError("Recv reg: x = " + msgtemp_register_recv.X + ", z = " + msgtemp_register_recv.Z + ".    Ry = ");

                update_player(msgtemp_register_recv.Playerid, ((float)msgtemp_register_recv.X) / 100000, ((float)msgtemp_register_recv.Z) / 100000, ((float)msgtemp_register_recv.Ry) / 100000, 0);
                break;
            }
        }



        m_PlayerSelf.FixedUpdate();
    }