Example #1
0
    void OnDrag(DragGesture gesture)
    {
        // first finger
        FingerGestures.Finger finger = gesture.Fingers[0];

        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
            // dismiss this event if we're not interacting with our drag object
            if (gesture.Selection != dragObject)
            {
                return;
            }

            Debug.Log("Started dragging with finger " + finger);

            // remember which finger is dragging dragObject
            dragFingerIndex = finger.Index;
        }
        else if (finger.Index == dragFingerIndex)   // gesture in progress, make sure that this event comes from the finger that is dragging our dragObject
        {
            if (gesture.Phase == ContinuousGesturePhase.Updated)
            {
                // update the position by converting the current screen position of the finger to a world position on the Z = 0 plane
                dragObject.transform.position = GetWorldPos(gesture.Position);
            }
            else
            {
                Debug.Log("Stopped dragging with finger " + finger);

                // reset our drag finger index
                dragFingerIndex = -1;
            }
        }
    }
Example #2
0
    //只对第一只手指的拖动动作有效,这里不暴露finger给用户是因为不想封装比较复杂的finger类,
    //以后要用两三只finger的操作 就再另外封装方法。
    void FirstFingerDragEventHandler(DragGesture gesture)
    {
        //没有用触屏机器测试,但估计Fingers[0]并不是代表第一只点击屏幕的的手指,
        //finger.Index才是,记录第几只开始触发的手指。两三只手指同时触发时
        //fingers[0].index是不同的。
        FingerGestures.Finger finger = gesture.Fingers[0];
        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
            dragFingerIndex = finger.Index;
        }

        if (dragFingerIndex != finger.Index)
        {
            return;
        }

        //下面的内容保证是第一只手指触发的。


        if (firstFingerDragMethods != null)
        {
            firstFingerDragMethods(gesture.Position, gesture.Selection, gesture.DeltaMove, ContinuousGesturePhaseConvertor(gesture.Phase));
        }

        //第一只手指收起,重置第一只手指index。
        if (gesture.Phase == ContinuousGesturePhase.Ended ||
            gesture.Phase == ContinuousGesturePhase.None)
        {
            dragFingerIndex = -1;
        }
    }
        void OnDrag(DragGesture gesture)
        {
            if (!HomeBuildingManager.GetInstance().Contains(gesture.Selection))
            {
                return;
            }

            //相机停止移动
            FingerCamera.GetInstance().couldDrag = false;
            // first finger
            FingerGestures.Finger finger = gesture.Fingers[0];

            if (gesture.Phase == ContinuousGesturePhase.Started)
            {
                dragFingerIndex = finger.Index;
            }
            else if (finger.Index == dragFingerIndex)  // gesture in progress, make sure that this event comes from the finger that is dragging our dragObject
            {
                if (gesture.Phase == ContinuousGesturePhase.Updated)
                {
                    //transform.position = ScreenPointToWorldPlane(gesture.Position);
                    gesture.Selection.transform.position = ScreenPointToWorldPlane(gesture.Position);
                }
                else
                {
                    dragFingerIndex = -1;
                    FingerCamera.GetInstance().couldDrag = true;
                    var gridPos    = HomeGridManager.GetInstance().WorldPosToGridPos(gesture.Selection.transform.position);
                    var cellCenter = HomeGridManager.GetInstance().GridPosToCellCenterInWorld(gridPos);
                    //transform.position = cellCenter;
                    gesture.Selection.transform.position = cellCenter;
                    SoundManager.GetInstance().PlaySound("sound/build_pickup_05");
                }
            }
        }
Example #4
0
    /// <summary>
    /// Updates the trail.
    /// </summary>
    /// <param name="gesture">Gesture.</param>
    private void UpdateTrail(DragGesture gesture)
    {
        ContinuousGesturePhase ePhase = gesture.Phase;

        // the screen position the user's finger is at currently
        Vector2 vPos = gesture.Position;

        // based on phase of the gesture, call certain functions
        switch (ePhase)
        {
        case ContinuousGesturePhase.Started:
            trail.DragStarted(vPos);
            break;

        case ContinuousGesturePhase.Updated:
            trail.DragUpdated(vPos);
            break;

        case ContinuousGesturePhase.Ended:
            trail.DragEnded();
            break;
        }

        // save the last position for use with displaying combo
        //lastPos = vPos;
        trailDeltaMove = gesture.DeltaMove;
    }
Example #5
0
 // Handle Gesture Event (sent by the DragRecognizer component)
 void OnDrag( DragGesture gesture )
 {
     if( gesture.Phase != ContinuousGesturePhase.Ended && !bIsInsideKeyRec)
         dragGesture = gesture;
     else
         dragGesture = null;
 }
 public override void OnDrag(DragGesture gesture)
 {
     if (_Controller)
     {
         _Controller.OnDrag(gesture);
     }
 }
Example #7
0
        public void OnTwoFingerDrag(DragGesture drag)
        {
            InputMessage.MessageTypes type = InputMessage.MessageTypes.Failed;

            switch (drag.Phase)
            {
            case ContinuousGesturePhase.Started:
                type = InputMessage.MessageTypes.Begin;
                break;

            case ContinuousGesturePhase.Updated:
                type = InputMessage.MessageTypes.Update;
                break;

            case ContinuousGesturePhase.Ended:
                type = InputMessage.MessageTypes.End;
                break;

            default:
                break;
            }

            _updates.Add(new InputMessage(
                             InputMessage.InputTypes.TwoFingerDrag,
                             type,
                             drag.Fingers.Select(f => f.Position).ToList(),
                             drag.Fingers.Select(f => f.DeltaPosition).ToList()
                             ));
        }
Example #8
0
    //private bool allowAttack = true;

    /*
     * void OnTap(TapGesture gesture)
     * {
     *              StartPosition = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(0);
     *
     * if(currentState != MooseState.None) return;
     * touchPosition = Camera.main.ScreenToWorldPoint(gesture.Position);
     * touchPosition = new Vector3(touchPosition.x, touchPosition.y, myTransform.position.z);
     * lastMoveSqrMag = Mathf.Infinity;
     * moveToDirection = (touchPosition - myTransform.position).normalized;
     *
     * }
     */

    void OnDrag(DragGesture gesture)
    {
        if (state == MooseState.Dying || state == MooseState.Dead || state == MooseState.Respawn)
        {
            return;
        }



        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
            Vector2 touchPosition = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(0);
            TouchBegan(touchPosition);
        }
        else if (gesture.Phase == ContinuousGesturePhase.Updated)
        {
            Vector2 touchPosition = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(0);
            TouchMoved(touchPosition);
        }
        else if (gesture.Phase == ContinuousGesturePhase.Ended)
        {
            Vector2 touchPosition = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(0);
            TouchEnded(touchPosition);
        }
    }
Example #9
0
 void OnDrag(DragGesture gesture)
 {
     if (Time.timeScale != 0)
     {
         HandleDrag(gesture);
     }
 }
