protected void PlaySound(AudioClip clip, bool isRunSound) { if (clip == null) { return; } audioSource.clip = clip; if (pitchVariance > 0f) { float randomPitch = 1f + Random.Range(-pitchVariance, pitchVariance); audioSource.pitch = randomPitch; } if (volumeVariance > 0f) { float randomVolume = 1f - Random.Range(0f, volumeVariance); if (soundToPlayFrom != null) { soundToPlayFrom.ChangeRelativeVolume(randomVolume * originalRelativeSound); } else { audioSource.volume = randomVolume; } } if (soundToPlayFrom != null) { soundToPlayFrom.Play(false); if (KickStarter.eventManager != null) { KickStarter.eventManager.Call_OnPlayFootstepSound(character, this, !isRunSound, soundToPlayFrom.audioSource, clip); } } else { audioSource.loop = false; audioSource.Play(); if (KickStarter.eventManager != null) { KickStarter.eventManager.Call_OnPlayFootstepSound(character, this, !isRunSound, audioSource, clip); } } }
override public float Run() { if (!isRunning) { if (soundObject) { soundObject.ChangeRelativeVolume(newRelativeVolume, changeTime); if (willWait && changeTime > 0f) { isRunning = true; return(changeTime); } } } else { isRunning = false; } return(0f); }
public override float Run() { if (!isRunning) { if (runtimeSoundObject != null) { runtimeSoundObject.ChangeRelativeVolume(newRelativeVolume, changeTime); if (willWait && changeTime > 0f) { isRunning = true; return(changeTime); } } } else { isRunning = false; } return(0f); }