Пример #1
0
    // Update is called once per frame
    void Update()
    {
        framesTillSend--;

        if (framesTillSend <= 0)
        {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
            bsonObj.Add("newx", playerPosition.transform.position.x);
            bsonObj.Add("newy", playerPosition.transform.position.y);
            bsonObj.Add("newz", playerPosition.transform.position.z);
            bsonSender.SendUncompressed(bsonObj);

            framesTillSend = sendEveryXFrames;
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        radius    = 1000.0f;
        ang       = 0;
        elevation = 0.1f;
        offset    = new Vector3(0, 0, 0);

        /*
         * tcpSender = new TCPAsyncSender("192.168.1.103", 5555);
         * tcpSender.StartThread();
         * tcpSender.AddMessage(testMsg);
         */

        Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
        bsonObj.Add("test", "hello");

        bsonSender = new BSONSender(remoteHost, remotePort);
        bsonSender.SendUncompressed(bsonObj);
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        float x, y, z;

        if (Input.touchCount == 1)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                touchMoved = false;
            }
            else if (touch.phase == TouchPhase.Moved)
            {
                Vector3 cameraPos;

                /*
                 * ang -= touch.deltaPosition.x * sensitivityRotate;
                 * elevation += touch.deltaPosition.y * sensitivityElevate;
                 * if (elevation < 0)
                 *      elevation = 0;
                 * else if (elevation > (Mathf.PI / 2.0f))
                 *      elevation = Mathf.PI / 2.0f;
                 */
                cameraPos    = camera.transform.position;
                cameraPos.x += touch.deltaPosition.x;
                cameraPos.z += touch.deltaPosition.y;
                camera.transform.position = cameraPos;
                touchMoved = true;
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                // this is a click
                if (!touchMoved)
                {
                    /* We can use GUI stuff so probably don't need this */

                    /*
                     * Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
                     * bsonObj.Add ("x", touch.position.x);
                     * bsonObj.Add ("y", touch.position.y);
                     * bsonSender.SendUncompressed(bsonObj);
                     */
                }
            }
        }
        else if (Input.touchCount == 2)
        {
            Touch t1, t2;
            t1 = Input.GetTouch(0);
            t2 = Input.GetTouch(1);
            if (!pinching)
            {
                pinching     = true;
                pinchDist    = Vector2.Distance(t1.position, t2.position);
                oldTouchPos  = t1.position;
                forwardDir   = camera.transform.forward;
                forwardDir.y = 0;
                rightDir     = camera.transform.right;
                rightDir.y   = 0;
            }
            else
            {
                float oldPinchdist = pinchDist;
                pinchDist   = Vector2.Distance(t1.position, t2.position);
                radius     += oldPinchdist - pinchDist;
                offset     -= forwardDir * (oldTouchPos.y - t1.position.y);
                offset     += rightDir * (oldTouchPos.x - t1.position.x);
                oldTouchPos = t1.position;
            }
        }
        else
        {
            pinching = false;
        }


        if (Input.GetKey(KeyCode.A))
        {
            ang += 0.1f;
        }
        if (Input.GetKey(KeyCode.D))
        {
            ang -= 0.1f;
        }
        if (Input.GetKey(KeyCode.Q))
        {
            if (elevation < (Mathf.PI / 2.0f))
            {
                elevation += 0.1f;
            }
        }
        if (Input.GetKey(KeyCode.E))
        {
            if (elevation > 0.15f)
            {
                elevation -= 0.1f;
            }
        }
        if (Input.GetKey(KeyCode.W))
        {
            radius -= 10.0f;
        }
        if (Input.GetKey(KeyCode.S))
        {
            radius += 10.0f;
        }
        if (Input.GetKey(KeyCode.Z))
        {
            offset += forwardDir;
        }
        if (Input.GetKey(KeyCode.X))
        {
            offset -= forwardDir;
        }

        x = radius * Mathf.Cos(ang) * Mathf.Sin(elevation);
        z = radius * Mathf.Sin(ang) * Mathf.Sin(elevation);
        y = radius * Mathf.Cos(elevation);

        //camera.transform.localPosition = new Vector3(x, y, z) + orbitAround.position + offset;
        //camera.transform.LookAt(orbitAround.position + offset);

        Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
        bsonObj.Add("x", jstick.position.x);
        bsonObj.Add("y", jstick.position.y);
        bsonSender.SendUncompressed(bsonObj);
    }