public void OnTileTypeChanged(Tile tileData) { SoundClip clip = AudioManager.GetAudio("Sound", "Floor_OnCreated"); if (cooldowns.ContainsKey(clip) && cooldowns[clip] > 0) { return; } cooldowns[clip] = 0.1f; PlaySoundAt(clip.Get(), tileData, "gameSounds", 1); }
public void OnButtonSFX() { SoundClip clip = AudioManager.GetAudio("Sound", "MenuClick"); if (cooldowns.ContainsKey(clip) && cooldowns[clip] > 0) { return; } cooldowns[clip] = 0.1f; PlaySound(clip.Get(), "UI"); }
public void OnFurnitureCreated(Furniture furniture) { SoundClip clip = AudioManager.GetAudio("Sound", furniture.Type + "_OnCreated"); if (cooldowns.ContainsKey(clip) && cooldowns[clip] > 0) { return; } cooldowns[clip] = 0.1f; PlaySoundAt(clip.Get(), furniture.Tile, "gameSounds"); }
/// <summary> /// Plays the clip at tile's location, on the channel group chanGroup. Pitch ranges from -freqRange to +freqRange in semitones. /// Volume ranges from -volRange to No change in decibels. /// </summary> /// <param name="clip">Sound to Play.</param> /// <param name="tile">Tile's location to play at. If null, plays at camera's position.</param> /// <param name="chanGroup">Chan group to play the sound on.</param> /// <param name="freqRange">Frequency range in semitones.</param> /// <param name="volRange">Volume range in decibels.</param> public void PlaySoundAt(SoundClip clip, Tile tile, string chanGroup = "master", float freqRange = 0f, float volRange = 0f, float cooldownTime = 0.1f) { if (clip == null || !clip.CanPlay()) { return; } clip.SetCooldown(cooldownTime); ChannelGroup channelGroup; if (AudioManager.channelGroups.TryGetValue(chanGroup, out channelGroup) == false) { channelGroup = AudioManager.channelGroups["master"]; } FMOD.System soundSystem = AudioManager.SoundSystem; Channel channel; soundSystem.playSound(clip.Get(), channelGroup, true, out channel); if (tile != null) { VECTOR tilePos = GetVectorFrom(tile); channel.set3DAttributes(ref tilePos, ref zero, ref zero); } if (!freqRange.AreEqual(0f)) { float pitch = Mathf.Pow(1.059f, Random.Range(-freqRange, freqRange)); channel.setPitch(pitch); } if (!volRange.AreEqual(0f)) { float curVol; channel.getVolume(out curVol); float volChange = Random.Range(-volRange, 0f); channel.setVolume(curVol * DecibelsToVolume(volChange)); } channel.set3DLevel(SettingsKeyHolder.LocationalSound ? 0.75f : 0f); channel.setPaused(false); }