Example #1
0
    private void ShowPrompt()
    {
        // Set sprite
        promptDisplay.sprite = prompts[currentFoldSet].Folds[currentFold].Sprite;

        // Display
        promptDisplay.enabled = true;

        // If it's not the first fold of the set nor is it beyond the set's index range
        if ((currentFold + 1) < FoldingSet.MaxCount)
        {
            // Set direction
            currentDirection      = GetDirectionPrompt();
            directionImage.sprite = GetDirectionSprite(currentDirection);
            directionText.text    = string.Format("Swipe " + currentDirection.ToString());
            directionPanel.SetActive(true);

            // Enable SwipeDetector
            swipeDetector.enabled = true;
        }
        else
        {
            directionPanel.SetActive(false);
            StartCoroutine(MoveForward());
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        Direction = SwipeDirection.None;

        if (Input.GetMouseButtonDown(0))
        {
            touchPosition = Input.mousePosition;
        }

        if (Input.GetMouseButtonUp(0))
        {
            Vector2 deltaSwipe = touchPosition - Input.mousePosition;

            if (Mathf.Abs(deltaSwipe.x) > swipeResistanceX)
            {
                Debug.Log("SWIIIIIIPPPPEEEEEE");

                //Swipe on the x axis
                Direction |= (deltaSwipe.x < 0) ? SwipeDirection.Right : SwipeDirection.Left;

                Debug.Log("Swipe Direction : " + Direction);

                Messenger <string> .Broadcast("SwipeDirection", Direction.ToString());

                //Dont forget to check the direction of the swipe
            }
        }
    }
    private void SwipeDetector_OnSwipe(SwipeData data)
    {
        SwipeDirection direction = data.Direction;

        // swiped right
        directionText.text = "SWIPE DIRECTION: " + direction.ToString() + "\n" + "END POSITION: " + data.EndPosition;
    }
Example #4
0
 public void OnCardSwiped(SwipeDirection direction)
 {
     Console.WriteLine("CardStackView", "onCardSwiped: " + direction.ToString());
     Console.WriteLine("CardStackView", "topIndex: " + cardStackView.TopIndex);
     if (cardStackView.TopIndex == adapter.Count - 5)
     {
         Console.WriteLine("CardStackView", "Paginate: " + cardStackView.TopIndex);
         Paginate();
     }
 }
Example #5
0
    private void Update()
    {
        CheckInput();

        log.text = swipe.ToString();

        if (swipe == SwipeDirection.LEFT)
        {
            cam.transform.Translate(this.transform.forward * speed);
        }
    }
Example #6
0
    public void ProcessSwipe(SwipeDirection swipe)
    {
        Debug.Log(swipe.ToString());
        bool moveMadeThisTurn = false;

        ResetTileMergedFlags();

        for (int i = 0; i < rows.Count; i++)
        {
            switch (swipe)
            {
            case SwipeDirection.Down:
                while (ShiftByOneIndexUp(columns[i]))
                {
                    moveMadeThisTurn = true;
                }
                break;

            case SwipeDirection.Up:
                while (ShiftByOneIndexDown(columns[i]))
                {
                    moveMadeThisTurn = true;
                }
                break;

            case SwipeDirection.Left:
                while (ShiftByOneIndexDown(rows[i]))
                {
                    moveMadeThisTurn = true;
                }
                break;

            case SwipeDirection.Right:
                while (ShiftByOneIndexUp(rows[i]))
                {
                    moveMadeThisTurn = true;
                }
                break;
            }
        }

        if (moveMadeThisTurn)//Generate a new tile only after a move is made successfully
        {
            UpdateEmptyTiles();
            GenerateRandomTile();
            if (!IsMovePossible())//Trigger Game over if no moves are possible
            {
                GameOver();
            }
        }
    }
Example #7
0
 void Update()
 {
     //goImage.color.a = imageAlphaLevel;
     if (Global.Instance.gameState == eStates.PowerSwiping)
     {
         if (!startingNextPhase)
         {
             updateTimers();
             showReadyGo(IntroDelay);
             if (gameTime > IntroDelay)
             {
                 startSwipeTimer = true;
                 startIntroTimer = false;
                 if (giveNewDirection == true)
                 {
                     randomSwipeDir   = getRandomEnum <SwipeDirection>();
                     givenSwipeDir    = randomSwipeDir.ToString();
                     giveNewDirection = false;
                 }
             }
             if (SwipeTimer > 0 && startSwipeTimer == true)
             {
                 Swipe();
                 bool tempBool = isCorrectDirection();
                 if (tempBool)
                 {
                     anim.SetTrigger("Punch");
                     Global.Instance.playPunch();
                     power           += PowerValue;
                     giveNewDirection = true;
                 }
             }
         }
         updateArrows();
     }
 }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        // code for mobile phone input
        if (Application.isMobilePlatform)
        {
            if (Input.touchCount == 1)
            {
                Touch cTouch1 = Input.GetTouch(0);
                CursorCurrentPosition = cTouch1.position;
                Collider2D colUC = GetCollider2DUnderCursor();

                // ClickUp
                if (cTouch1.phase == TouchPhase.Ended)
                {
                    if (InputClickUpEventsEnabled && InputAllEventsEnabled /*&& !_isMove*/)
                    {
                        OnInputClickUp.Invoke(cTouch1.position, colUC);

                        if (_canInvokeMoveExclusive)
                        {
                            _canInvokeMoveExclusive = false;
                            _invokeMoveExclusiveCollider2DHelper = null;
                        }
                    }
                    //else if(_isMove)
                    //{
                    //    _isMove = false;
                    //}
                }

                // SWIPE OUT
                if (cTouch1.phase == TouchPhase.Ended && InputSwipeEventsEnabled)
                {
                    Vector2 diff = cTouch1.position - _swipeHelperPos;
                    if (/*colUC == _swipeHelperCol &&*/ diff.magnitude >= _swipeMinimumLength)
                    {
                        SwipeDirection dir = GetSwipeDirectionFromVector(diff);
                        Debug.Log("SWIPE OUT " + dir.ToString());
                        OnInputSwipe.Invoke(_swipeHelperPos, dir, diff.magnitude, colUC);
                        _swipeHelperCol = null;
                        _swipeHelperPos = Vector2.zero;
                    }
                }

                // ClickDown
                if (cTouch1.phase == TouchPhase.Began && InputClickDownEventsEnabled && InputAllEventsEnabled)
                {
                    _cursorPrevPosition = cTouch1.position;
                    OnInputClickDown.Invoke(cTouch1.position, colUC);
                }

                // Swipe IN
                if (cTouch1.phase == TouchPhase.Began && InputSwipeEventsEnabled)
                {
                    Debug.Log("SWIPE IN");
                    _swipeHelperCol = colUC;
                    _swipeHelperPos = cTouch1.position;
                }

                // hold
                if (cTouch1.phase == TouchPhase.Stationary && InputHoldEventsEnabled && InputAllEventsEnabled)
                {
                    OnInputHold.Invoke(cTouch1.position, colUC);
                }

                // move
                if (cTouch1.phase == TouchPhase.Moved && InputMoveEventsEnabled && InputAllEventsEnabled)
                {
                    if (OnInputMove != null)
                    {
                        OnInputMove.Invoke(cTouch1.position, cTouch1.position - _cursorPrevPosition, colUC);
                    }

                    //if(!_isMove)
                    //{
                    //    _isMove = true;
                    //}

                    if (!_canInvokeMoveExclusive)
                    {
                        _canInvokeMoveExclusive = true;
                        _invokeMoveExclusiveCollider2DHelper = colUC;
                    }
                    else
                    {
                        if (OnInputMoveExclusive != null && InputMoveEventsExclusiveEnabled && InputAllEventsEnabled)
                        {
                            OnInputMoveExclusive.Invoke(cTouch1.position, cTouch1.position - _cursorPrevPosition, _invokeMoveExclusiveCollider2DHelper);
                        }
                    }
                }

                _cursorPrevPosition = cTouch1.position;
            }
            else if (Input.touchCount == 2)
            {
                Touch cTouch1 = Input.GetTouch(0);
                Touch cTouch2 = Input.GetTouch(1);

                // zoom
                if (cTouch1.phase == TouchPhase.Moved && cTouch2.phase == TouchPhase.Moved && InputZoomEventsEnabled && InputAllEventsEnabled)
                {
                    /*
                     * // pinch gesture
                     * // Two touch positions with given directions are in fact two rays. Checking if the rays intersect (zoom in) or not (zoom out)
                     * // more info: http://stackoverflow.com/questions/2931573/determining-if-two-rays-intersect
                     * Vector2 pos1 = cTouch1.position;
                     * Vector2 pos2 = cTouch2.position;
                     * Vector2 delta1 = pos1 - _cursorPrevPosition;
                     * Vector2 delta2 = pos2 - _cursor2PrevPosition;
                     * float u, v;
                     *
                     * u = (pos1.y * delta2.x + delta2.y * pos2.x - pos2.y * delta2.x - delta2.y * pos1.x) / (delta1.x * delta2.y - delta1.y * delta2.x);
                     * v = (pos1.x + delta1.x * u - pos2.x) / delta2.x;
                     *
                     * // rays intersect - zoom in
                     * float amount = (delta1.sqrMagnitude + delta2.sqrMagnitude) * 0.1f;
                     *
                     * // rays do not intersect - zoom out
                     * if(u == 0.0f || v == 0.0f || float.IsInfinity(u) || float.IsInfinity(v))
                     * {
                     *  amount = 0.0f;
                     * }
                     * else if (u < 0.0f && v < 0.0f)
                     * {
                     *  amount *= -1.0f;
                     * }
                     *
                     * string debugSTR = delta1.ToString() + " | " + delta2.ToString() + " | " + u.ToString() + " | " + v.ToString() + " | " + amount.ToString();
                     *
                     * Debug.Log(debugSTR);
                     * OnInputZoom(amount);
                     */

                    // bo chciałem być fajny a wyszło jak zwykle

                    Vector2 pos1   = cTouch1.position;
                    Vector2 pos2   = cTouch2.position;
                    Vector2 delta1 = pos1 - _cursorPrevPosition;
                    Vector2 delta2 = pos2 - _cursor2PrevPosition;

                    float dot = Vector2.Dot(delta1, delta2);

                    if (dot < 0.7f)
                    {
                        float fl   = delta1.magnitude;
                        float sl   = delta2.magnitude;
                        float mp   = -0.05f;
                        float diff = (pos1 - pos2).magnitude;
                        if (diff - _diffPinchHelper < 0)
                        {
                            mp *= -1.0f;
                        }
                        _diffPinchHelper = diff;
                        float amount = (fl + sl) * mp;

                        if (OnInputZoom != null)
                        {
                            OnInputZoom.Invoke(amount);
                        }
                    }
                }

                _cursorPrevPosition  = cTouch1.position;
                _cursor2PrevPosition = cTouch2.position;
            }


            // shake
            if (InputShakeEventsEnabled && InputAllEventsEnabled)
            {
                Vector3 shakeInput = Input.acceleration;

                if (shakeInput.sqrMagnitude >= ShakeVectorMinimumSqrLength &&
                    Time.time - _shakeLastTimeSeconds >= ShakeTimeMinBetweenSeconds)
                {
                    _shakeLastTimeSeconds = Time.time;
                    Debug.Log("SHAKEKURWA " + shakeInput.sqrMagnitude.ToString());
                    OnInputShake.Invoke(shakeInput);
                }
            }
        }

        // code for editor or PC test input
        else
        {
            CursorCurrentPosition = Input.mousePosition;
            Collider2D colUC = GetCollider2DUnderCursor();

            // ClickUp
            if (Input.GetMouseButtonUp(0) && InputClickUpEventsEnabled && InputAllEventsEnabled)
            {
                OnInputClickUp.Invoke(Input.mousePosition, colUC);
            }

            // SWIPE OUT
            if (Input.GetMouseButtonUp(0) && InputSwipeEventsEnabled)
            {
                Vector2 diff = new Vector2(Input.mousePosition.x, Input.mousePosition.y) - _swipeHelperPos;
                if (/*colUC == _swipeHelperCol &&*/ diff.magnitude >= _swipeMinimumLength)
                {
                    OnInputSwipe.Invoke(_swipeHelperPos, GetSwipeDirectionFromVector(diff), diff.magnitude, _swipeHelperCol);
                    _swipeHelperCol = null;
                    _swipeHelperPos = Vector2.zero;
                }
            }

            // ClickDown
            if (Input.GetMouseButtonDown(0) && InputClickDownEventsEnabled && InputAllEventsEnabled)
            {
                OnInputClickDown.Invoke(Input.mousePosition, colUC);
            }

            // Swipe IN
            if (Input.GetMouseButtonDown(0) && InputSwipeEventsEnabled)
            {
                _swipeHelperCol = colUC;
                _swipeHelperPos = Input.mousePosition;
            }

            // hold
            if (Input.GetMouseButton(0) && InputHoldEventsEnabled && InputAllEventsEnabled)
            {
                OnInputHold.Invoke(Input.mousePosition, colUC);
            }

            // move
            if (Input.GetMouseButton(1) && _cursorPrevPosition != new Vector2(Input.mousePosition.x, Input.mousePosition.y) && InputMoveEventsEnabled && InputAllEventsEnabled)
            {
                OnInputMove.Invoke(Input.mousePosition, new Vector2(Input.mousePosition.x, Input.mousePosition.y) - _cursorPrevPosition, colUC);

                if (!_canInvokeMoveExclusive)
                {
                    _canInvokeMoveExclusive = true;
                    _invokeMoveExclusiveCollider2DHelper = colUC;
                }
                else
                {
                    if (OnInputMoveExclusive != null && InputMoveEventsExclusiveEnabled && InputAllEventsEnabled)
                    {
                        OnInputMoveExclusive.Invoke(Input.mousePosition, new Vector2(Input.mousePosition.x, Input.mousePosition.y) - _cursorPrevPosition, _invokeMoveExclusiveCollider2DHelper);
                    }
                }
            }

            // move exclusive cleanup
            if (Input.GetMouseButtonUp(1))
            {
                if (_canInvokeMoveExclusive)
                {
                    _canInvokeMoveExclusive = false;
                    _invokeMoveExclusiveCollider2DHelper = null;
                }
            }

            // zoom
            if (Input.mouseScrollDelta.y != 0.0f && InputZoomEventsEnabled && InputAllEventsEnabled)
            {
                OnInputZoom.Invoke(-Input.mouseScrollDelta.y);
            }

            _cursorPrevPosition = Input.mousePosition;
        }

        // shake simulation
        if (InputShakeEventsEnabled && InputAllEventsEnabled)
        {
            Vector3 mPositionNoZ = Input.mousePosition;
            mPositionNoZ.z = 0.0f;
            Vector3 cShakeDiff = mPositionNoZ - _shakeLast;
            _shakeLast = mPositionNoZ;

            if (cShakeDiff.sqrMagnitude >= ShakeVectorMinimumSqrLengthPC &&
                Input.GetMouseButton(2) &&
                Time.time - _shakeLastTimeSeconds >= ShakeTimeMinBetweenSeconds)
            {
                _shakeLastTimeSeconds = Time.time;
                OnInputShake.Invoke(cShakeDiff);
            }
        }

        // showing pause menu on back button pressed
        //if (Input.GetKeyUp(KeyCode.Escape))
        //{
        //GameManager.Instance.ShowPauseMenu();
        //}
    }
 // Swipe callback
 public void onSwipe( UISwipeDetector sender, SwipeDirection direction )
 {
     swipeText.text = direction.ToString();
 }
