private void Update() { float f = Mathf.InverseLerp(0f, 2000f, force.magnitude); f = Mathf.Sqrt(f); float num = Vector3.Dot(boom.transform.right, force.normalized); num = Mathf.Clamp(num * 100f, -1f, 1f); float num2 = Mathf.Abs(Vector3.Dot(rhs: (wind - boom.GetPointVelocity(forcePoint.position)).normalized, lhs: boom.transform.right)); float num3 = Mathf.Sqrt(1f - num2 * num2); float time = ReplayRecorder.time; float num4 = lastFrameTime - time; lastFrameTime = time; phaseOpen += num4 * f * f * 100f; phaseFill += num4 * f * 5f; float value = num2 * num * f; float value2 = num3 * num * f; value = Smoothing.SmoothValue(smoothFill, value); value2 = Smoothing.SmoothValue(smoothOpen, value2); SetSignedShape(0, 150f * value + Mathf.Sin(phaseFill) * Mathf.Lerp(5f, 0f, f * 10f)); SetSignedShape(2, 150f * value2 + Mathf.Sin(phaseOpen) * Mathf.Lerp(10f, 5f, f)); if (sailSound != null) { sailSound.SetPitch(Mathf.Lerp(0.4f, 1.2f, f)); sailSound.SetVolume(Mathf.Lerp(0.2f, 1f, f)); } }
private void SyncAudio() { if (sound == null) { return; } int num = isHot ? Mathf.Clamp(coalList.Count, 0, 5) : 0; if (currentAudio == num) { return; } currentAudio = num; if (num == 0) { if (sound.isPlaying) { sound.Stop(); } return; } sound.SetPitch(0.9f + (float)currentAudio * 0.1f); sound.SetVolume(0.5f + fireVolume * 0.1f); sound.Switch((char)(65 + num - 1)); if (!sound.isPlaying) { sound.Play(forceLoop: true); } }
public float ApplyVolume(int idx, Vector3 pos) { float num = 0f; if (idx + 1 < all.Count) { num = all[idx + 1].ApplyVolume(idx + 1, pos); } float num2 = GetOpacity(pos) * baseOpacity; if (num2 < grid.volumeTreshold) { if (sound.isPlaying) { sound.Stop(); } } else if (!sound.isPlaying) { sound.Play(); } currentVolume = Mathf.MoveTowards(currentVolume, num2 * (1f - num), Time.deltaTime / grid.fadeDuration); sound.SetVolume(currentVolume); return(num + (1f - num) * num2); }
private void SignalChanged(float val) { if (sound != null) { sound.SetPitch(Mathf.Lerp(minPitch, maxPitch, val)); sound.SetVolume(Mathf.Lerp(minVolume, maxVolume, val)); } else { source.pitch = Mathf.Lerp(minPitch, maxPitch, val); source.volume = Mathf.Lerp(minVolume, maxVolume, val); } }