void OnTouchStay(touchPerRecipient touchValues)
 {
     if (tokenId == tangibleId)
     {
         point = touchValues.touchList[0].point;
         MyOnMouseDrag();
     }
 }
Example #2
0
 private int checkTokenPlaced(touchPerRecipient touchValues)
 {
     //Debug.Log("tangibleTrack:checkTokenPlaced");
     return(kPatternId.findTokenId(
                touchValues.touchList[0].point,
                touchValues.touchList[0].fingerId,
                touchValues.touchList[1].point,
                touchValues.touchList[1].fingerId,
                touchValues.touchList[2].point,
                touchValues.touchList[2].fingerId)); // needs to be adjusted....
 }
 void OnTouchDown(touchPerRecipient touchValues)
 {
     tokenId = 0;
     if (touchValues.touchCount >= 3)
     {
         tokenId = checkTokenPlaced(touchValues);
         point   = touchValues.touchList[0].point;
         if (tokenId == tangibleId)
         {
             MyOnMouseDown();
         }
     }
 }
Example #4
0
 void OnTouchDown(touchPerRecipient touchValues)
 {
     tokenId = 0;
     if (touchValues.touchCount >= 3)
     {
         tokenId = checkTokenPlaced(touchValues);
         point   = touchValues.touchList[0].point;
         if (tokenId == id1)
         {
             Debug.Log("id1");
             Debug.Log(touchValues.triangleCenter);
             tangible1.transform.position = touchValues.triangleCenter;
         }
         else if (tokenId == id2)
         {
             Debug.Log("id2");
             Debug.Log(touchValues.triangleCenter);
             tangible2.transform.position = touchValues.triangleCenter;
         }
     }
 }
Example #5
0
    void Update()
    {
        if (Input.touchCount > 0)
        {
            touchesOld = new GameObject[touchList.Count];
            touchList.CopyTo(touchesOld);
            touchList.Clear();
            touchPerRecList.Clear();

            foreach (Touch touch in Input.touches)
            {
                //Debug.Log(touch.fingerId);
                //Debug.Log(touch.position);
                //Debug.Log("raw");
                //Debug.Log(touch.rawPosition);
                //Debug.Log(Input.mousePosition);

                containsRecipient = false;
                Ray ray = Camera.main.ScreenPointToRay(touch.position);

                if (Physics.Raycast(ray, out hit, touchInputMask))
                {
                    GameObject recipient = hit.transform.gameObject;
                    touchList.Add(recipient);
                    foreach (touchPerRecipient t in touchPerRecList)
                    {
                        //Debug.Log("Entered here!1");
                        if (t.recipient == recipient)
                        {
                            //Debug.Log("Entered here!2");
                            containsFingerId = false;
                            foreach (touchPointListElement i in t.touchList)
                            {
                                //Debug.Log(i.fingerId);
                                //Debug.Log(touch.fingerId);
                                if (i.fingerId == touch.fingerId)
                                {
                                    containsFingerId = true;
                                }
                            }

                            if (containsFingerId == false)
                            {
                                //Debug.Log("Entered here!3 - listing touches before insert");
                                touchPointListItem       = new touchPointListElement();
                                touchPointListItem.point = touch.position;
                                // touchPointListItem.point = hit.point;
                                touchPointListItem.hitPoint = hit.point;
                                touchPointListItem.fingerId = touch.fingerId;
                                t.recipient = recipient;
                                t.touchList.Add(touchPointListItem);
                                t.touchCount++;
                                containsRecipient = true;
                                touchRecipient    = t;
                                if (t.touchCount == 3)
                                {
                                    t.triangleCenter = findTriangleCenter(t.touchList[0].hitPoint, t.touchList[1].hitPoint, t.touchList[2].hitPoint);
                                }
                            }
                        }
                    }
                    //Debug.Log("Entered here!4");
                    if (containsRecipient == false)
                    {
                        touchRecipient            = new touchPerRecipient();
                        touchPointListItem        = new touchPointListElement();
                        touchRecipient.touchList  = new List <touchPointListElement>();
                        touchRecipient.recipient  = recipient;
                        touchRecipient.touchCount = 1;
                        touchPointListItem.point  = touch.position;
                        //touchPointListItem.point = hit.point;
                        touchPointListItem.hitPoint = hit.point;
                        touchPointListItem.fingerId = touch.fingerId;
                        touchRecipient.recipient    = recipient;
                        touchRecipient.touchList.Add(touchPointListItem);
                        touchPerRecList.Add(touchRecipient);
                    }
                    if (touch.phase == TouchPhase.Began)
                    {
                        recipient.SendMessage("OnTouchDown", touchRecipient, SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Ended)
                    {
                        recipient.SendMessage("OnTouchUp", touchRecipient, SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved)
                    {
                        recipient.SendMessage("OnTouchStay", touchRecipient, SendMessageOptions.DontRequireReceiver);
                    }
                    if (touch.phase == TouchPhase.Canceled)
                    {
                        recipient.SendMessage("OnTouchExit", touchRecipient, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
            foreach (GameObject g in touchesOld)
            {
                if (!touchList.Contains(g))
                {
                    g.SendMessage("OnTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
Example #6
0
 void OnTouchStay(touchPerRecipient touchValues)
 {
 }