Class SoundManager
java.lang.Object
za.co.wethinkcode.robots.rendering.gui.ui.SoundManager
Central audio controller for the Robot World GUI.
Manages background music, UI sound effects, command sounds, error sounds,
and per-robot variant sounds. All sounds are loaded from /sounds/ on
the classpath. Missing sound files are silently ignored so the GUI never
crashes due to audio issues.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleanstatic voidplayBack()Play the sound for thebackcommand.static voidPlay the blocked-move error sound.static voidPlay the UI button-click effect.static voidPlay the robot death sound.static voidPlay the dialog close effect.static voidPlay the dialog open effect.static voidplayFire()Play the sound for thefirecommand (hit).static voidPlay the fire error sound (e.g., no ammo).static voidplayFireFor(RobotKind kind) Play a fire sound specific to the robot kind.static voidPlay the sound for theforwardcommand.static voidplayHelp()Play the sound for thehelpcommand.static voidPlay the sound for launching a robot.static voidplayLaunchFor(RobotKind kind) Play a launch sound specific to the robot kind.static voidplayLook()Play the sound for thelookcommand.static voidplayMine()Play the sound for theminecommand.static voidplayMoveFor(RobotKind kind) Play a move sound specific to the robot kind.static voidPlay the sound for theorientationcommand.static voidPlay the pit fall sound.static voidplayQuit()Play the sound for thequitcommand.static voidPlay the sound for thereloadcommand.static voidPlay the reload error sound.static voidPlay the sound for therepaircommand.static voidPlay a sound effect from the /sounds/ directory.static voidPlay the sound for thestatecommand.static voidplaySwap()Play the sound for theswapcommand.static voidplayTurn()Play the sound for theturncommand.static voidplayTurnFor(RobotKind kind) Play a turn sound specific to the robot kind.static voidPlay the sound for theworldcommand.static voidsetMusicEnabled(boolean enabled) Enable or disable background music.static voidsetMusicVolume(double volume) Set the background music volume.static voidsetSoundEnabled(boolean enabled) Enable or disable sound effects.static voidStart the default background music loop.static voidstartAmbient(String filename) Start a specific background music file.static voidStop the background music.
-
Constructor Details
-
SoundManager
public SoundManager()
-
-
Method Details
-
startAmbient
public static void startAmbient()Start the default background music loop. -
startAmbient
Start a specific background music file. -
stopBackgroundSong
public static void stopBackgroundSong()Stop the background music. -
setMusicVolume
public static void setMusicVolume(double volume) Set the background music volume.- Parameters:
volume- 0.0 (silent) to 1.0 (full)
-
playSound
Play a sound effect from the /sounds/ directory.- Parameters:
filename- the sound file (relative to /sounds/)
-
playButton
public static void playButton()Play the UI button-click effect. -
playDialogOpen
public static void playDialogOpen()Play the dialog open effect. -
playDialogClose
public static void playDialogClose()Play the dialog close effect. -
playLook
public static void playLook()Play the sound for thelookcommand. -
playTurn
public static void playTurn()Play the sound for theturncommand. -
playForward
public static void playForward()Play the sound for theforwardcommand. -
playBack
public static void playBack()Play the sound for thebackcommand. -
playFire
public static void playFire()Play the sound for thefirecommand (hit). -
playReload
public static void playReload()Play the sound for thereloadcommand. -
playRepair
public static void playRepair()Play the sound for therepaircommand. -
playMine
public static void playMine()Play the sound for theminecommand. -
playLaunch
public static void playLaunch()Play the sound for launching a robot. -
playState
public static void playState()Play the sound for thestatecommand. -
playWorld
public static void playWorld()Play the sound for theworldcommand. -
playOrientation
public static void playOrientation()Play the sound for theorientationcommand. -
playHelp
public static void playHelp()Play the sound for thehelpcommand. -
playSwap
public static void playSwap()Play the sound for theswapcommand. -
playQuit
public static void playQuit()Play the sound for thequitcommand. -
playBlocked
public static void playBlocked()Play the blocked-move error sound. -
playDeath
public static void playDeath()Play the robot death sound. -
playFireError
public static void playFireError()Play the fire error sound (e.g., no ammo). -
playReloadError
public static void playReloadError()Play the reload error sound. -
playPitFall
public static void playPitFall()Play the pit fall sound. -
playLaunchFor
Play a launch sound specific to the robot kind. Falls back to the default launch sound if the variant file doesn't exist.- Parameters:
kind- the robot kind
-
playFireFor
Play a fire sound specific to the robot kind. Falls back to the default fire sound if the variant file doesn't exist.- Parameters:
kind- the robot kind
-
playTurnFor
Play a turn sound specific to the robot kind. Falls back to the default turn sound if the variant file doesn't exist.- Parameters:
kind- the robot kind
-
playMoveFor
Play a move sound specific to the robot kind. Falls back to the default forward sound if the variant file doesn't exist.- Parameters:
kind- the robot kind
-
setSoundEnabled
public static void setSoundEnabled(boolean enabled) Enable or disable sound effects.- Parameters:
enabled- true to enable, false to mute
-
setMusicEnabled
public static void setMusicEnabled(boolean enabled) Enable or disable background music.- Parameters:
enabled- true to enable, false to mute
-
isSoundEnabled
public static boolean isSoundEnabled()- Returns:
- true if sound effects are enabled
-
isMusicEnabled
public static boolean isMusicEnabled()- Returns:
- true if background music is enabled
-