CombatMoveAudio - UQcsse3200/2024-studio-2 GitHub Wiki

Overview

A large part of understanding what is occurring during combat is having audio that plays depending on the combination of player and enemy action as well as their stats. This class has a large dependency on the CombatAnimationDisplay class as the sounds played need to reflect the animations that are occurring on screen for combat. This page will cover audio that is currently in combat and how it is implemented as well as how to add in additional audio.

Types of audio

  • Attack consist of 2 types of audio:
    • Attack hitting an unguarded entity, which is played by calling attackHit() method
    • Attack hitting an entity using guard, which is played by calling attackBlock() method
  • Entity using sleep played via sleep() method
  • An Entity that is not being attacked using guard and is played by calling raiseGuard() method

Moves in Combat and Audio Combinations

Player Move Enemy Move Audio played
Attack Attack attackHit() followed by a delay from CombatAnimationDisplay.bothAttackAnimationDelay and then attackHit()
Attack Guard attackBlock()
Attack Sleep attackHit() and sleep()
Guard Guard raiseGuard() followed by a delay from CombatAnimationDisplay.rockTravelTime and then raiseGuard()
Sleep Sleep sleep() followed by a delay from CombatAnimationDisplay.rockTravelTime and then sleep()
Guard Sleep raiseGuard() followed by a delay from CombatAnimationDisplay.rockTravelTime and then sleep()

The last 3 rows are speed independent combination (The speed stats of the player and the oponent have no affect on how these move combination works) so to make animations and audio more consist the player entity audio and animation are played first followed by a short delay (CombatAnimationDisplay.rockTravelTime) and then the enemies animation and audio. Having a short delay helps the user understand what is happening as user testing showed that it was quite confusing when animations and audio were occuring simultaneously (E.g. playing the raiseGuard() method and sleep() method at the same time.

Sound Details

Sounds were played using methods from AudioManager. The methods below are called from the sound controller method playCombatSound (See below for more detail) that determines which of the following sounds to call:

  • attackHit() consist of a sound attack start.wav that is the start of the attack followed by the delay stored in CombatAnimationDisplay.rockTravelTime and then a sound of a rock breaking apart to indicate contact with another unguarded entity attack hit.wav.
  • attackBlock() consist of the attack start.wav sound that indicates the start of the attack followed by the CombatAnimationDisplay.rockTravelTime delay and then the sound of a rock hitting a metal object to indicate contact with a guarded entity attack blocked.wav. The design decision was made not to play the guard.wav sound as having the attack start.wav sound and the guard.wav sound simultaneously was confusing for the user
  • raiseGuard() consist of the guard.wav that indicates an entity has used guard when it isn't attacked.
  • sleep() consist of the sleep.wav that indicates an entity is sleeping.

Sounds Used

Audio warning recommend turning down volume prior to playing

  • attack start.wav: Swoosh sound of a rock flying through the air to indicate the start of an attack.
  • attack blocked.wav: Sound of a rock hitting a metal object to indicate the attack hitting an entity using guard.
  • attack hit.wav: Sound of a rock breaking apart to indicate the attack hitting an entity not using guard.
  • guard.wav: Sound metal clanging to indicate an entity not being attacked is using guard.
  • sleep.wav: Sound of snoring to indicate an entity is using sleep.

Sound Controller

This class is instantiated in CombatManager and the method playCombatSound is called in executeMoveCombination in order to play sounds. playCombatSound(CombatManager.Action playerMove, CombatManager.Action enemyMove) takes in an Enum that represents the move the player chose and take in an Enum that represents the move that the enemy chose and plays the corresponding audio given the move combination. The flow of code can be seen in the sequence diagram below: tLJBJiCm4BpxAwoU4YcqTmwe0Qu52Se7REDLOiMnAtiTrB_7Zw0YH7W8wA4-hEruFEFCE5ax0aj-K0mQCfO_ERICnSelhlYD6NP06pDYxOKq_9Bl5HpoqqVZjIZY76r4L1mr3eSuB1a3HVmE9NM128YWwHtZeRrd329fi04DRS1cXSozSB5pgoRjMJc5k5y-mxWeUJZfBAxrO4N6pKbkvP And the UML class diagram can be seen below: TL5BQiCm4Dtx55ewDEq1l8hJGhifbCGNc4eJMrYV88q28UJkbIpP9YtLGg2Pzvatsda2Hq6hgk8Al6UlLdy3VTeBja58osuLY-VfhE2QMqSRZAZJ6rs2DJC53FJeNbfEqfejGuFw-ZzWC-a-Ev0UtmCuKPSA404VFoGz5lRAyd4kUOLuZe_xhwcpGvaPJT0icwt0ATGZRigMKvsamY-WeM

Adding Sounds and Moves

Once a new move has been added (adding to as an Acton enum in CombatManager, adding buttons for it etc,.) the logic for what audio to play and when to play it needs to be added in to the sound controller method playCombatSound