Example #10
0
 void OnSwipeDetected(SwipeDirection direction, Hand hand)
 {
     App.ViewModel.SwipeInfo = "Swiped " + hand.ToString() + " hand, to the " + direction.ToString();
 }
Example #11
0
    private void Update()
    {
        //state = Controller.UPvr_GetSwipeDirection(1);
        //if(Controller.UPvr_GetSwipeDirection(1)==SwipeDirection.SwipeLeft)
        //txt.text = Controller.UPvr_GetSwipeDirection(1).ToString();
        string         msg;
        SwipeDirection s = Controller.UPvr_GetTouchPadDirection(1, out msg);

        txt.text = s.ToString() + " " + msg;

        //if (Controller.UPvr_GetKey(0, Pvr_KeyCode.Left))
        //{
        //    txt.text = "0Grip按下";
        //}
        //if (Controller.UPvr_GetKey(1, Pvr_KeyCode.Right))
        //{
        //    txt.text = "1Grip按下";
        //}
        if (CurrentController != null && GetTeleportKey())
        {
            line.enabled = true;
            //sdkManagerGo = currentController.transform.parent.gameObject;
            ray.direction = CurrentController.transform.Find("dot").position - CurrentController.transform.Find("start").position;
            ray.origin    = CurrentController.transform.Find("start").position;

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                currentHitPoint = hit.point;
                if (HitFloor(ref hit) && hit.point != null)
                {
                    PointGo.transform.position = hit.point;

                    PointGo.SetActive(true);
                    //CurrentController.transform.Find("dot").position = hit.point;
                }
            }
            else
            {
                PointGo.SetActive(false);
            }

            DrawLine();
        }
        else
        {
            if (currentHitPoint != Vector3.zero)
            {
                if (PointGo.activeInHierarchy)
                {
                    MoveCameraPrefab(currentHitPoint);

                    currentHitPoint = Vector3.zero;
                    PointGo.SetActive(false);
                }
            }

            if (line.enabled == false)
            {
                return;
            }
            line.enabled = false;
        }
    }
Example #12
0
 public static void UpdateAnimator(Animator animator, SwipeDirection direction)
 {
     UpdateAnimator(
         animator
         , (MovementDirection)Enum.Parse(typeof(MovementDirection), direction.ToString()));
 }
Example #13
0
 // Swipe callback
 public void onSwipe(UISwipeDetector sender, SwipeDirection direction)
 {
     swipeText.text = direction.ToString();
 }