コード例 #1
0
 public virtual void EmphasisHapticsButton()
 {
     HapticPatterns.PlayEmphasis(EmphasisAmplitude, EmphasisFrequency);
     StartCoroutine(Logo.Shake(0.2f));
     DebugAudioEmphasis.volume = EmphasisAmplitude;
     DebugAudioEmphasis.pitch  = 0.5f + EmphasisFrequency / 2f;
     DebugAudioEmphasis.Play();
 }
コード例 #2
0
        protected virtual void HitWall()
        {
            float amplitude = _rigidBody.velocity.magnitude / 100f;

            HapticPatterns.PlayEmphasis(amplitude, 0.7f);
            EmphasisAudioSource.volume = amplitude;
            StartCoroutine(LogoShaker.Shake(0.2f));
            EmphasisAudioSource.Play();
            _ballAnimator.SetTrigger(_hitAnimationParameter);
        }
コード例 #3
0
 public virtual void HitPusher()
 {
     HitPusherParticles.Play();
     HapticController.fallbackPreset = HapticPatterns.PresetType.Selection;
     HapticPatterns.PlayEmphasis(0.85f, 0.05f);
     EmphasisAudioSource.volume = 0.1f;
     StartCoroutine(LogoShaker.Shake(0.2f));
     EmphasisAudioSource.Play();
     _ballAnimator.SetTrigger(_hitAnimationParameter);
 }
コード例 #4
0
        /// <summary>
        /// On play we play our preset haptic
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
            {
                return;
            }

            HapticSettings.SetGamepad();
            HapticPatterns.PlayPreset(Preset);
        }
コード例 #5
0
        /// <summary>
        /// On play, we randomize our amplitude and frequency and play our emphasis haptic
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
            {
                return;
            }

            float amplitude = Random.Range(MinAmplitude, MaxAmplitude);
            float frequency = Random.Range(MinFrequency, MaxFrequency);

            HapticSettings.SetGamepad();
            HapticPatterns.PlayEmphasis(amplitude, frequency);
        }
コード例 #6
0
        /// <summary>
        /// On play we randomize our amplitude and frequency, trigger our haptic, and initialize real time modulation if needed
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
            {
                return;
            }

            float amplitude = Random.Range(MinAmplitude, MaxAmplitude);
            float frequency = Random.Range(MinFrequency, MaxFrequency);

            _duration = Random.Range(MinDuration, MaxDuration);
            HapticSettings.SetGamepad();
            HapticPatterns.PlayConstant(amplitude, frequency, FeedbackDuration);

            if (UseRealTimeModulation)
            {
                _coroutine = Owner.StartCoroutine(RealtimeModulationCo());
            }
        }
コード例 #7
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();
     }
 }
コード例 #8
0
 public virtual void TurnHapticsOn()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Success);
 }
コード例 #9
0
 public virtual void LightButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.LightImpact);
     ChangeImage(LightSprite);
 }
コード例 #10
0
 public virtual void SoftButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.SoftImpact);
     ChangeImage(SoftSprite);
 }
コード例 #11
0
 public virtual void RigidButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.RigidImpact);
     ChangeImage(RigidSprite);
 }
コード例 #12
0
 public virtual void FailureButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Failure);
     ChangeImage(FailureSprite);
 }
コード例 #13
0
 public virtual void WarningButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Warning);
     ChangeImage(WarningSprite);
 }
コード例 #14
0
 public virtual void SuccessButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Success);
     ChangeImage(SuccessSprite);
 }
コード例 #15
0
 public virtual void SelectionButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Selection);
     ChangeImage(SelectionSprite);
 }
コード例 #16
0
 public virtual void HeavyButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.HeavyImpact);
     ChangeImage(HeavySprite);
 }
コード例 #17
0
 public virtual void MediumButton()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.MediumImpact);
     ChangeImage(MediumSprite);
 }
コード例 #18
0
 public virtual void TurnHapticsOff()
 {
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Warning);
 }
コード例 #19
0
 public virtual void TurnSoundsOn()
 {
     AudioListener.volume = 1f;
     SoundActive          = true;
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Success);
 }
コード例 #20
0
 public virtual void TurnSoundsOff()
 {
     AudioListener.volume = 0f;
     SoundActive          = false;
     HapticPatterns.PlayPreset(HapticPatterns.PresetType.Warning);
 }
コード例 #21
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();
                    }
                }
            }
        }