Пример #1
0
 protected virtual void UpdateContinuousDemo()
 {
     if (_timeLeft > 0f)
     {
         ContinuousProgressBar.UpdateBar(_timeLeft, 0f, ContinuousDuration);
         _timeLeft       -= Time.deltaTime;
         Logo.Shaking     = true;
         TargetCurve.Move = true;
         Logo.Amplitude   = NiceVibrationsDemoHelpers.Remap(ContinuousAmplitude, 0f, 1f, 1f, 8f);
         Logo.Frequency   = NiceVibrationsDemoHelpers.Remap(ContinuousFrequency, 0f, 1f, 10f, 25f);
     }
     else
     {
         ContinuousProgressBar.UpdateBar(0f, 0f, ContinuousDuration);
         Logo.Shaking     = false;
         TargetCurve.Move = false;
         if (_continuousActive)
         {
             HapticController.Stop();
         }
     }
     if ((_frequencyLastFrame != ContinuousFrequency) || (_amplitudeLastFrame != ContinuousAmplitude))
     {
         TargetCurve.UpdateCurve(ContinuousAmplitude, ContinuousFrequency);
     }
     _amplitudeLastFrame = ContinuousAmplitude;
     _frequencyLastFrame = ContinuousFrequency;
 }
Пример #2
0
        /// <summary>
        /// On play we apply the specified order
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active || !FeedbackTypeAuthorized)
            {
                return;
            }

            switch (ControlType)
            {
            case ControlTypes.Stop:
                HapticController.Stop();
                break;

            case ControlTypes.EnableHaptics:
                HapticController.hapticsEnabled = true;
                break;

            case ControlTypes.DisableHaptics:
                HapticController.hapticsEnabled = false;
                break;

            case ControlTypes.AdjustHapticsLevel:
                HapticController.outputLevel = OutputLevel;
                break;

            case ControlTypes.Initialize:
                LofeltHaptics.Initialize();
                HapticController.Init();
                break;

            case ControlTypes.Release:
                LofeltHaptics.Release();
                break;
            }
        }
Пример #3
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
 }
 void OnDisable()
 {
     HapticController.PlaybackStopped -= OnHapticsStopped;
     if (HapticController.IsPlaying())
     {
         HapticController.Stop();
     }
 }
        // Haptic Clip -----------------------------------------------------------------------------

        public virtual void PlayHapticClip(int index)
        {
            Logo.Shaking = true;

            HapticController.fallbackPreset = HapticPatterns.PresetType.LightImpact;
            HapticController.Play(DemoItems[index].HapticClip);
            DemoItems[index].AssociatedSound.Play();
            StopAllCoroutines();
            StartCoroutine(ChangeIcon(DemoItems[index].AssociatedSprite));
        }
Пример #6
0
        protected virtual void Transition(int previous, int next, bool goingRight)
        {
            HapticController.Reset();

            if (_transitionCoroutine != null)
            {
                StopCoroutine(_transitionCoroutine);
            }
            _transitionCoroutine = StartCoroutine(TransitionCoroutine(previous, next, goingRight));
        }
Пример #7
0
        /// <summary>
        /// On stop we stop haptics
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
        {
            if (!FeedbackTypeAuthorized)
            {
                return;
            }

            base.CustomStopFeedback(position, feedbacksIntensity);
            IsPlaying = false;
            HapticController.Stop();
        }
Пример #8
0
        /// <summary>
        /// On stop we stop haptics and our coroutine
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
        {
            if (!FeedbackTypeAuthorized)
            {
                return;
            }

            base.CustomStopFeedback(position, feedbacksIntensity);
            IsPlaying = false;
            HapticController.Stop();
            if (Active && (_coroutine != null))
            {
                Owner.StopCoroutine(_coroutine);
                _coroutine = null;
            }
        }
Пример #9
0
        /// <summary>
        /// On play, we load our clip, set its settings and play it
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay() || (Clip == null))
            {
                return;
            }

            HapticController.Load(Clip);
            HapticSettings.SetGamepad();
            HapticController.fallbackPreset = FallbackPreset;
            HapticController.Loop(Loop);
            HapticController.Seek(SeekTime);
            HapticController.clipLevel          = Random.Range(MinLevel, MaxLevel);
            HapticController.clipFrequencyShift = Random.Range(MinFrequencyShift, MaxFrequencyShift);
            HapticController.Play();
        }
Пример #10
0
 public virtual void ContinuousHapticsButton()
 {
     if (!_continuousActive)
     {
         // START
         HapticController.fallbackPreset = HapticPatterns.PresetType.LightImpact;
         HapticPatterns.PlayConstant(ContinuousAmplitude, ContinuousFrequency, ContinuousDuration);
         _timeLeft = ContinuousDuration;
         ContinuousButtonText.text   = "Stop continuous haptic pattern";
         DurationSlider.interactable = false;
         _continuousActive           = true;
         DebugAudioContinuous.Play();
     }
     else
     {
         // STOP
         HapticController.Stop();
         ResetPlayState();
     }
 }
Пример #11
0
 private void Start()
 {
     _lastFire         = Time.time;
     _hapticController = HapticController.Instance;
     _layerMask        = LayerMask.GetMask("Ground_Asphalt", "Ground_Grass", "Ground_Gravel", "Ground_Wood", "Ground_Metal");
 }
Пример #12
0
        protected virtual void HandlePower()
        {
            _knobValue = Knob.Active ? Knob.Value : 0f;

            if (!_carStarted)
            {
                if ((_knobValue > MinimumKnobValue) && (Knob.Active))
                {
                    _carStarted       = true;
                    _carStartedAt     = Time.time;
                    _lastStartClickAt = Time.time;

                    HapticPatterns.PlayConstant(_knobValue, _knobValue, MaximumPowerDuration);
                    CarEngineAudioSource.Play();
                }
                else
                {
                    Power += Time.deltaTime * ChargingSpeed;
                    Power  = Mathf.Clamp(Power, 0f, MaximumPowerDuration);

                    if (Power == MaximumPowerDuration)
                    {
                        Knob.SetActive(true);
                        Knob._rectTransform.localScale = Vector3.one;
                        ReloadingPrompt.SetActive(false);
                    }
                    else
                    {
                        if (!Knob.Active)
                        {
                            Knob.SetValue(CarSpeed);
                        }
                    }
                }
            }
            else
            {
                if (Time.time - _carStartedAt > MaximumPowerDuration)
                {
                    _carStarted = false;
                    Knob.SetActive(false);
                    Knob._rectTransform.localScale = Vector3.one * 0.9f;
                    ReloadingPrompt.SetActive(true);
                }
                else
                {
                    if (_knobValue > MinimumKnobValue)
                    {
                        Power -= Time.deltaTime;
                        Power  = Mathf.Clamp(Power, 0f, MaximumPowerDuration);

                        HapticController.clipLevel          = _knobValue;
                        HapticController.clipFrequencyShift = _knobValue;

                        if (Power <= 0f)
                        {
                            _carStarted = false;
                            Knob.SetActive(false);
                            Knob._rectTransform.localScale = Vector3.one * 0.9f;
                            ReloadingPrompt.SetActive(true);
                            HapticController.Stop();
                        }
                    }
                    else
                    {
                        _carStarted       = false;
                        _lastStartClickAt = Time.time;
                        HapticController.Stop();
                    }
                }
            }
        }