Exemplo n.º 1
0
    private void Update()
    {
        int i = 0;

        while (i < Input.touchCount)
        {
            Touch t = Input.GetTouch(i);

            if (t.phase == TouchPhase.Began)
            {
                touches.Add(new touchLocation(t.fingerId, CreateCircle(t), true));
            }
            else if (t.phase == TouchPhase.Moved)
            {
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchID == t.fingerId);
                thisTouch.planet.transform.position = GetTouchPos(t.position);
            }
            else if (t.phase == TouchPhase.Ended)
            {
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchID == t.fingerId);
                thisTouch.manualMove = false;
                Destroy(thisTouch.planet);
                touches.RemoveAt(touches.IndexOf(thisTouch));
            }
            i++;
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        int i = 0;

        while (i < Input.touchCount)
        {
            Touch t = Input.GetTouch(i);
            if (t.phase == TouchPhase.Began)
            {
                //Debug.Log("touch began");
                touches.Add(new touchLocation(t.fingerId, createCircle(t)));
            }
            else if (t.phase == TouchPhase.Ended)
            {
                //Debug.Log("touch ended");
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchId == t.fingerId);
                Destroy(thisTouch.circle);
                touches.RemoveAt(touches.IndexOf(thisTouch));
            }
            else if (t.phase == TouchPhase.Moved)
            {
                //Debug.Log("touch is moving");
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchId == t.fingerId);
                thisTouch.circle.transform.position = getTouchPosition(t.position);
            }
            ++i;
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        int i = 0;

        while (i < Input.touchCount)
        {
            Touch t = Input.GetTouch(i);
            if (t.phase == TouchPhase.Began)
            {
                Debug.Log("touch began");

                touches.Add(new touchLocation(t.fingerId, circle1));
            }
            else if (t.phase == TouchPhase.Ended)
            {
                Debug.Log("touch ended");
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchId == t.fingerId);
                //Destroy(thisTouch.circle);
                touches.RemoveAt(touches.IndexOf(thisTouch));
            }
            else if (t.phase == TouchPhase.Moved)
            {
                Debug.Log("touch is moving");
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchId == t.fingerId);
                Ray           ray       = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);

                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, mask))
                {
                    if (hit.point.z < playerBoundary1.Up)
                    {
                        Vector3 clampedMousePos1 = new Vector3(Mathf.Clamp(hit.point.x, playerBoundary1.Left, playerBoundary1.Right), hit.point.y,
                                                               Mathf.Clamp(hit.point.z, playerBoundary1.Down, playerBoundary1.Up));

                        rb1.MovePosition(clampedMousePos1);
                    }
                    if (hit.point.z > playerBoundary2.Down)
                    {
                        Vector3 clampedMousePos2 = new Vector3(Mathf.Clamp(hit.point.x, playerBoundary2.Left, playerBoundary2.Right), hit.point.y,
                                                               Mathf.Clamp(hit.point.z, playerBoundary2.Down, playerBoundary2.Up));

                        rb2.MovePosition(clampedMousePos2);
                    }
                }
            }
            ++i;
        }
    }
Exemplo n.º 4
0
    void Update()
    {
        int i = 0;

        while (i < Input.touchCount)
        {
            Touch t = Input.GetTouch(i);
            if (t.phase == TouchPhase.Began)
            {
                touches.Add(new touchLocation(t.fingerId, createCircle(t)));
            }
            else if (t.phase == TouchPhase.Ended)
            {
                touchLocation thisTouch = touches.Find(touchLocation => touchLocation.touchId == t.fingerId);
                Destroy(thisTouch.touchCircle);
                touches.RemoveAt(touches.IndexOf(thisTouch));
            }
            ++i;
        }
    }