DoopelPonger
|
Plays sound effects based on game events emitted through the EventManager. More...
Public Member Functions | |
void | Awake () |
void | SetMaxVolume (float volume) |
Master volume control for sound effects. More... | |
float | GetMaxVolume () |
Returns the master volume for sound effects. More... | |
Public Attributes | |
AudioMapping [] | audioMappings |
Plays sound effects based on game events emitted through the EventManager.
The AudioManager (maybe a better name would have been SoundEffectManager) takes an Inspector defined mapping of an EventManager.EventType to an AudioSelector. This basically means that if anything in the game emits the EventType, then the AudioManager will then tell the specified AudioSelector to play a sound effect. Another way to structure sound effects would have been to have a single "PlaySoundEffect" EventType and as a parameter you specify the effect to play. However, I did not implement it this way so that a single event could be fired to trigger multiple effects. For example, when the player death event is fired, there would not need to be a second event to be fired to play a death sound.
void AudioManager.Awake | ( | ) |
Converts the AudioMapping input array into a dictionary since Unity does not support serializing dictionaries. Also registers all AudioMapping events with the EventManager and sets the max volume to 1.
float AudioManager.GetMaxVolume | ( | ) |
Returns the master volume for sound effects.
void AudioManager.SetMaxVolume | ( | float | volume | ) |
Master volume control for sound effects.
volume | New volume for sound effects. Clamped between 0 and 1 |
AudioMapping [] AudioManager.audioMappings |
Describes the relationship between events and the sound effects to play.