Пример #1
0
    public bool PlayRMS(AudioChannel channel, Vector3 pos, float rms, float pitch)
    {
        float num  = rms;
        float num2 = pitch;

        rms *= volumeAdjust;
        rms  = ((rndVolumeMin != rndVolumeMax) ? (rms * Random.Range(rndVolumeMin, rndVolumeMax)) : (rms * rndVolumeMin));
        if (!CanPlay(rms))
        {
            return(false);
        }
        pitch = ((rndPitchMin != rndPitchMax) ? (pitch * Random.Range(rndPitchMin, rndPitchMax)) : (pitch * rndPitchMin));
        int         num3        = Random.Range(0, clips.Length);
        AudioClip   audioClip   = clips[num3];
        float       volumeScale = rms / clipsRms[num3];
        AudioSource audioSource = AudioSourcePool.Allocate(poolId, null, pos);

        audioSource.pitch = pitch;
        audioSource.outputAudioMixerGroup = AudioRouting.GetChannel(channel);
        audioSource.volume = 1f;
        audioSource.PlayOneShot(audioClip, volumeScale);
        float time = Time.time;

        if (blockTime > 0f)
        {
            blockUntil = Mathf.Max(blockUntil, time + blockTime);
        }
        if (maxVoices > 0)
        {
            polyphonyBlockUntil.Add(time + audioClip.length);
            playingLoudness.Add(rms);
        }
        return(true);
    }