Ejemplo n.º 1
0
    void sendPos()
    {
        bufin = SerializeNetchan(1, 2);
        Netchan net = deserializeNetchan(bufin);

        print("Sending...\nProtocol: " + net.Protocol +
              "\nSequence: " + net.Sequence + "\nAck: " + net.Ack);

        client.Send(bufin, bufin.Length);

        bufout = client.Receive(ref ep);
        net    = deserializeNetchan(bufout);
        Player p = net.Players(0).Value;

        print("Receiving...\nProtocol: " + net.Protocol +
              "\nSequence: " + net.Sequence + "\nAck: " + net.Ack +
              "\n x: " + p.Rot.Value.X +
              "\n y: " + p.Rot.Value.Y +
              "\n z: " + p.Rot.Value.Z);
        print(net.ByteBuffer.Data);

        var i = 0;

        foreach (Transform t in networkedPlayers)
        {
            i++;
            t.position    = new Vector3(p.Pos.Value.X, p.Pos.Value.Y, (float)p.Pos.Value.Z + 2 * i);
            t.eulerAngles = new Vector3(p.Rot.Value.X, p.Rot.Value.Y, p.Rot.Value.Z);
            //t.rotation = new Quaternion(p.Rot.Value.X, p.Rot.Value.Y, p.Rot.Value.Z, 0);
        }
    }