Beispiel #1
0
 public void InitializeEqualizerInBattle()
 {
     gameObject.SetActive(true);
     active = true;
     previousMusicSettings = null;
 }
Beispiel #2
0
    private void ApplyHealthEffects(int percentage)
    {
        const int basicModeMin    = 41;
        var       corruptionLevel = 0;

        AudioManager.MusicSettings musicSettings;
        if (percentage >= basicModeMin)
        {
            musicSettings = AudioManager.MusicSettings.DEFAULT_SETTINGS;
        }
        else
        {
            const int corruptionLevel2 = 35;
            const int corruptionLevel3 = 30;
            const int corruptionLevel4 = 25;
            const int corruptionLevel5 = 20;
            const int corruptionLevel6 = 10;
            if (percentage <= corruptionLevel6)
            {
                corruptionLevel = 6;
            }
            else if (percentage <= corruptionLevel5)
            {
                corruptionLevel = 5;
            }
            else if (percentage <= corruptionLevel4)
            {
                corruptionLevel = 4;
            }
            else if (percentage <= corruptionLevel3)
            {
                corruptionLevel = 3;
            }
            else if (percentage <= corruptionLevel2)
            {
                corruptionLevel = 2;
            }
            else
            {
                corruptionLevel = 1;
            }

            const float middleLowPass = 4000;
            var         point         = (float)percentage / basicModeMin;
            float       lowPass;
            if (point > 0.5f)
            {
                var t = Mathf.InverseLerp(0.5f, 1f, point);
                lowPass = Mathf.Lerp(middleLowPass, AudioManager.MusicSettings.NORMAL_LOWPASS, t);
            }
            else
            {
                var t = Mathf.InverseLerp(0, 0.5f, point);
                lowPass = Mathf.Lerp(AudioManager.MusicSettings.MIN_LOWPASS, middleLowPass, t);
            }

            musicSettings = new AudioManager.MusicSettings(lowPass);
        }

        if (previousMusicSettings == null || !musicSettings.Equals(previousMusicSettings))
        {
            previousMusicSettings = musicSettings;
            AudioManager.Instance.ApplyMusicSettings(previousMusicSettings);
        }

        GameUI.Instance.corruption.UpdateCorruption(corruptionLevel);
    }