Example #10
0
    void OnTwoFingerDrag(DragGesture gesture)
    {
        if (allowPanning)
        {
            Vector3 move = -panningSensitivity * (panningPlane.right * gesture.DeltaMove.x.Centimeters() + panningPlane.up * gesture.DeltaMove.y.Centimeters());

            if (invertPanningDirections)
            {
                IdealPanOffset -= move;
            }
            else
            {
                IdealPanOffset += move;
            }


//			// use the vertical pan to keep the fretboard aligned with edge
//			Camera cam = GetComponent<Camera>();
//			Debug.Log(cam.ViewportToWorldPoint (new Vector3(0.5f, 1, 0.5f)) + " and the target is at: " + target.transform.position);
//			float panShift = cam.ViewportToWorldPoint (new Vector3(0.5f, 1, 4f)).y + target.transform.position.z;
//			idealPanOffset += new Vector3(0, 0, panShift);
//			// END


            nextDragTime = Time.time + 0.25f;
        }
    }
Example #11
0
        void OnDrag_Normal(DragGesture gesture)
        {
            if (gesture.State == GestureRecognitionState.InProgress && CouldDrag())
            {
                dragGesture = gesture;
                if (dragGesture.DeltaMove.SqrMagnitude() > 0)
                {
                    Vector2 screenSpaceMove = dragSensitivity * dragGesture.DeltaMove;
                    Vector3 worldSpaceMove  = screenSpaceMove.x * cacheTrans.right + screenSpaceMove.y * cacheTrans.up;

                    dragMoveTo.x -= worldSpaceMove.x;
                    dragMoveTo.z -= worldSpaceMove.z;

                    dragMoveTo2D.x = dragMoveTo.x;
                    dragMoveTo2D.y = dragMoveTo.z;
                    if (CouldMoveTo(dragMoveTo2D))
                    {
                        cacheTrans.position = dragMoveTo;
                    }
                    else
                    {
                        WhenCannotMoveTo(dragMoveTo2D);
                    }
                }
            }
        }
Example #12
0
 // Handle Gesture Event (sent by the DragRecognizer component)
 void OnDrag( DragGesture gesture )
 {
     if( gesture.Phase != ContinuousGesturePhase.Ended )
         dragGesture = gesture;
     else
         dragGesture = null;
 }
Example #13
0
    public override void OnDrag(DragGesture gesture)
    {
        if (_Pinching)
        {
            return;
        }


        base.OnDrag(gesture);
        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
            mEntity.SetVelocityCameraUp(0);
            _Draging = true;
            mEntity.StartPullEnergy();
        }
        else if (gesture.Phase == ContinuousGesturePhase.Updated)
        {
            _Draging = true;
            if (gesture.LastDelta.y != 0)
            {
                _LastY = gesture.LastDelta.y;
            }
            mEntity.RotateCameraRight(gesture.LastDelta.y);
            mEntity.RotateCameraUp(-gesture.LastDelta.x);

            mEntity.AddPullEnergy(gesture.LastDelta.x);
        }
        else if (gesture.Phase == ContinuousGesturePhase.Ended)
        {
            mEntity.GoToPullOrBounce();

            _Draging = false;
        }
    }
        /*
        // TODO: Impliment Swipe

        public void OnSwipe(SwipeGesture swipe)
        {
            Vector2 velocity = new Vector2();

            switch (swipe.Direction) {
                case FingerGestures.SwipeDirection.Right:
                    velocity = Vector2.right * swipe.Velocity;
                    break;
                case FingerGestures.SwipeDirection.Left:
                    velocity = Vector2.right * -swipe.Velocity;
                    break;
                case FingerGestures.SwipeDirection.Up:
                    velocity = Vector2.up * swipe.Velocity;
                    break;
                case FingerGestures.SwipeDirection.Down:
                    velocity = Vector2.up * -swipe.Velocity;
                    break;
            }

            HandleDragMoveEvent(swipe.Position, velocity, _swipeZones, true);
        }

        */
        public void OnDrag(DragGesture drag)
        {
            InputMessage.MessageTypes type = InputMessage.MessageTypes.Failed;

            switch (drag.Phase) {
                case ContinuousGesturePhase.Started:
                    type = InputMessage.MessageTypes.Begin;
                    break;
                case ContinuousGesturePhase.Updated:
                    type = InputMessage.MessageTypes.Update;
                    break;
                case ContinuousGesturePhase.Ended:
                    type = InputMessage.MessageTypes.End;
                    break;
                default:
                    break;

            }

            _updates.Add(new InputMessage(
                InputMessage.InputTypes.OneFingerDrag,
                type,
                drag.Fingers.Select(f => f.Position).ToList(),
                drag.Fingers.Select(f => f.DeltaPosition).ToList()
            ));
        }
Example #15
0
    public void OnDrag(DragGesture gesture)
    {
        //GuiTextDebug.Debug("OnDrag");
        m_bIsPinch = false;
        m_bIsDrag  = true;

        FingerGestures.Finger finger = gesture.Fingers[0];
        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
            m_iDragFingerIndex = finger.Index;
            ClearData();
            FingerStart(gesture);
        }
        else if (finger.Index == m_iDragFingerIndex)
        {
            if (gesture.Phase == ContinuousGesturePhase.Updated)
            {
                FingerMove(gesture);
            }
            else
            {
                m_iDragFingerIndex = -1;
                //if (m_v3TouchPostions.Count >= 2)
                {
                    FingerUp(gesture);
                }
            }
        }
    }
Example #16
0
        public static IEnumerator <object> PickColorProcessor(Widget widget, Action <Color4> setter)
        {
            var input = CommonWindow.Current.Input;

            Document.Current.History.BeginTransaction();
            var drag = new DragGesture();

            widget.Gestures.Add(drag);
            yield return(null);

            while (true)
            {
                if (drag.WasBegan())
                {
                    input.ConsumeKey(Key.Mouse0);
                    WidgetContext.Current.Root.Input.ConsumeKey(Key.Mouse0);
                    while (!drag.WasEnded())
                    {
                        Utils.ChangeCursorIfDefault(Cursors.Pipette);
                        setter(ColorPicker.PickAtCursor());
                        yield return(null);
                    }
                    Utils.ChangeCursorIfDefault(MouseCursor.Default);
                    Document.Current.History.EndTransaction();
                }
                yield return(null);
            }
        }
Example #17
0
        private void OnDrag(DragGesture gesture)
        {
            if (gesture.Selection == null)
            {
                return;
            }

            FingerGestures.Finger finger = gesture.Fingers[0];

            if (gesture.Phase == ContinuousGesturePhase.Started)
            {
                _dragScroll = gesture.Selection.GetComponent <Scroll>();

                if (_dragScroll == null)
                {
                    return;
                }

                _dragFingerIndex = finger.Index;
            }
            else if (finger.Index == _dragFingerIndex && _dragScroll != null)  // gesture in progress, make sure that this event comes from the finger that is dragging our dragObject
            {
                if (gesture.Phase == ContinuousGesturePhase.Updated)
                {
                    _dragScroll.DragScroll(gesture.StartPosition, gesture.Position);
                }
                else
                {
                    _dragScroll.StopScrolling();

                    _dragFingerIndex = -1;
                }
            }
        }
