コード例 #1
0
 private void PlatformSpecificViewTapUpdated(DigitalRubyShared.GestureRecognizer gesture)
 {
     if (gesture.State == GestureRecognizerState.Ended)
     {
         Debug.Log("You triple tapped the platform specific label!");
     }
 }
コード例 #2
0
 private void SwipeGestureCallback(DigitalRubyShared.GestureRecognizer gesture)
 {
     // Debug.LogFormat("TouchManager Swipe state: {0}", gesture.State);
     if (gesture.State == GestureRecognizerState.Ended)
     {
     }
 }
コード例 #3
0
 private void TapGesture_StateUpdated(DigitalRubyShared.GestureRecognizer gesture)
 {
     Debug.LogFormat("Single tap state: {0}", gesture.State);
     if (gesture.State == GestureRecognizerState.Ended)
     {
         Debug.LogFormat("Single tap at {0},{1}", gesture.FocusX, gesture.FocusY);
     }
 }
コード例 #4
0
 void TapUpdated(DigitalRubyShared.GestureRecognizer gesture)
 {
     Debug.Log(gesture.FocusX);
     if (gesture.State == GestureRecognizerState.Ended)
     {
         if ((gesture as TapGestureRecognizer).TapTouches.Count == 2)
         {
             command.Jump();
         }
     }
 }
コード例 #5
0
 private void LongPressGestureCallback(DigitalRubyShared.GestureRecognizer gesture)
 {
     //  Debug.LogFormat("TouchManager LongPress state: {0}", gesture.State);
     if (gesture.State == GestureRecognizerState.Began)
     {
     }
     else if (gesture.State == GestureRecognizerState.Executing)
     {
     }
     else if (gesture.State == GestureRecognizerState.Ended)
     {
     }
 }
コード例 #6
0
    private void Swipe_Updated(DigitalRubyShared.GestureRecognizer gesture)
    {
        //Debug.LogFormat("Swipe state: {0}", gesture.State);

        SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer;

        if (swipe.State == GestureRecognizerState.Ended)
        {
            if (swipe.EndDirection.Equals(SwipeGestureRecognizerDirection.Right))
            {
                photoPickerController.SwipeRight();
            }
            else if (swipe.EndDirection.Equals(SwipeGestureRecognizerDirection.Left))
            {
                photoPickerController.SwipeLeft();
            }
        }
    }
コード例 #7
0
    void SwipeUpdated(DigitalRubyShared.GestureRecognizer gesture)
    {
        SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer;

        if (swipe.State == GestureRecognizerState.Ended)
        {
            if (swipe.FocusX < Screen.width / 2)
            {
                if (swipe.EndDirection == SwipeGestureRecognizerDirection.Up)
                {
                    command.Jump();
                }
                else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Left)
                {
                    command.MoveLeft();
                }
                else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Right)
                {
                    command.MoveRight();
                }
            }

            if (swipe.FocusX > Screen.width / 2)
            {
                if (swipe.EndDirection == SwipeGestureRecognizerDirection.Up)
                {
                    command.MakePoseUp();
                }
                else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Down)
                {
                    command.MakePoseDown();
                }
                else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Left)
                {
                    command.MakePoseLeft();
                }
                else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Right)
                {
                    command.MakePoseRight();
                }
            }
        }
    }
コード例 #8
0
    void SwipeUpdated(DigitalRubyShared.GestureRecognizer gesture)
    {
        SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer;

        if (swipe.State == GestureRecognizerState.Ended)
        {
            if (swipe.EndDirection == SwipeGestureRecognizerDirection.Up)
            {
                command.Jump();
            }
            else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Left)
            {
                command.MoveLeft();
            }
            else if (swipe.EndDirection == SwipeGestureRecognizerDirection.Right)
            {
                command.MoveRight();
            }
        }
    }
