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
- Attack hitting an unguarded entity, which is played by calling
- 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 soundattack start.wav
that is the start of the attack followed by the delay stored inCombatAnimationDisplay.rockTravelTime
and then a sound of a rock breaking apart to indicate contact with another unguarded entityattack hit.wav
.attackBlock()
consist of theattack start.wav
sound that indicates the start of the attack followed by theCombatAnimationDisplay.rockTravelTime
delay and then the sound of a rock hitting a metal object to indicate contact with a guarded entityattack blocked.wav
. The design decision was made not to play theguard.wav
sound as having theattack start.wav
sound and theguard.wav
sound simultaneously was confusing for the userraiseGuard()
consist of theguard.wav
that indicates an entity has used guard when it isn't attacked.sleep()
consist of thesleep.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:
And the UML class diagram can be seen below:
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