Example #18
0
    /// <summary>
    /// Raises the drag gesture event. This event is raised by FingerGestures's DragRecognizer component.
    /// Determine the selected tile and in which direction the user dragged it and tell the <see cref="Match3BoardGameLogic"/>
    /// that we've started moving that tile in that direction.
    /// </summary>
    /// <param name='eventData'>
    /// Event data.
    /// </param>
    public void OnDragGesture(DragGesture eventData)
    {
        if (dragLock > 0)
        {
            tapSelectedTile = null;
            return;
        }

        // Check if we've selected any tile.
        if (eventData.StartSelection != null && eventData.StartSelection.layer == Match3Globals.Instance.layerBoardTile)
        {
            if (eventData.Phase == ContinuousGesturePhase.Started)
            {
                // Cancel the tap selected tile if we've done a drag gesture.
                tapSelectedTile = null;

                AbstractTile      dragSelectedTile = eventData.StartSelection.GetComponent <AbstractTile>();
                TileMoveDirection moveDirection    = Match3BoardGameLogic.GetTileMoveDirection(eventData.TotalMove);

                if (InputFilter == null || InputFilter(dragSelectedTile, null, moveDirection))
                {
//					Debug.Log("Drag event started! Start Selection: " + eventData.StartSelection + " -> totalMove = " + eventData.TotalMove);
                    if (boardGameLogic.TryToMoveTile(dragSelectedTile, moveDirection))
                    {
                        //boardGameLogic.loseConditions.NewMove();
                    }
                }
            }
        }
    }
Example #19
0
        void OnDrag(DragGesture gesture)
        {
            if (gesture.Selection && _isGesture == true && _isEventPopUp == false)
            {
                if (_controlObject != null)
                {
                    if (gesture.State == GestureRecognitionState.Ended)
                    {
                        _dragStartPosition = new Vector3(gesture.Position.x - (Screen.width * 0.5f), gesture.Position.y - (Screen.height * 0.5f), 0);
                    }

                    //上を中心として回転処理
                    Vector2 basepos = _rotateBasePosition;
                    basepos.y += 600;
                    Vector2 pos = basepos - _nowPosition;
                    float   rad = Mathf.Atan2(pos.y, pos.x);
                    rad = rad * Mathf.Rad2Deg;
                    _controlObject.transform.localRotation = Quaternion.identity;
                    _controlObject.transform.Rotate(new Vector3(0, 0, 1), rad - 90);

                    // 位置反映
                    _controlObject.transform.localPosition = new Vector3(gesture.Position.x - (Screen.width * 0.5f), gesture.Position.y - (Screen.height * 0.5f), 0);

                    // 現在位置
                    _nowPosition = new Vector2(gesture.Position.x - (Screen.width * 0.5f), gesture.Position.y - (Screen.height * 0.5f));


                    // 指を離した時
                    if (gesture.State == GestureRecognitionState.Ended)
                    {
                        //離して飛んで行く方向記憶
                        _releaseDirection = _nowPosition - _baseControlObjectPosition;

                        _time = 1;
                        _tapReleasePosition = _nowPosition;
                        _springDirection    = gesture.DeltaMove;

                        if (_tapReleasePosition.y > 220f && LNState == LikeOrNope.SuperLike)
                        {
                            //Super Like
                            StartCoroutine(TinAction(LNState));
                        }
                        else if (_tapReleasePosition.x > 40 && LNState == LikeOrNope.Like)
                        {
                            //Like
                            StartCoroutine(TinAction(LNState));
                        }
                        else if (_tapReleasePosition.x < -40 && LNState == LikeOrNope.Nope)
                        {
                            //Nope
                            StartCoroutine(TinAction(LNState));
                        }
                        else if (LNState == LikeOrNope.None)
                        {
                            StartCoroutine(TinAction(LNState));
                        }
                    }
                }
            }
        }
Example #20
0
    public override void OnDrag(DragGesture gesture)
    {
        base.OnDrag(gesture);
        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
        }
        else if (gesture.Phase == ContinuousGesturePhase.Updated)
        {
            if (_ControlledCamera)
            {
                Vector2 center = GetCenterPos();
                float   ang    = GetAng(center, gesture.LastPos);
                float   radius = GetRadius(center, gesture.LastPos);
                radius = Mathf.Clamp01(radius);

                _ControlledCamera.SetCameraX(radius);
                _ControlledCamera.SetCameraY(ang);
            }


            Debug.Log(gesture.Position);
        }
        else if (gesture.Phase == ContinuousGesturePhase.Ended)
        {
        }
    }
Example #21
0
 public override void OnDrag(DragGesture gesture)
 {
     //不用BASE因为要区分手指位置转动
     //base.OnDrag(gesture);
     if (gesture.Phase == ContinuousGesturePhase.Started)
     {
         mEntity.SetVelocityCameraUp(0);
         _IsDrag = true;
     }
     else if (gesture.Phase == ContinuousGesturePhase.Updated)
     {
         if (gesture.Position.y > Screen.height / 2)
         {
             mEntity.RotateCameraUp(gesture.LastDelta.x);
         }
         else
         {
             mEntity.RotateCameraUp(-gesture.LastDelta.x);
         }
         mEntity.DoDrag(Mathf.Abs(gesture.LastDelta.y));
         mEntity.CalculateYPos();
     }
     else if (gesture.Phase == ContinuousGesturePhase.Ended)
     {
         _IsDrag = false;
         if (gesture.Position.y > Screen.height / 2)
         {
             mEntity.AddForceCameraY(gesture.TotalMove.x / gesture.ElapsedTime);
         }
         else
         {
             mEntity.AddForceCameraY(-gesture.TotalMove.x / gesture.ElapsedTime);
         }
     }
 }
Example #22
0
    void OnDrag(DragGesture gesture)
    {
        // current gesture phase (Started/Updated/Ended)
        ContinuousGesturePhase phase = gesture.Phase;

        switch (phase)
        {
        case ContinuousGesturePhase.Ended:
            transform.position = startDragPos;
            if (doneWithShake)
            {
                GetComponent <TBDragToMove>().DragPlaneCollider = null;
            }
            break;

        case ContinuousGesturePhase.Updated:
            elapsed = gesture.ElapsedTime;
            if (!doneWithShake && elapsed >= 1f)              //Shake inhaler for 1 second
            {
                if (!isGestureRecognized)
                {
                    isGestureRecognized = true;
                    scaleAnim.Play("InhalerObjectPulse");
                    NextStep();
                }
            }
            break;
        }
    }
Example #23
0
 public override void OnDrag(DragGesture gesture)
 {
     if (gesture.Phase == ContinuousGesturePhase.Started)
     {
         mEntity.mISM.Push("PatrolDrag");
     }
 }
 //-------------------------------------------------------------------------
 void OnDrag(DragGesture gesture)
 {
     if (onFingerDragMove != null)
     {
         onFingerDragMove(gesture.Position);
     }
 }
