private void updateSoundsAndEffects(double hereStability, double ownStability) { if (!isSelf || tempStabSoundDrain == null) { return; } // Effects float fadeSpeed = 3f; // Sounds if (hereStability < 0.95f && ownStability < 0.65f) { if (!tempStabSoundDrain.IsPlaying) { tempStabSoundDrain.Start(); } tempStabSoundDrain.FadeTo(Math.Min(1, 3 * (1 - hereStability)), 0.95f * fadeSpeed, (s) => { }); } else { tempStabSoundDrain.FadeTo(0, 0.95f * fadeSpeed, (s) => { tempStabSoundDrain.Stop(); }); } SurfaceMusicTrack.ShouldPlayMusic = ownStability > 0.45f; CaveMusicTrack.ShouldPlayCaveMusic = ownStability > 0.2f; if (ownStability < 0.4f) { if (!tempStabSoundLow.IsPlaying) { tempStabSoundLow.Start(); } float volume = (0.4f - (float)ownStability) * 1 / 0.4f; tempStabSoundLow.FadeTo(Math.Min(1, volume), 0.95f * fadeSpeed, (s) => { }); } else { tempStabSoundLow.FadeTo(0, 0.95f * fadeSpeed, (s) => { tempStabSoundLow.Stop(); }); } if (ownStability < 0.25f) { if (!tempStabSoundVeryLow.IsPlaying) { tempStabSoundVeryLow.Start(); } float volume = (0.25f - (float)ownStability) * 1 / 0.25f; tempStabSoundVeryLow.FadeTo(Math.Min(1, volume) / 5f, 0.95f * fadeSpeed, (s) => { }); } else { tempStabSoundVeryLow.FadeTo(0, 0.95f * fadeSpeed, (s) => { tempStabSoundVeryLow.Stop(); }); } }