コード例 #9
0
    private void DoubleTapGesture_StateUpdated(DigitalRubyShared.GestureRecognizer gesture)
    {
        Debug.LogFormat("Double tap state: {0}", gesture.State);
        if (gesture.State == GestureRecognizerState.Ended)
        {
            Debug.LogFormat("Double tap at {0},{1}", gesture.FocusX, gesture.FocusY);

            PointerEventData p = new PointerEventData(EventSystem.current);
            p.position = new Vector2(gesture.FocusX, gesture.FocusY);
            raycast.Clear();
            EventSystem.current.RaycastAll(p, raycast);
            foreach (RaycastResult result in raycast)
            {
                if (result.gameObject.name == "BlockDoubleTappable")
                {
                    print(result.gameObject.GetComponent <Block>().color);
                    this.blockDoubleTapManager.NotifyBlockDoubleTapped(result.gameObject);
                    break;
                }
            }
        }
    }
コード例 #10
0
        private void Swipe_Updated(GestureRecognizer gesture, ICollection <GestureTouch> touches)
        {
            SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer;

            if (swipe.State == GestureRecognizerState.Began)
            {
                float angle = Mathf.Atan2(-swipe.DistanceY, swipe.DistanceX) * Mathf.Rad2Deg;
                SwipeParticleSystem.transform.rotation = Quaternion.Euler(angle, 90.0f, 0.0f);
                Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(gesture.StartFocusX, gesture.StartFocusY, 0.0f));
                pos.z = 0.0f;
                SwipeParticleSystem.transform.position = pos;
                SwipeParticleSystem.Play();
                Debug.Log("Swipe began!");
            }
            else if (swipe.State == GestureRecognizerState.Executing)
            {
                Debug.Log("Swipe executing!");
            }
            else if (swipe.State == GestureRecognizerState.Ended)
            {
                Debug.Log("Swipe ended!");
            }
        }
コード例 #11
0
 private void Tap_Updated(GestureRecognizer gesture)
 {
     if (scaleEnd == 0.0f && gesture.State == GestureRecognizerState.Ended)
     {
         scaleStart       = rt.localScale.x;
         scaleTime        = 0.5f;
         elapsedScaleTime = 0.0f;
         if (ScrollContent.transform.localScale.x >= 2.5f)
         {
             // zoom out
             scaleEnd = 1.0f;
         }
         else
         {
             // zoom in
             scaleEnd = 4.0f;
         }
         scalePosStart = rt.anchoredPosition;
         Vector2 localPoint;
         RectTransformUtility.ScreenPointToLocalPointInRectangle(rt, new Vector2(gesture.FocusX, gesture.FocusY), null, out localPoint);
         scalePosEnd = localPoint * -scaleEnd;
     }
 }
コード例 #12
0
 private void PanGesture_Updated(GestureRecognizer gesture)
 {
     // if gesture is not executing, exit function
     if (gesture.State != GestureRecognizerState.Executing)
     {
         if (gesture.State == GestureRecognizerState.Ended)
         {
             lockedAxis = 0;
             if (OrbitInertia > 0.0f)
             {
                 panVelocity = new Vector2(gesture.VelocityX * 0.01f, gesture.VelocityY * 0.01f);
                 if (OrbitXSpeed == 0.0f)
                 {
                     panVelocity.x = 0.0f;
                 }
                 if (OrbitYSpeed == 0.0f)
                 {
                     panVelocity.y = 0.0f;
                 }
             }
         }
         else if (gesture.State == GestureRecognizerState.Began)
         {
             panVelocity = Vector2.zero;
         }
         return;
     }
     else
     {
         float xVelocity = gesture.DeltaX;
         float yVelocity = gesture.DeltaY;
         if (PanGestureHasEnoughMovementOnOneAxis(ref xVelocity, ref yVelocity))
         {
             UpdateOrbit(xVelocity, yVelocity);
         }
     }
 }
コード例 #13
0
 private void PanGestureUpdated(GestureRecognizer r, ICollection <GestureTouch> touches)
 {
     // OWENEDIT: RETURN TO PREVENT EDITS WHEN MENUS ARE OPEN
     if (AppController.FingersGestureAllowed == false)
     {
         return;
     }
     StartOrResetGesture(r, BringToFront, Camera, gameObject, spriteRenderer);
     if (r.State == GestureRecognizerState.Began)
     {
         AppController.FingersGestureInProgress = 1;                                     // ################ OWENEDIT ################
         panStart = (rigidBody == null ? (Vector2)gameObject.transform.position : rigidBody.position);
     }
     else if (r.State == GestureRecognizerState.Executing)
     {
         AppController.FingersGestureInProgress = 1;                                     // ################ OWENEDIT ################
         Vector2 screenMovement = new Vector2(panGesture.DistanceX, panGesture.DistanceY);
         Vector2 worldMovement  = Camera.ScreenToWorldPoint(screenMovement) - Camera.ScreenToWorldPoint(Vector2.zero);
         //Debug.LogFormat("Screen movement: {0}, World movement: {1}", screenMovement, worldMovement);
         if (rigidBody == null)
         {
             transform.position = panStart + worldMovement;
         }
         else
         {
             rigidBody.MovePosition(panStart + worldMovement);
         }
     }
     else if (r.State == GestureRecognizerState.Ended)
     {
         AppController.FingersGestureInProgress = 0;                                     // ################ OWENEDIT ################
         if (spriteRenderer != null && BringToFront)
         {
             spriteRenderer.sortingOrder = startSortOrder;
         }
     }
 }
コード例 #14
0
 private void ImageGestureUpdated(GestureRecognizer imageGesture)
 {
     if (imageGesture.State == GestureRecognizerState.Ended)
     {
         AddTouches(imageGesture.CurrentTrackedTouches);
         UpdateImage();
         UpdateScriptText();
         // note - if you have received an image you care about, you should reset the image gesture, i.e. imageGesture.Reset()
         // the ImageGestureRecognizer doesn't automaticaly Reset like other gestures when it ends because some images need multiple paths
         // which requires lifting the mouse or finger and drawing again
     }
     else if (imageGesture.State == GestureRecognizerState.Began)
     {
         // began
         currentPointList = new List <Vector2>();
         lineSet.Add(currentPointList);
         AddTouches(imageGesture.CurrentTrackedTouches);
     }
     else if (imageGesture.State == GestureRecognizerState.Executing)
     {
         // moving
         AddTouches(imageGesture.CurrentTrackedTouches);
     }
 }
コード例 #15
0
        private ICollection <GestureTouch> FilterTouches(ICollection <GestureTouch> touches, GestureRecognizer r)
        {
            // if any gestures are over an object that is not allowing touches, remove them
            List <GameObject> gameObjects;

            filteredTouches.Clear();
            foreach (GestureTouch t in touches)
            {
                if (!gameObjectsForTouch.TryGetValue(t.Id, out gameObjects) || GameObjectMatchesPlatformSpecificView(gameObjects, r.PlatformSpecificView as GameObject))
                {
                    filteredTouches.Add(t);
                }
            }
            return(filteredTouches);
        }
コード例 #16
0
 private void PushGesture(GestureRecognizer gesture)
 {
     gestures.Add(gesture);
 }
コード例 #17
0
ファイル: FingersScript.cs プロジェクト: disklessGames/swarm
        private ICollection <GestureTouch> FilterTouchesBegan(List <GestureTouch> touches, GestureRecognizer r)
        {
            // in order to begin, touches must match the platform specific view
            List <GameObject> gameObjects;

            filteredTouches.Clear();
            foreach (GestureTouch t in touches)
            {
                if (!gameObjectsForTouch.TryGetValue(t.Id, out gameObjects) || GameObjectMatchesPlatformSpecificView(gameObjects, r))
                {
                    filteredTouches.Add(t);
                }
            }
            return(filteredTouches);
        }
コード例 #18
0
 private void Tap_StateUpdated(GestureRecognizer gesture)
 {
     Log("Tap gesture, state: {0}, position: {1},{2}", gesture.State, gesture.FocusX, gesture.FocusY);
 }