Example #25
0
    private void OnDrag(DragGesture gesture)
    {
        if (Pinch)
        {
            return;
        }
        switch (gesture.Phase)
        {
        case ContinuousGesturePhase.Started:
            if (UICamera.Raycast(gesture.StartPosition) == false)
            {
                m_Drag    = gesture;
                Drag      = true;
                DragDelta = gesture.DeltaMove;
            }
            break;

        case ContinuousGesturePhase.Updated:
            if (Drag && gesture.ClusterId == m_Drag.ClusterId)
            {
                DragDelta = gesture.DeltaMove;
            }
            break;

        case ContinuousGesturePhase.Ended:
        case ContinuousGesturePhase.None:
            if (m_Drag != null && m_Drag.ClusterId == gesture.ClusterId)
            {
                m_Drag    = null;
                Drag      = false;
                DragDelta = Vector2.zero;
            }
            break;
        }
    }
Example #26
0
 //-------------------------------------------------------------------------
 void OnDrag(DragGesture gesture)
 {
     if (onFingerDragMove != null)
     {
         onFingerDragMove(gesture.Position);
     }
 }
Example #27
0
    private void OnTwoFingerDrag(DragGesture gesture)
    {
        if (canControl)
        {
            if (!canInput)
            {
                return;
            }
            if (allowPanning)
            {
                panningSens = Distance / 5.0f * panningSensMax;
                Vector3 move = -panningSens *
                               (panningPlane.right * gesture.DeltaMove.x.Centimeters() +
                                panningPlane.up * gesture.DeltaMove.y.Centimeters());

                if (invertPanningDirections)
                {
                    IdealPanOffset = -move;
                }
                else
                {
                    IdealPanOffset = move;
                }

                //reset idealPanPositon
                if (gesture.Phase == ContinuousGesturePhase.Ended)
                {
                    IdealPanOffset = Vector3.zero;
                }

                nextDragTime = Time.time + 0.25f;
            }
        }
    }
Example #28
0
    public override void OnDrag(DragGesture gesture)
    {
        _NoOperationTimer.Reset();
        if (_Pinching)
        {
            return;
        }

        base.OnDrag(gesture);
        if (gesture.Phase == ContinuousGesturePhase.Started)
        {
        }
        else if (gesture.Phase == ContinuousGesturePhase.Updated)
        {
            if (gesture.LastDelta.y != 0)
            {
                _LastY = gesture.LastDelta.y;
            }
            mEntity.AddEulerAng(gesture.LastDelta.y);
        }
        else if (gesture.Phase == ContinuousGesturePhase.Ended)
        {
            mEntity.GoToBounce(_LastY);
        }
    }
Example #29
0
 public void OnDrag(DragGesture gesture)
 {
     if (_ModeDic.ContainsKey(_CurrentMode))
     {
         _ModeDic[_CurrentMode].OnDrag(gesture);
     }
 }
Example #30
0
    void OnDrag(DragGesture gesture)
    {
        if (GameApp.Instance.HomePageUI.IsSomeUIShowing())
        {
            return;
        }

        //ContinuousGesturePhase phase = gesture.Phase;

        Vector2 deltaMove = gesture.DeltaMove * 0.03f;

        //Vector2 totalMove = gesture.TotalMove * 0.5f;

        lastAngle += new Vector3(-deltaMove.y, 0, deltaMove.x);
        //Debug.Log(lastAngle.x);

        if (lastAngle.x < -15)
        {
            lastAngle = new Vector3(-15, 0, lastAngle.z);
        }
        if (lastAngle.x > 15)
        {
            lastAngle = new Vector3(15, 0, lastAngle.z);
        }

        targetRotation = Quaternion.Euler(lastAngle) * Quaternion.identity;
    }
Example #31
0
 // Handle Gesture Event (sent by the DragRecognizer component)
 void OnDrag(DragGesture gesture)
 {
     if (gesture.Phase != ContinuousGesturePhase.Ended)
         dragGesture = gesture;
     else
         dragGesture = null;
 }
Example #32
0
 void OnDrag(DragGesture gesture)
 {
     if (GameData.getInstance().isLock)
     {
         return;
     }
     if (gesture.Phase == ContinuousGesturePhase.Started)
     {
     }
     else if (gesture.Phase == ContinuousGesturePhase.Updated)
     {
         foreach (GameObject dragObject in dragObjects)
         {
             if (gesture.Selection == dragObject)
             {
                 dragObject.transform.position = Util.GetWorldPos(gesture.Position, dragObject, true);
             }
         }
     }
     else
     {
         foreach (GameObject dragObject in dragObjects)
         {
             if (gesture.Selection == dragObject)
             {
             }
         }
     }
 }
Example #33
0
    void OnDrag(DragGesture gesture)
    {
        if (!Game.Instance.IsPlaying) return;

        // Drag/displacement since last frame
        Vector2 deltaMove = gesture.DeltaMove;
        player.Move(deltaMove.y * moveFactor, -deltaMove.x * moveFactor);
    }
 private void OnDrag(DragGesture pDragGesture)
 {
     // LogManager.Debug(pDragGesture.State);
     if (DragEvent != null)
     {
         DragEvent(pDragGesture);
     }
 }
Example #35
0
 public override void OnDrag(DragGesture gesture)
 {
     base.OnDrag(gesture);
     if (gesture.Phase == ContinuousGesturePhase.Started)
     {
         mEntity.mISM.Push("BounceDrag");
     }
 }
Example #36
0
    void OnDrag( DragGesture gesture )
    {
        dragGesture = ( gesture.State == GestureRecognitionState.Ended ) ? null : gesture;
		if (dragGesture != null) {
			if ((dragGesture.Fingers.Count > 1) || IgnoreDrag)
				dragGesture = null;
		}
    }
	void OnDragDrop(DragGesture gesture) {
		Vector3 newPos = Camera.main.ScreenToWorldPoint (gesture.TotalMove);
		newPos.z = -5f;
		newPos.y += 5f;
		transform.position = newPos;

		Debug.Log (Camera.main.ScreenToWorldPoint (gesture.TotalMove));
	}
Example #38
0
 void OnDrag(DragGesture gesture)
 {
     if(model == EModel.Move){
         Vector3 move = gesture.DeltaMove * 0.05f;
         parent.transform.Translate(move, Space.World);
     }else if(model == EModel.Rotate){
         Vector3 move = gesture.DeltaMove * 0.3f;
         parent.transform.Rotate(move.y, -1 * move.x, 0f, Space.World);
     }
 }
Example #39
0
    void OnDrag( DragGesture gesture )
    {
        if (gesture.DeltaMove.SqrMagnitude() > 0)
        {
            Vector2 screenSpaceMove = sensitivity * gesture.DeltaMove;
            Vector3 worldSpaceMove = screenSpaceMove.x * cachedTransform.right + screenSpaceMove.y * cachedTransform.up;
            idealPos -= worldSpaceMove;

            if (OnPan != null)
                OnPan(this, worldSpaceMove);
        }
    }
        void DragingStart(DragGesture gesture)
        {
            if (!GlobalManager.FurnitureOperationSwitch)
                return;
            if (gesture.Selection != GlobalManager.Selection)
                return;

            GestureRunning = IsTargetNull() ? false : true;
            if (!GestureRunning)
                return;

            StartChange();
        }
