DoopelPonger
Public Member Functions | Public Attributes | List of all members
AudioManager Class Reference

Plays sound effects based on game events emitted through the EventManager. More...

Inheritance diagram for AudioManager:
Inheritance graph
[legend]
Collaboration diagram for AudioManager:
Collaboration graph
[legend]

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
 

Detailed Description

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.

Member Function Documentation

◆ Awake()

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.

◆ GetMaxVolume()

float AudioManager.GetMaxVolume ( )

Returns the master volume for sound effects.

Returns
the current volume for sound effects. Will be between 0 and 1

◆ SetMaxVolume()

void AudioManager.SetMaxVolume ( float  volume)

Master volume control for sound effects.

Parameters
volumeNew volume for sound effects. Clamped between 0 and 1

Member Data Documentation

◆ audioMappings

AudioMapping [] AudioManager.audioMappings

Describes the relationship between events and the sound effects to play.


The documentation for this class was generated from the following file: