Example #1
0
    public void ShakeCamera(float power = 2f, float duration = 0.2f, int vibro = 2, float elasitcy = 0.5f)
    {
        if (isShaking)
        {
            return;
        }

        isShaking = true;
        transform.DOPunchRotation(Vector3.forward * power, duration, vibro, elasitcy).OnComplete(() => isShaking = false);
        HapticManager.Haptic(HapticTypes.RigidImpact);
    }
Example #2
0
    private void TapInput()
    {
        if (Input.GetMouseButtonDown(0))
        {
            tapInputDownTime = Time.time;
        }

        if (Input.GetMouseButtonUp(0))
        {
            tapDuration = Mathf.Abs(tapInputDownTime - Time.time);

            if (tapDuration < 0.2f)
            {
                OnTapInput.Invoke();
                HapticManager.Haptic(HapticTypes.SoftImpact);
                //Debug.Log("Tap " + tapDuration);
            }
            tapDuration = 0;
        }

        //Editor Input
        //#if UNITY_EDITOR
        //        if (Input.GetMouseButtonDown(0))
        //            tapInputDownTime = Time.time;

        //        if (Input.GetMouseButtonUp(0))
        //        {
        //            tapDuration = Mathf.Abs(tapInputDownTime - Time.time);

        //            if (tapDuration < 0.2f)
        //            {
        //                OnTapInput.Invoke();
        //                //Debug.Log("Tap " + tapDuration);
        //            }
        //            tapDuration = 0;

        //        }
        //#else //Android and IOS Input


        //        if(Input.touchCount > 0)
        //        {
        //            Touch touch = Input.GetTouch(0);

        //            switch (touch.phase)
        //            {
        //                case TouchPhase.Began:
        //                    tapInputDownTime = Time.time;
        //                    break;
        //                case TouchPhase.Moved:
        //                    break;
        //                case TouchPhase.Stationary:
        //                    break;
        //                case TouchPhase.Ended:
        //                    tapDuration = Mathf.Abs(tapInputDownTime - Time.time);

        //                    if (tapDuration < 0.2f)
        //                    {
        //                        OnTapInput.Invoke();
        //                        //Debug.Log("Tap " + tapDuration);
        //                    }
        //                    tapDuration = 0;
        //                    GameManager.Instance.StartGame();
        //                    LevelManager.Instance.StartLevel();
        //                    break;
        //                case TouchPhase.Canceled:
        //                    tapDuration = Mathf.Abs(tapInputDownTime - Time.time);

        //                    if (tapDuration < 0.2f)
        //                    {
        //                        OnTapInput.Invoke();
        //                        //Debug.Log("Tap " + tapDuration);
        //                    }
        //                    tapDuration = 0;
        //                    break;
        //                default:
        //                    break;
        //            }
        //        }
        //#endif
    }