示例#1
0
    public void PlaySingleSFXWithRandomPitch(AudioClip clip, ESFXType type)
    {
        float randomPitch = Random.Range(minPitchSFXRange, maxPitchSFXRange);

        _randomPitchSources[_currentRandomSourceIndex].pitch = randomPitch;
        _randomPitchSources[_currentRandomSourceIndex].clip  = clip;
        _randomPitchSources[_currentRandomSourceIndex].Play();

        _currentRandomSourceIndex = (_currentRandomSourceIndex + 1) % RANDOM_PITCH_SOURCES_SIZE;
    }
示例#2
0
    public void PlaySingleSFX(AudioClip clip, ESFXType type)
    {
        //Resets the pitch
        AudioSource source = null;

        switch (type)
        {
        case ESFXType.ESFXType_PLAYER:
            source = _playerSFXAudioSource;
            break;

        case ESFXType.ESFXType_GAMEPLAY:
            source = _gameplaySFXAudioSource;
            break;
        }

        if (source)
        {
            source.pitch = 1.0f;
            source.PlayOneShot(clip);
        }
    }
示例#3
0
 public void PlayLoopSFX(ESFXType type)
 {
     refs.loopAudio.clip   = clips[type];
     refs.loopAudio.volume = volumes[type];
     refs.loopAudio.Play( );
 }
示例#4
0
 public void PlaySFX(ESFXType type)
 {
     refs.audio.PlayOneShot(clips[type], volumes[type]);
 }