Example #41
0
	/// <summary>
	/// 拖拽时调用
	/// </summary>
	/// <param name="gesture"></param>
    void OnDrag(DragGesture gesture)
	{
        ///< UI层不做处理
        if (null != UICamera.hoveredObject)
        {
            gameObject.GetComponent<TBDragView>().enabled = false;
            //return;
        }
        else
        {
            gameObject.GetComponent<TBDragView>().enabled = true;
        }

        ///<判断手指的数量与旋转区分开,如果大于两个手指则不旋转
        if (fingerNumber >= 1)
		{
			return;
		}

        ///<拖动的位置
        dragPosition = gesture.Position;
        if ((downPosition.x - dragPosition.x) > SunmConstant.offDistance)
		{
			//           Debug.LogError("left");
			bIsMovePress = true;
		}

        if ((dragPosition.x - downPosition.x) > SunmConstant.offDistance)
		{
			//            Debug.Log("right");
			bIsMovePress = true;
		}

        if ((dragPosition.y - downPosition.y) > SunmConstant.offDistance)
		{
			//           Debug.Log("up");
			bIsMovePress = true;
		}

		if ((downPosition.y - dragPosition.y) > SunmConstant.offDistance)
		{
			//            Debug.LogError("down");
			bIsMovePress = true;
		}

		downPosition = dragPosition;
	}
Example #42
0
    void OnDrag( DragGesture gesture )
    {
        if( gesture.Phase == ContinuousGesturePhase.Started )
        {
            // initialize the line renderer
            lineRenderer.enabled = true;
            lineRenderer.SetPosition( 0, transform.position );
            lineRenderer.SetPosition( 1, transform.position );

            // keep end point width in sync with object's current scale
            lineRenderer.SetWidth( 0.01f, transform.localScale.x );
        }
        else if( gesture.Phase == ContinuousGesturePhase.Ended )
        {
            lineRenderer.enabled = false;
        }
    }
        void DragingUpdate(DragGesture gesture)
        {
            if (!GestureRunning)
                return;

            Vector3 fingerPos3d, prevFingerPos3d;

            ///calculate distance between previous finger position and new position
            /// and position of finger is in or out of screen
            if (ProjectScreenPointOnDragPlane(TargetTransform.position, gesture.Fingers [0].PreviousPosition, out prevFingerPos3d) &&
                ProjectScreenPointOnDragPlane(TargetTransform.position, gesture.Fingers [0].Position, out fingerPos3d))
            {

                Vector3 move = fingerPos3d - prevFingerPos3d;

                TargetTransform.position += move;
            }
        }
Example #44
0
    void OnDrag( DragGesture gesture )
    {
        // first finger
        FingerGestures.Finger finger = gesture.Fingers[0];

        if( gesture.Phase == ContinuousGesturePhase.Started )
        {
            Debug.Log("sex");
            // dismiss this event if we're not interacting with our drag object
            if( gesture.Selection != dragObject )
                return;

            UI.StatusText = "Started dragging with finger " + finger;

            // remember which finger is dragging dragObject
            dragFingerIndex = finger.Index;

            // spawn some particles because it's cool.
            SpawnParticles( dragObject );
        }
        else if( finger.Index == dragFingerIndex )  // gesture in progress, make sure that this event comes from the finger that is dragging our dragObject
        {
            if( gesture.Phase == ContinuousGesturePhase.Updated )
            {
                // update the position by converting the current screen position of the finger to a world position on the Z = 0 plane
                dragObject.transform.position = GetWorldPos( gesture.Position );
            }
            else
            {
                UI.StatusText = "Stopped dragging with finger " + finger;

                // reset our drag finger index
                dragFingerIndex = -1;

                // spawn some particles because it's cool.
                SpawnParticles( dragObject );

            }
        }
    }
Example #45
0
    //public static void moveCenter( Vector3 _mov )
    //{

    //}
    /// <summary>
    /// 重新设置旋转中心点
    /// </summary>
    /// <param name="_center"></param>
    /// 
    //public static void changeCenter(Vector3 _center)
    //{
    //    rotateCenter = rotateCenter + _center;
    //}

    void OnDrag(DragGesture gesture)
    {
        ///< UI层不做处理
        if (null != UICamera.hoveredObject)
        {
            return;
        }

        ///< 判断手指的数量与旋转区分开,如果大于两个手指则不旋转
        if (fingerNumber >= 1)
        {
            return;
        }

        //< 如果正在操作按键,则不处理//
        if (SunmRTKeyControl.bIsMoving || bIsKeying)
        {
            return;
        }

        //< 拖动的位置//
        dragPosition = gesture.Position;
        dragPoint3 = map2Sphere(dragPosition);
        float theta = Mathf.Acos(Mathf.Min(1.0f, Vector3.Dot(startPoint3, dragPoint3))) * CNCRotation;
        Vector3 axis = Vector3.Cross(startPoint3, dragPoint3).normalized;
        Quaternion rot = Quaternion.Inverse(Quaternion.AngleAxis(theta * 180.0f / Mathf.PI, axis));//当前拖动得到的四元数//
        currentRotation = currentRotation * rot;//当前相机的四元数//
        transform.position = currentRotation * (initPosition - rotateCenter) + rotateCenter;//当前相机所在位置//
        transform.rotation = currentRotation;
        //transform.LookAt (rotateCenter);
        if ((downPosition.x - dragPosition.x) > SunmConstant.offDistance)
        {
            //           Debug.LogError("left");
            bIsMovePress = true;
        }

        if ((dragPosition.x - downPosition.x) > SunmConstant.offDistance)
        {
            //            Debug.Log("right");
            bIsMovePress = true;
        }

        if ((dragPosition.y - downPosition.y) > SunmConstant.offDistance)
        {
            //           Debug.Log("up");
            bIsMovePress = true;
        }

        if ((downPosition.y - dragPosition.y) > SunmConstant.offDistance)
        {
            //            Debug.LogError("down");
            bIsMovePress = true;
        }

        downPosition = dragPosition;
        startPoint3 = dragPoint3;
    }
 void DragingEnd(DragGesture gesture)
 {
     if (!GestureRunning)
         return;
     RecordChange();
 }
Example #47
0
 void OnDrag( DragGesture gesture )
 {
     HandleDrag( gesture );
 }
