Class diagram overview
The following class diagram (Figure 1) represents the classes involved with implementing sound, music, and cutscene support:
As a note, the classes shaded in as grey are classes we have discussed in the previous chapters, so we will not be discussing them in depth.
The AudioManager
class implements the AudioObserver
interface and manages the various commands, such as loading and playing music and sounds. The corresponding AudioObserver
objects are owned by the GameScreen
, PlayerHUD
, and Map
classes, which in turn send notification events when music or sound files are involved.
The Map
class implements the AudioSubject
interface so that all the derived classes, such as TownMap
, TopWorldMap
, and CastleDoomMap
, have access to the music and sound resources. PlayerHUD
implements the AudioSubject
interface as well so that the appropriate sounds can be played, for instance, when the player is hit and loses health or the player purchases items from the store. Finally...