Class SoundManager

java.lang.Object
za.co.wethinkcode.robots.rendering.gui.ui.SoundManager

public class SoundManager extends Object
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 Details

    • SoundManager

      public SoundManager()
  • Method Details

    • startAmbient

      public static void startAmbient()
      Start the default background music loop.
    • startAmbient

      public static void startAmbient(String filename)
      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

      public static void playSound(String filename)
      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 the look command.
    • playTurn

      public static void playTurn()
      Play the sound for the turn command.
    • playForward

      public static void playForward()
      Play the sound for the forward command.
    • playBack

      public static void playBack()
      Play the sound for the back command.
    • playFire

      public static void playFire()
      Play the sound for the fire command (hit).
    • playReload

      public static void playReload()
      Play the sound for the reload command.
    • playRepair

      public static void playRepair()
      Play the sound for the repair command.
    • playMine

      public static void playMine()
      Play the sound for the mine command.
    • playLaunch

      public static void playLaunch()
      Play the sound for launching a robot.
    • playState

      public static void playState()
      Play the sound for the state command.
    • playWorld

      public static void playWorld()
      Play the sound for the world command.
    • playOrientation

      public static void playOrientation()
      Play the sound for the orientation command.
    • playHelp

      public static void playHelp()
      Play the sound for the help command.
    • playSwap

      public static void playSwap()
      Play the sound for the swap command.
    • playQuit

      public static void playQuit()
      Play the sound for the quit command.
    • 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

      public static void playLaunchFor(RobotKind kind)
      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

      public static void playFireFor(RobotKind kind)
      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

      public static void playTurnFor(RobotKind kind)
      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

      public static void playMoveFor(RobotKind kind)
      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