Example #48
0
void HandleDrag( DragGesture gesture )
{
    if( !enabled )
        return;

    if( gesture.Phase == ContinuousGesturePhase.Started )
    {
        Dragging = true;
        draggingFinger = gesture.Fingers[0];
    }
    else if( Dragging )
    {
        // make sure this is the finger we started dragging with
        if( gesture.Fingers[0] != draggingFinger )
            return;

        if( gesture.Phase == ContinuousGesturePhase.Updated )
        {
            Transform tf = transform;
            Vector3 move = Vector3.zero;

            if( DragFromObjectCenter )
            {
                Vector3 fingerPos3d;
                if( ProjectScreenPointOnDragPlane( tf.position, draggingFinger.Position, out fingerPos3d ) )
                {
                    move = fingerPos3d - tf.position;
                }
            }
            else
            {
                // figure out our previous screen space finger position
                Vector3 fingerPos3d, prevFingerPos3d;

                // convert these to world-space coordinates, and compute the amount of motion we need to apply to the object
                if( ProjectScreenPointOnDragPlane( tf.position, draggingFinger.PreviousPosition, out prevFingerPos3d ) &&
                    ProjectScreenPointOnDragPlane( tf.position, draggingFinger.Position, out fingerPos3d ) )
                {
                    move = fingerPos3d - prevFingerPos3d;
                }
            }

            if( rigidbody )
                physxDragMove += move; // this will be used in FixedUpdate() to properly move the rigidbody
            else
                tf.position += move;
        }
        else
        {
            Dragging = false;
        }
    }
}
	/// <summary>
	/// Raises the drag gesture event. This event is raised by FingerGestures's DragRecognizer component.
	/// Determine the selected tile and in which direction the user dragged it and tell the <see cref="Match3BoardGameLogic"/>
	/// that we've started moving that tile in that direction.
	/// </summary>
	/// <param name='eventData'>
	/// Event data.
	/// </param>
	public void OnDragGesture(DragGesture eventData) {		
		if (dragLock > 0) {
			tapSelectedTile = null;
			return;
		}
		
		// Check if we've selected any tile.
		if (eventData.StartSelection != null && eventData.StartSelection.layer == Match3Globals.Instance.layerBoardTile) {
			if (eventData.Phase == ContinuousGesturePhase.Started) {
				// Cancel the tap selected tile if we've done a drag gesture.
				tapSelectedTile = null;
				
				AbstractTile dragSelectedTile = eventData.StartSelection.GetComponent<AbstractTile>();
				TileMoveDirection moveDirection = Match3BoardGameLogic.GetTileMoveDirection(eventData.TotalMove);
				
				if (InputFilter == null || InputFilter(dragSelectedTile, null, moveDirection)) {
//					Debug.Log("Drag event started! Start Selection: " + eventData.StartSelection + " -> totalMove = " + eventData.TotalMove);
					if (boardGameLogic.TryToMoveTile(dragSelectedTile, moveDirection)) {
						//boardGameLogic.loseConditions.NewMove();
					}
				}
			}
		}
	}
Example #50
0
	void OnDrag(DragGesture gesture){
		if(gesture.Phase == ContinuousGesturePhase.Updated){
			//拖动屏幕
			GameController.GetInstance().deltaMove =  gesture.DeltaMove;
		}
		if(gesture.Phase == ContinuousGesturePhase.Ended){
			//结束拖动屏幕,向量恢复为(0f,0f)
			GameController.GetInstance().deltaMove = new Vector2(0f,0f);
		}
	}
Example #51
0
 void OnDrag( DragGesture gesture )
 {
     //if(pausing.isPaused == false)
     HandleDrag( gesture );
 }
Example #52
0
 void OnDrag(DragGesture gesture)
 {
     if(!HasUI()){
         Vector3 move = gesture.DeltaMove * 0.3f;
         camera.transform.Rotate(-1 * move.y, move.x, 0f);
         Vector3 angle = camera.transform.eulerAngles;
         angle.z = 0;
         camera.transform.eulerAngles = angle;
     }
     //		if(model == EModel.Move){
     //			Vector3 move = gesture.DeltaMove * 0.05f;
     //			camera.transform.Translate(move, Space.World);
     //		}else if(model == EModel.Rotate){
     //
     //		}
 }
Example #53
0
    void OnTwoFingerDrag( DragGesture gesture )
    {
        //Debug.Log( "OnTwoFingerDrag " + e.Phase + " @ Frame " + Time.frameCount );

        if( allowPanning )
        {
            Vector3 move = -0.02f * panningSensitivity * 
				( panningPlane.right * gesture.DeltaMove.x + panningPlane.up * gesture.DeltaMove.y );
            
            if( invertPanningDirections )
                IdealPanOffset -= move; 
            else
                IdealPanOffset += move;

            nextDragTime = Time.time + 0.25f;
        }
    }
Example #54
0
    void OnDrag( DragGesture gesture )
    {
        // dont apply drag rotation if more than one touch is on the screen
        //if( FingerGestures.Touches.Count > 1 )
        //    return;
        
        // wait for drag cooldown timer to wear off
        //  used to avoid dragging right after a pinch or pan, when lifting off one finger but the other one is still on screen
        if( Time.time < nextDragTime )
            return;

        if( target )
        {
            IdealYaw += gesture.DeltaMove.x * yawSensitivity * 0.02f;
            IdealPitch -= gesture.DeltaMove.y * pitchSensitivity * 0.02f;
        }
    }
Example #55
0
	void OnDrag ( DragGesture e ) {
		if ( unitToCreate == null || !canCreate ) return;
		
		if ( !unitToCreate.Recharged ) return;
		
		switch ( e.State ) {
		case GestureRecognitionState.Started:
			if ( instiantedUnit == null ) {
				instiantedUnit = Instantiate ( unitToCreate.gameObject ) as GameObject;
				instiantedUnit.renderer.enabled = false;
			}
			
			break;
			
		case GestureRecognitionState.InProgress:
			selectedTerrainBlockGO = e.Selection;
			
			if ( selectedTerrainBlockGO == null ) {
				if ( instiantedUnit != null )
					instiantedUnit.renderer.enabled = false;
				return;
			}
			
			selectedTerrainBlock = selectedTerrainBlockGO.GetComponent<TerrainBlock>();
			if ( selectedTerrainBlock == null ) { 
				if ( instiantedUnit != null )
					instiantedUnit.renderer.enabled = false;
				return;
			}
			
			if ( instiantedUnit != null )
				instiantedUnit.renderer.enabled = true;
			
			if ( highlightedTerrainBlocks != null )
			foreach ( TerrainBlock block in highlightedTerrainBlocks )
				block.SpriteRenderer.VertexColor = block.DefaultColor;
			
			// Highlight selection of the row and column from the terrain block.
			highlightedTerrainBlocks = TerrainManager.GetTerrainRowAndColumn (selectedTerrainBlock);
			
			foreach ( TerrainBlock block in highlightedTerrainBlocks ) {
				block.SpriteRenderer.VertexColor = Color.red;
			}
			
			if ( instiantedUnit != null )
				instiantedUnit.SetXY ( selectedTerrainBlockGO.GetX(), selectedTerrainBlockGO.GetY() );
			
			break;
			
		case GestureRecognitionState.Ended:
			if ( highlightedTerrainBlocks != null )
				foreach ( TerrainBlock block in highlightedTerrainBlocks )
					block.SpriteRenderer.VertexColor = block.DefaultColor;
			
			selectedTerrainBlockGO = e.Selection;
			if ( selectedTerrainBlockGO == null ) {
				if ( instiantedUnit != null ) {
					Destroy ( instiantedUnit );
				}
				return; 
			}
			
			selectedTerrainBlock = selectedTerrainBlockGO.GetComponent<TerrainBlock>();
			if ( selectedTerrainBlock == null ) { 
				if ( instiantedUnit != null ) {
					instiantedUnit.renderer.enabled = false;
					Destroy ( instiantedUnit );
				}
				return;
			}
			
			if ( selectedTerrainBlock.HasUnit )
				Destroy ( instiantedUnit );
			else {
				if ( selectedTerrainBlock == null )
					return;
				
				selectedTerrainBlock.unitOnTerrain = instiantedUnit.GetComponent<Unit>();
				selectedTerrainBlock.unitOnTerrain.terrainBlock = selectedTerrainBlock;
				selectedTerrainBlock.unitOnTerrain.UnitPlaced = true;
			}
			
			selectedTerrainBlockGO = null;
			selectedTerrainBlock = null;
			instiantedUnit = null;
			UnitToCreate.LastUsedTime = Time.time;
			
			break;
		}
	}
Example #56
0
 void OnDrag( DragGesture gesture )
 {
     dragGesture = ( gesture.State == GestureRecognitionState.Ended ) ? null : gesture;
 }
Example #57
0
    void OnTwoFingerDrag( DragGesture gesture )
    {
        if( allowPanning )
        {
            Vector3 move = -panningSensitivity * ( panningPlane.right * gesture.DeltaMove.x.Centimeters() + panningPlane.up * gesture.DeltaMove.y.Centimeters() );

            if( invertPanningDirections )
                IdealPanOffset -= move;
            else
                IdealPanOffset += move;

            nextDragTime = Time.time + 0.25f;
        }
    }
Example #58
0
    void OnDrag( DragGesture gesture )
    {
        // don't rotate unless the drag started on our target object
        if( OnlyRotateWhenDragStartsOnObject )
        {
            if( gesture.Phase == ContinuousGesturePhase.Started )
            {
                if( !gesture.Recognizer.Raycaster )
                {
                    Debug.LogWarning( "The drag recognizer on " + gesture.Recognizer.name + " has no ScreenRaycaster component set. This will prevent OnlyRotateWhenDragStartsOnObject flag from working." );
                    OnlyRotateWhenDragStartsOnObject = false;
                    return;
                }

                if( target && !target.collider )
                {
                    Debug.LogWarning( "The target object has no collider set. OnlyRotateWhenDragStartsOnObject won't work." );
                    OnlyRotateWhenDragStartsOnObject = false;
                    return;
                }
            }

            if( !target || gesture.StartSelection != target.gameObject )
                return;
        }

        // wait for drag cooldown timer to wear off
        //  used to avoid dragging right after a pinch or pan, when lifting off one finger but the other one is still on screen
        if( Time.time < nextDragTime )
            return;

        if( target )
        {
            IdealYaw += gesture.DeltaMove.x.Centimeters() * yawSensitivity;
            IdealPitch -= gesture.DeltaMove.y.Centimeters() * pitchSensitivity;
        }
    }
Example #59
0
    void OnDrag(DragGesture drag)
    {
        //		Vector2 deltaMove = drag.DeltaMove * 0.1f;
        //		hero.transform.Rotate(0f, deltaMove.x, 0f, Space.World);
        //
        //		CameraControll camealControll = main_camera.GetComponent<CameraControll>();
        //		camealControll.OnDrag(drag);

        //		main_camera.transform.Rotate(deltaMove.y, 0, 0f, Space.World);
        //		Vector3 cameraAngle = main_camera.transform.eulerAngles;
        //		cameraAngle.z = 0;
        //		cameraAngle.y = hero.transform.eulerAngles.y;
        //		main_camera.transform.eulerAngles = cameraAngle;
    }