コード例 #19
0
 /// <summary>
 /// Remove a gesture from the script. The gesture will no longer give callbacks.
 /// </summary>
 /// <param name="gesture">Gesture to remove</param>
 /// <returns>True if the gesture was removed, false if it was not in the script</returns>
 public bool RemoveGesture(GestureRecognizer gesture)
 {
     return(gestures.Remove(gesture));
 }
コード例 #20
0
 private void Pan_Updated(GestureRecognizer gesture)
 {
     //Log("Pan gesture, state: {0}, position: {1},{2}", gesture.State, gesture.FocusX, gesture.FocusY);
 }
コード例 #21
0
 private void RotationGesture_Updated(GestureRecognizer gesture)
 {
     Orbiter.transform.RotateAround(OrbitTarget.transform.position, Axis, rotationGesture.RotationDegreesDelta * Time.deltaTime * RotationSpeed);
 }
コード例 #22
0
        private void LongPress_StateUpdated(GestureRecognizer gesture)
        {
            if (gesture.State == GestureRecognizerState.Began)
            {
                // raycast out for the card - this let's us have multiple cards
                Vector3    gestureWorldPos = Camera.main.ScreenToWorldPoint(new Vector3(gesture.FocusX, gesture.FocusY, 0.0f));
                Collider2D hit             = Physics2D.OverlapPoint(gestureWorldPos);

                // see if we found a card
                if (hit != null && !swipedCards.Contains(hit.transform))
                {
                    // set the draggingCard variable to the card transform, this let's us move it around in the "Executing" state
                    Debug.Log("Found card, beginning drag...");
                    draggingCard            = hit.GetComponent <Transform>();
                    draggingCard.localScale = Vector3.one * 1.2f;
                }
                else
                {
                    // no card, reset the gesture and they must lift the touch and try again
                    Debug.Log("No card under gesture, resetting...");
                    gesture.Reset();
                }

                // apply an offset from the center of the card so it drags from wherever it was touched on the card
                dragOffset   = draggingCard.position - Camera.main.ScreenToWorldPoint(new Vector3(gesture.FocusX, gesture.FocusY, 0.0f));
                dragOffset.z = 0.0f;
            }
            else if (gesture.State == GestureRecognizerState.Executing)
            {
                // if the gesture velocity is high enough, fling the card off screen
                float speed = longPress.Distance(gesture.VelocityX, gesture.VelocityY);
                if (speed >= SwipeAwaySpeed)
                {
                    // convert the screen units velocity to world velocity and apply to the card
                    draggingCard.localScale = Vector3.one;
                    Vector3 worldVelocityZero    = Camera.main.ScreenToWorldPoint(Vector3.zero);
                    Vector3 worldVelocityGesture = Camera.main.ScreenToWorldPoint(new Vector3(gesture.VelocityX, gesture.VelocityY, 0.0f));
                    Vector3 worldVelocity        = (worldVelocityGesture - worldVelocityZero) * 0.5f;
                    worldVelocity.z = 0.0f;
                    Rigidbody2D rb = draggingCard.GetComponent <Rigidbody2D>();
                    rb.velocity = worldVelocity;

                    // apply some random spin for fun
                    rb.angularVelocity = Random.Range(-1000.0f, 1000.0f);

                    // don't allow the card to be re-dragged while it flings away
                    swipedCards.Add(draggingCard);
                    draggingCard = null;

                    // reset gesture, the swipe away finishes the gesture
                    gesture.Reset();

                    Debug.LogFormat("Swiping card away at world velocity {0} (screen velocity units {1})", (Vector2)worldVelocity, new Vector2(gesture.VelocityX, gesture.VelocityY));
                }
                else
                {
                    // drag the card
                    Vector3 dragCurrent = Camera.main.ScreenToWorldPoint(new Vector3(gesture.FocusX, gesture.FocusY, 0.0f));
                    dragCurrent.z         = draggingCard.transform.position.z;
                    draggingCard.position = dragCurrent + dragOffset;
                }
            }
            else
            {
                // if not begin or execute state, null out the dragging card
                if (draggingCard != null)
                {
                    draggingCard.localScale = Vector3.one;
                }
                draggingCard = null;
            }
        }
