Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (myPressureSettings == IsPressureAllowed.PressureAllowed)
        {
            if (PressureKeepersCount > 0 && PressureVolume != VolumeMax)
            {
                PressureVolume = 1;
                PressureVolume = Mathf.Clamp(PressureVolume, 0f, VolumeMax);
                Layer4.volume  = PressureVolume;
            }
            else if (PressureKeepersCount == 0 && PressureVolume != 0)
            {
                PressureVolume -= SpeedChange * Time.deltaTime;
                PressureVolume  = Mathf.Clamp(PressureVolume, 0f, VolumeMax);
                Layer4.volume   = PressureVolume;
            }
        }

        if (mySmoothStatus == SmoothStatus.Open)
        {
            for (int i = 0; i < ConstantPlaying.Count; i++)
            {
                ConstantPlaying[i].volume += Time.deltaTime / 4;
                ConstantPlaying[i].volume  = Mathf.Clamp(ConstantPlaying[i].volume, 0f, VolumeMax);
                if (ConstantPlaying[i].volume == VolumeMax)
                {
                    mySmoothStatus = SmoothStatus.Constant;
                }
            }
        }
        else if (mySmoothStatus == SmoothStatus.Close)
        {
            for (int i = 0; i < ConstantPlaying.Count; i++)
            {
                ConstantPlaying[i].volume -= Time.deltaTime;
                ConstantPlaying[i].volume  = Mathf.Clamp(ConstantPlaying[i].volume, 0f, VolumeMax);
                if (ConstantPlaying[i].volume == 0)
                {
                    mySmoothStatus = SmoothStatus.Constant;
                }
            }
        }
    }
Beispiel #2
0
 public void CloseMusic() => mySmoothStatus = SmoothStatus.Close;