public void PlayAtPosition(SoundId id, Vector2 pos) { float dist = Vector2.Distance(this.player.transform.position, pos); if (dist > this.spatialSoundsMaxDistance) { return; } Sound sound = this.sounds.Find(o => o.id == id); if (sound == null) { Debug.LogWarning("Couldn't find sound with id " + id.ToString()); return; } sound.ApplyPitch(this.sfxSource); float t = (dist - this.spatialSoundsMinDistance) / (this.spatialSoundsMaxDistance - this.spatialSoundsMinDistance); t = Mathf.Clamp01(t); this.sfxSource.PlayOneShot(sound.clip, sound.volume * this.spatialSoundFalloffCurve.Evaluate(t)); }
public void PlaySfx(SoundId id) { Sound sound = this.sounds.Find(o => o.id == id); if (sound == null) { Debug.LogWarning("Couldn't find sound with id " + id.ToString()); return; } sound.ApplyPitch(this.sfxSource); this.sfxSource.PlayOneShot(sound.clip, sound.volume); }
public static void PlaySound(this SoundManager sound, SoundId soundId) { string path = Utility.Text.Format("Assets/Game/Res/Sounds/Sound/{0}.mp3", soundId.ToString()); GameEntry.Sound.PlaySound(path, true); }