Example #60
0
    void OnDrag(DragGesture gesture)
    {
        ContinuousGesturePhase phase = gesture.Phase;
        Vector2 deltaMove = gesture.DeltaMove;
        if(controller == TouchControllerType.FRAME)
        {
            if(phase == ContinuousGesturePhase.Started)
            {
                float relativeObjectPosX = 0;
                if(is_right_user)
                    relativeObjectPosX = (player.transform.localPosition.x - 30f) / 175f; // max value is 1
                else
                    relativeObjectPosX = -(player.transform.localPosition.x + 30f) / 175f; // min value is -1
                //Initialize touch Frame's cursor
                touchFrame = new TouchFrame();
                touchFrame.cursor_x = relativeObjectPosX * touchFrame.size_x;
                touchFrame.cursor_y = 0;
                //Initialize touch Frame's boundary
                touchFrame.boundary_minus_x = gesture.Position.x - touchFrame.cursor_x;
                touchFrame.boundary_minus_y = gesture.Position.y;
                touchFrame.boundary_plus_x = touchFrame.boundary_minus_x + touchFrame.size_x;
                touchFrame.boundary_plus_y = touchFrame.boundary_minus_y + touchFrame.size_y;
                is_touching = true;
                Debug.Log(GameObject.Find("VollyBallCamera").GetComponent<Camera>().ScreenToWorldPoint(new Vector3(gesture.Position.x , gesture.Position.y, 0)) - new Vector3(216,153,0));
                //Debug.Log("Touch!");
            }
            else if(phase == ContinuousGesturePhase.Updated)
          			{
                float movePos = 0; // player's move position which is on x-axis
                float mst = 1;		//player's moving direction ( + : move right, - : move left)
                if(is_right_user)
                {
                    movePos = 30f + ((touchFrame.touch_pos.x - touchFrame.boundary_minus_x) / touchFrame.size_x * 175f);
                }

                else
                {
                    movePos = -30f - ((touchFrame.boundary_plus_x - touchFrame.touch_pos.x) / touchFrame.size_x * 175f);
                }
                    gameManager.FrameP1Walking(movePos);

                //update touch Frame's cursor and touch Frame's boundary
                touchFrame.touch_pos = gesture.Position;
                touchFrame.cursor_x = touchFrame.touch_pos.x - touchFrame.boundary_minus_x;
                touchFrame.cursor_y = touchFrame.touch_pos.y - touchFrame.boundary_minus_y;

                /*move touch frame if cursors get out of this frame*/
                if(touchFrame.touch_pos.x > touchFrame.boundary_plus_x)
                {
                    touchFrame.boundary_plus_x += touchFrame.cursor_x - touchFrame.size_x;
                    touchFrame.boundary_minus_x += touchFrame.cursor_x - touchFrame.size_x;
                    touchFrame.cursor_x = touchFrame.size_x;
                }else if(touchFrame.touch_pos.x < touchFrame.boundary_minus_x)
                {
                    touchFrame.boundary_minus_x += touchFrame.cursor_x;
                    touchFrame.boundary_plus_x += touchFrame.cursor_x;
                    touchFrame.cursor_x = 0;
                }
                if(touchFrame.touch_pos.y > touchFrame.boundary_plus_y)
                {
                    touchFrame.boundary_plus_y += touchFrame.cursor_y - touchFrame.size_y;
                    touchFrame.boundary_minus_y += touchFrame.cursor_y - touchFrame.size_y;
                    touchFrame.cursor_y = touchFrame.size_y;
                }
                else if(touchFrame.touch_pos.y < touchFrame.boundary_minus_y)
                {
                    touchFrame.boundary_plus_y += touchFrame.cursor_y;
                    touchFrame.boundary_minus_y += touchFrame.cursor_y;
                    touchFrame.cursor_y = 0;
                }
                //Debug.Log("Touch Pos : " + touchFrame.touch_pos.x +"/t/tCursor : " + touchFrame.cursor + "\nbndMinus : " + touchFrame.boundary_minus_x + "/t/tbndPlus : " + touchFrame.boundary_plus_x);

                if(player1.can_swipe)
                {
                    if(player1.pMotion == MotionType.WALK)//if(!player1.jumping && !player1.leftSliding && !player1.rightSliding &&!is_jumped)
                    {
                        if(touchFrame.touch_pos.y - touchFrame.boundary_minus_y > jump_touch_dist)//jump touch event
                        {
                            gameManager.P1Jumping();
                        }
                        else if(deltaMove.x < -40) // left sliding touch event
                        {
                            gameManager.P1Sliding(false);
                        }
                        else if(deltaMove.x > 40) // right sliding touch event
                        {
                            gameManager.P1Sliding(true);
                        }
                    }
                    else if(player1.pMotion == MotionType.JUMP)//(player1.jumping && !player1.upperSpike && !player1.middleSpike && !player1.lowerSpike)
                    {
                        if(deltaMove.y > 25 )//&& deltaMove.x < 10 && deltaMove.x > -10)//upper spike
                        {
                            gameManager.P1Spiking(SpikeType.HIGH, false);
                        }
                        else if(deltaMove.y < -25)// && deltaMove.x < 10 && deltaMove.x > -10)//lower spike
                        {
                            gameManager.P1Spiking(SpikeType.LOW, false);
                        }
                        else if(deltaMove.x > 20)// && deltaMove.y < 10 && deltaMove.y > -10)//middle spike
                        {
                            gameManager.P1Spiking(SpikeType.MID, false);
                        }
                        else if(deltaMove.x < -20)// && deltaMove.y < 10 && deltaMove.y > -10)//middle spike
                        {
                            gameManager.P1Spiking(SpikeType.MID, true);
                        }
                    }
                }

            }
            else // it is called when user get off the hand from screen
            {
                is_touching = false;
            }
        }
        else if(controller == TouchControllerType.BUTTON)
        {
         	FingerGestures.Finger finger = gesture.Fingers[0];
            if(gesture.Phase == ContinuousGesturePhase.Started)
            {
                if(gesture.Selection == bt_left && player1.can_swipe)
                {
                    if(is_left_clckd && Time.time - touched_time < 0.5f)
                    {
                        touchEvent = TouchEvent.NONE;
                        gameManager.P1Sliding(false);
                        is_left_clckd = false;
                        if(is_right_clckd)
                            is_right_clckd = false;
                        Debug.Log("left Sliding!");
                    }
                    else
                    {
                        touchEvent = TouchEvent.LEFT;
                        sprite_bt_left.SetSprite("bubble_orange");
                        //GameObject particle = touchEffect.spawnParticle(new Vector3(gesture.Position.x, gesture.Position.y, -3));

                        is_left_touching = true;
                        touched_time = Time.time;
                        is_left_clckd = true;
                        if(is_right_clckd)
                            is_right_clckd = false;
                        Debug.Log("left walking!!!");
                    }
                    dragFingerIdx = finger.Index;
                }
                else if(gesture.Selection == bt_right && player1.can_swipe)
                {
                    if(is_right_clckd && Time.time - touched_time < 0.5f)
                    {
                        touchEvent = TouchEvent.NONE;
                        gameManager.P1Sliding(true);
                        is_right_clckd = false;
                        if(is_left_clckd)
                        is_left_clckd = false;
                        Debug.Log("right Sliding!");
                    }
                    else
                    {
                        touchEvent = TouchEvent.RIGHT;
                        sprite_bt_right.SetSprite("bubble_orange");
                        is_right_touching = true;
                        Debug.Log("right Button is selected!");
                        touched_time = Time.time;
                            is_right_clckd = true;
                        if(is_left_clckd)
                            is_left_clckd = false;
                    }
                    dragFingerIdx = finger.Index;
                }
            }

            else if(dragFingerIdx == finger.Index && gesture.Phase == ContinuousGesturePhase.Ended)
            {
                if(touchEvent == TouchEvent.LEFT)
                {
                    sprite_bt_left.SetSprite("bubble_red");
                    is_left_touching = false;
                    touchEvent = TouchEvent.NONE;
                }
                if(touchEvent == TouchEvent.RIGHT)
                {
                    sprite_bt_right.SetSprite("bubble_red");
                    is_right_touching = false;
                    touchEvent = TouchEvent.NONE;
                }
                else
                {
                    sprite_bt_left.SetSprite("bubble_red");
                    is_left_touching = false;
                    sprite_bt_right.SetSprite("bubble_red");
                    is_right_touching = false;
                }
            }
        }
        else
        {
            //FingerGestures.Finger finger = gesture.Fingers[0];
            Vector3 pos = Vector3.zero;
            if(is_right_user)
                pos = cam.camera.ScreenToWorldPoint(new Vector3(gesture.Position.x, gesture.Position.y, 0)) - new Vector3(432/2 - 130, 306/2 - 50, -7);
            else
                pos = cam.camera.ScreenToWorldPoint(new Vector3(gesture.Position.x, gesture.Position.y, 0)) - new Vector3(432/2 + 130, 306/2 + 50, -7);
            Debug.Log(pos);
            if(gesture.Phase == ContinuousGesturePhase.Started)
            {
                if(gesture.Selection == joystick_bg || gesture.Selection == joystick_bar)
                {
                    joystick_bar.transform.localPosition = pos;
                    is_touching_joypad = true;
                }
                //dragFingerIdx = finger.Index;
            }
            else if(is_touching_joypad)
            {
                if(gesture.Phase == ContinuousGesturePhase.Updated )
                {
                    joystick_bar.transform.localPosition = SetJoyPaddlePos(pos);
                    Vector3 paddlePos = joystick_bar.transform.localPosition;

                    if(paddlePos.y >= 15 && player1.pMotion == MotionType.WALK && player1.can_swipe)
                    {
                        gameManager.P1Jumping();
                    }
                    else if(paddlePos.x < -15)
                    {
                        gameManager.JoypadP1Walking(true);
                    }
                    else if(paddlePos.x > 15)
                    {
                        gameManager.JoypadP1Walking(false);
                    }
                    else if(paddlePos.x <=15 && paddlePos.x >= -15 && paddlePos.y < 15)
                    {
                        gameManager.P1NoneTouching();
                    }

                }
                else
                {
                    joystick_bar.transform.localPosition = new Vector3(0,0,-3);
                    gameManager.P1NoneTouching();
                    is_touching_joypad = false;
                }
            }
        }
    }