コード例 #23
0
 private void Panned(GestureRecognizer panGesture)
 {
     if (panGesture.State == GestureRecognizerState.Began)
     {
         if (PanAnchor != null)
         {
             PanAnchor.enabled            = true;
             PanAnchor.transform.position = new Vector3(panGesture.StartFocusX, panGesture.StartFocusY, PanAnchor.transform.position.z);
         }
         if (PanAnchorLine != null)
         {
             PanAnchorLine.enabled = true;
             PanAnchorLine.DrawLine(Vector2.zero, Vector2.zero, 0.0f);
         }
     }
     else if (panGesture.State == GestureRecognizerState.Executing)
     {
         float unitsX = DeviceInfo.PixelsToUnits(panGesture.DistanceX);
         float unitsY = DeviceInfo.PixelsToUnits(panGesture.DistanceY);
         float panX   = Mathf.Sign(unitsX) * Mathf.Lerp(0.0f, 1.0f, Mathf.Abs(unitsX) / PanUnitsForMaxMove);
         float panY   = Mathf.Sign(unitsY) * Mathf.Lerp(0.0f, 1.0f, Mathf.Abs(unitsY) / PanUnitsForMaxMove);
         if (PanCallback != null)
         {
             PanCallback.Invoke(new Vector2(panX, panY));
         }
         if (crossPlatformInputHorizontalAxisObject != null)
         {
             FingersCrossPlatformInputReflectionScript.UpdateVirtualAxis(crossPlatformInputHorizontalAxisObject, panX);
         }
         if (crossPlatformInputVerticalAxisObject != null)
         {
             FingersCrossPlatformInputReflectionScript.UpdateVirtualAxis(crossPlatformInputVerticalAxisObject, panY);
         }
         if (PanAnchor != null)
         {
             panLocation = new Vector2(panGesture.FocusX, panGesture.FocusY);
         }
     }
     else if (panGesture.State == GestureRecognizerState.Ended || panGesture.State == GestureRecognizerState.Failed)
     {
         if (PanCallback != null)
         {
             PanCallback.Invoke(new Vector2(0.0f, 0.0f));
         }
         if (crossPlatformInputHorizontalAxisObject != null)
         {
             FingersCrossPlatformInputReflectionScript.UpdateVirtualAxis(crossPlatformInputHorizontalAxisObject, 0.0f);
         }
         if (crossPlatformInputVerticalAxisObject != null)
         {
             FingersCrossPlatformInputReflectionScript.UpdateVirtualAxis(crossPlatformInputVerticalAxisObject, 0.0f);
         }
         if (PanAnchor != null)
         {
             PanAnchor.enabled = false;
             panLocation       = Vector2.zero;
         }
         if (PanAnchorLine != null)
         {
             PanAnchorLine.enabled = false;
         }
     }
 }
コード例 #24
0
ファイル: DemoScriptComponent.cs プロジェクト: lwb4/tetris
 public void PanGestureExecuted(GestureRecognizer gesture)
 {
     Debug.LogFormat("Pan gesture executing, state: {0}, pos: {1},{2}", gesture.State, gesture.FocusX, gesture.FocusY);
 }
コード例 #25
0
ファイル: DemoScriptComponent.cs プロジェクト: lwb4/tetris
 public void LongPressGestureExecuted(GestureRecognizer gesture)
 {
     Debug.LogFormat("Long press gesture executing, state: {0}, pos: {1},{2}", gesture.State, gesture.FocusX, gesture.FocusY);
 }
コード例 #26
0
ファイル: DemoScriptComponent.cs プロジェクト: lwb4/tetris
 public void RotateGestureExecuted(GestureRecognizer gesture)
 {
     Debug.LogFormat("Rotate gesture executing, state: {0}, degrees: {1} pos: {2},{3}", gesture.State, (gesture as RotateGestureRecognizer).RotationDegrees, gesture.FocusX, gesture.FocusY);
 }
