Example #1
0
 private void Start()
 {
     if (onSoundChangedCallback != null)
     {
         onSoundChangedCallback.Invoke();
     }
 }
Example #2
0
    public void DecaySanityConstant()
    {
        if (isDecaying && !isFrozen)
        {
            if (currentSanity > 0)
            {
                currentSanity = Mathf.Lerp(currentSanity, currentSanity - InsanityDecaySpeed, InsanityDecaySpeed * Time.deltaTime);

                UIMaster.instance.onMeterChange.Invoke(9 - currentSanity);

                float normalisedSanity = 1f - (currentSanity / maxSanity);
                CameraEffects.instance.ApplyInsanity(normalisedSanity);

                OnSoundChanged?.Invoke(normalisedSanity);

                if (normalisedSanity >= 0.7f)
                {
                    if (!warn.IsFlashing())
                    {
                        warn.StartFlashing();
                    }
                }
            }
            else if (!godMode)
            {
                onPlayerLose?.Invoke();
                CameraEffects.instance.ApplyInsanity(1);
            }
        }
    }
Example #3
0
    public void DecaySanityByAmount()
    {
        if (isDecaying)
        {
            float projectedSanity = Mathf.Lerp(currentSanity, currentSanity - impactSanityDamage, impactSanityDamage * Time.deltaTime);

            if (projectedSanity > 0)
            {
                currentSanity = projectedSanity;

                UIMaster.instance.onMeterChange.Invoke(9 - currentSanity);

                float normalisedSanity = 1f - (currentSanity / maxSanity);

                OnSoundChanged?.Invoke(normalisedSanity);

                if (normalisedSanity >= 0.7f)
                {
                    if (!warn.IsFlashing())
                    {
                        warn.StartFlashing();
                    }
                }
            }
            else if (!godMode)
            {
                onPlayerLose?.Invoke();
            }
        }
    }
Example #4
0
    public void ImproveSanity()
    {
        float sanity = Mathf.Lerp(currentSanity, currentSanity + sanityDodgeIncrease, sanityDodgeIncrease * Time.deltaTime);

        if (sanity >= maxSanity)
        {
            sanity = maxSanity;
        }

        if (isDecaying)
        {
            isDecaying = false;
            if (sanity <= maxSanity)
            {
                currentSanity = Mathf.Clamp(sanity, 0, maxSanity);

                UIMaster.instance.onMeterChange.Invoke(9 - currentSanity, true);

                float normalisedSanity = 1f - (currentSanity / maxSanity);

                OnSoundChanged?.Invoke(normalisedSanity);

                if (normalisedSanity < 0.7f)
                {
                    if (warn.IsFlashing())
                    {
                        warn.StopFlashing();
                    }
                }
            }
        }
        isDecaying = true;
    }