Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.touches[0];
            switch (touch.phase)
            {
            case TouchPhase.Began:
                //Condition that terminate touch
                if (!InhalerUtility.IsTouchingObject(touch, gameObject))
                {
                    return;
                }

                //Store first touch position
                firstTouchOnObject = true;
                startTouchPos      = touch.position;
                break;

            case TouchPhase.Moved:
                //Condition that terminate touch
                if (!firstTouchOnObject)
                {
                    return;
                }

                if (IsDragging(touch))
                {
                    //If swipe down and correct step. Move on to the next step
                    if (InhalerGameManager.Instance.IsCurrentStepCorrect(gameStepID))
                    {
                        // exhale.Play();
                        InhalerGameManager.Instance.NextStep();
                        Disable();
                    }
                }
                break;

            case TouchPhase.Ended:
                if (!firstTouchOnObject)
                {
                    return;
                }

                firstTouchOnObject = false;
                break;
            }
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (InhalerGameManager.Instance.CurrentStep != advairStepID)
        {
            return;
        }
        if (!GetComponent <Collider>().enabled)
        {
            GetComponent <Collider>().enabled = true;
        }
        if (Input.touchCount > 0)
        {
            Touch touch = Input.touches[0];
            switch (touch.phase)
            {
            case TouchPhase.Began:
                //Condition that terminate touch
                if (!InhalerUtility.IsTouchingObject(touch, gameObject))
                {
                    return;
                }

                firstTouchOnObject = true;
                HideLargeInhaler();
                ShowSmallInhaler(touch.position);
                break;

            case TouchPhase.Moved:
                //Condition that terminate touch
                if (!firstTouchOnObject)
                {
                    return;
                }

                //Move the small advair icon to the finger position
                MoveSmallInhalerToTouchPos(touch.position);
                break;

            case TouchPhase.Ended:
                //Condition that terminate touch
                if (!firstTouchOnObject)
                {
                    return;
                }

                firstTouchOnObject = false;
                if (InhalerUtility.IsTouchingObject(touch, petSprite))     //Check if advair drop on pet
                {
                    if (InhalerGameManager.Instance.IsCurrentStepCorrect(advairStepID))
                    {
                        InhalerGameManager.Instance.NextStep();
                        HideSmallInhaler();
                    }
                }
                else
                {
                    ShowLargeInhaler();
                    HideSmallInhaler();
                }
                break;
            }
        }
    }