public virtual void EmphasisHapticsButton() { HapticPatterns.PlayEmphasis(EmphasisAmplitude, EmphasisFrequency); StartCoroutine(Logo.Shake(0.2f)); DebugAudioEmphasis.volume = EmphasisAmplitude; DebugAudioEmphasis.pitch = 0.5f + EmphasisFrequency / 2f; DebugAudioEmphasis.Play(); }
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); }
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); }
/// <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); }
/// <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); }
/// <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()); } }
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(); } }
public virtual void TurnHapticsOn() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.Success); }
public virtual void LightButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.LightImpact); ChangeImage(LightSprite); }
public virtual void SoftButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.SoftImpact); ChangeImage(SoftSprite); }
public virtual void RigidButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.RigidImpact); ChangeImage(RigidSprite); }
public virtual void FailureButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.Failure); ChangeImage(FailureSprite); }
public virtual void WarningButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.Warning); ChangeImage(WarningSprite); }
public virtual void SuccessButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.Success); ChangeImage(SuccessSprite); }
public virtual void SelectionButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.Selection); ChangeImage(SelectionSprite); }
public virtual void HeavyButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.HeavyImpact); ChangeImage(HeavySprite); }
public virtual void MediumButton() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.MediumImpact); ChangeImage(MediumSprite); }
public virtual void TurnHapticsOff() { HapticPatterns.PlayPreset(HapticPatterns.PresetType.Warning); }
public virtual void TurnSoundsOn() { AudioListener.volume = 1f; SoundActive = true; HapticPatterns.PlayPreset(HapticPatterns.PresetType.Success); }
public virtual void TurnSoundsOff() { AudioListener.volume = 0f; SoundActive = false; HapticPatterns.PlayPreset(HapticPatterns.PresetType.Warning); }
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(); } } } }