Exemple #1
0
    void Update()
    {
        Packet s;

        if ((s = channel.GetPacket()) != null)
        {
            int messages = s.buffer.GetInt();
            for (int i = 0; i < messages; i++)
            {
                Message m = readServerMessage(s.buffer);
                if (m != null)
                {
                    ProcessMessage(m);
                }
                else
                {
                    Debug.Log("m is null");
                }
            }
            Debug.Log("Recibi algo");
        }
        if (!snapshotManager.alreadyAdded)
        {
            snapshotManager.AddInterpolated();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            //send player connect message
            ConnectPlayerMessage connectPlayerMessage = ConnectPlayerMessage.CreateConnectPlayerMessageToSend(playerId);
            cm.SendMessage(connectPlayerMessage);
        }
        processSnapshot();
        Packet             packet = Packet.Obtain();
        PlayerInputMessage pim    = new PlayerInputMessage(playerId, playerController.playerInput);

        cm.SendMessage(pim);

        Packet p = cm.BuildPacket();

        channel.Send(p);
    }