コード例 #27
0
ファイル: DemoScriptComponent.cs プロジェクト: lwb4/tetris
 public void OneTouchScaleGestureExecuted(GestureRecognizer gesture)
 {
     oneTouchScale *= (gesture as OneTouchScaleGestureRecognizer).ScaleMultiplier;
     Debug.LogFormat("Scale gesture executing, state: {0}, scale: {1} pos: {2},{3}", gesture.State, oneTouchScale, gesture.FocusX, gesture.FocusY);
 }
コード例 #28
0
ファイル: DemoScriptComponent.cs プロジェクト: lwb4/tetris
 public void SwipeGestureExecuted(GestureRecognizer gesture)
 {
     Debug.LogFormat("Swipe gesture executing, state: {0}, dir: {1} pos: {2},{3}", gesture.State, (gesture as SwipeGestureRecognizer).EndDirection, gesture.FocusX, gesture.FocusY);
 }
コード例 #29
0
        private void LetterGestureUpdated(GestureRecognizer gesture)
        {
            //Debug.Log("Pan state " + gesture.State);

            if (gesture.State == GestureRecognizerState.Began)
            {
                PointerEventData p = new PointerEventData(EventSystem.current);
                p.position = new Vector2(gesture.FocusX, gesture.FocusY);
                raycast.Clear();
                EventSystem.current.RaycastAll(p, raycast);
                foreach (RaycastResult result in raycast)
                {
                    if (result.gameObject.name.IndexOf("BlockDraggable", System.StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        print("DRAGGABLE FOUND BOUNDARIES");
                        // we have a letter!
                        this.boundaries = this.blockDragManager.NotifyDraggingBlockStart(result.gameObject);
                        //print("BOUNDARIES:" + this.boundaries[0]);
                        //print("BOUNDARIES:" + this.boundaries[1]);
                        Vector2 dragPos = FingersUtility.ScreenToCanvasPoint(canvas, new Vector2(gesture.FocusX, gesture.FocusY));
                        draggingLetter = result.gameObject.transform;
                        dragOffset     = (Vector2)draggingLetter.position - dragPos;
                        break;
                    }
                }
                if (draggingLetter == null)
                {
                    gesture.Reset();
                }
            }
            else if (gesture.State == GestureRecognizerState.Executing)
            {
                this.boundaries = this.blockDragManager.CalculateBlockBoundaries(this.draggingLetter.gameObject);


                Vector2 dragPos = FingersUtility.ScreenToCanvasPoint(canvas, new Vector2(gesture.FocusX, gesture.FocusY));
                Vector3 pos     = draggingLetter.transform.position;

                // don't mess with the z
                float newPosition = dragPos.x + dragOffset.x;
                float containerX  = this.container.GetComponent <RectTransform>().position.x;

                if (newPosition >= this.boundaries[0] + containerX && newPosition <= this.boundaries[1] + containerX)
                {
                    this.lastDelta = newPosition - pos.x;
                    pos.x          = newPosition;
                    //pos.y = dragPos.y + dragOffset.y;

                    draggingLetter.transform.position = pos;
                }
                else
                {
                    //print("DRAGGABLE BOUNDARIES BLOCK");
                    //print("BOUNDARIES:" + this.boundaries[0]);
                    //print("BOUNDARIES:" + this.boundaries[1]);
                }
            }
            else if (gesture.State == GestureRecognizerState.Ended)
            {
                this.blockDragManager.NotifyDraggingBlockEnd(draggingLetter.gameObject, this.lastDelta);

                GameObject gameObject = draggingLetter.gameObject;

                draggingLetter = null;
            }
        }
コード例 #30
0
 private void Pan_Updated(GestureRecognizer gesture, ICollection <GestureTouch> touches)
 {
     Debug.LogFormat("Pan gesture, state: {0}, position: {1},{2}", gesture.State, gesture.FocusX, gesture.FocusY);
 }