Skip to content

Commit

Permalink
added differenet sounds and improved the existing tests for the tower…
Browse files Browse the repository at this point in the history
…s to include in the sounds
  • Loading branch information
karthikeya-v committed Oct 16, 2023
1 parent 06bdf52 commit f403283
Show file tree
Hide file tree
Showing 15 changed files with 5,142 additions and 4 deletions.
1,696 changes: 1,696 additions & 0 deletions source/core/assets/replay_pid32365.log

Large diffs are not rendered by default.

1,696 changes: 1,696 additions & 0 deletions source/core/assets/replay_pid33005.log

Large diffs are not rendered by default.

1,697 changes: 1,697 additions & 0 deletions source/core/assets/replay_pid63318.log

Large diffs are not rendered by default.

Binary file not shown.
Binary file added source/core/assets/sounds/towers/explosion.mp3
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ public class ForestGameArea extends GameArea {
"sounds/mobBoss/patrickCast.mp3",
"sounds/mobBoss/patrickThunder.mp3",
"sounds/mobBoss/patrickHit.mp3",
"sounds/mobBoss/spawnDemonSlime.mp3"
"sounds/mobBoss/spawnDemonSlime.mp3",
"sounds/towers/Desert-Eagle-Far-Single-Gunshot.mp3",
"sounds/towers/5.56_single_shot.mp3",
"sounds/towers/explosion.mp3",
"sounds/towers/eco_tower_ping.mp3"
};
private static final String backgroundMusic = "sounds/background/Sci-Fi1.ogg";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.csse3200.game.components.tower;

import com.badlogic.gdx.audio.Sound;
import com.csse3200.game.components.Component;
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.services.ServiceLocator;

/**
* Listens for events relevant to a weapon tower state.
Expand All @@ -15,6 +17,11 @@ public class EconTowerAnimationController extends Component {
private static final String ECO_MOVE = "move1";
private static final String ECO_IDLE = "idle";

private static final String PING = "sounds/towers/eco_tower_ping.mp3";

private final Sound ping = ServiceLocator.getResourceService().getAsset(
PING, Sound.class);

AnimationRenderComponent animator;

/**
Expand All @@ -36,7 +43,8 @@ void animateIdle() {
animator.startAnimation(ECO_IDLE);
}

void animateMove() { animator.startAnimation(ECO_MOVE); }
void animateMove() { animator.startAnimation(ECO_MOVE);
ping.play();}


}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class FireTowerAnimationController extends Component{
private static final String DEATH_ANIM = "death";
//here we can add the sounds for the implemented animations

private static final String FIRE_SINGLE_SFX = "sounds/towers/Desert-Eagle-Far-Single-Gunshot.mp3";

private final Sound fireSingleSound = ServiceLocator.getResourceService().getAsset(
FIRE_SINGLE_SFX, Sound.class);

AnimationRenderComponent animator;

/**
Expand Down Expand Up @@ -57,6 +62,7 @@ void animatePrepAttack() {
*/
void animateAttack() {
animator.startAnimation(ATTACK_ANIM);
fireSingleSound.play();
}

void animateDeath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class StunTowerAnimationController extends Component {

//further sounds can be added for the tower attacks/movement

private static final String FIRE_SINGLE_SFX = "sounds/towers/Desert-Eagle-Far-Single-Gunshot.mp3";

private final Sound fireSingleSound = ServiceLocator.getResourceService().getAsset(
FIRE_SINGLE_SFX, Sound.class);

AnimationRenderComponent animator;

/**
Expand Down Expand Up @@ -47,6 +52,7 @@ void animateIdle() {
*/
void animateAttack() {
animator.startAnimation(ATTACK_ANIM);
fireSingleSound.play();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.csse3200.game.components.tower;

import com.badlogic.gdx.audio.Sound;
import com.csse3200.game.components.Component;
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.services.ServiceLocator;

/**
* This class listens to events relevant to TNTTower entity's state and plays the animation when one
* of the events is triggered.
*/
public class TNTAnimationController extends Component {
private AnimationRenderComponent animator;
private static final String EXPLOSION = "sounds/towers/explosion.mp3";

private final Sound explosion = ServiceLocator.getResourceService().getAsset(
EXPLOSION, Sound.class);

/**
* Creation call for a TNTAnimationController, fetches the animationRenderComponent that this controller will
Expand Down Expand Up @@ -43,7 +49,7 @@ void animateDig() {
* This method should be invoked when the entity enters the explosion state.
*/
void animateExplode() { animator.startAnimation("explode");

explosion.play();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public class FireTowerAnimationControllerTest {
private final String[] texture = {"images/towers/fire_tower_atlas.png"};
private final String[] atlas = {"images/towers/fire_tower_atlas.atlas"};

private static final String[] sounds = {
"sounds/towers/Desert-Eagle-Far-Single-Gunshot.mp3"
};

@BeforeEach
public void setUp() {
ServiceLocator.registerPhysicsService(new PhysicsService());
Expand All @@ -33,6 +37,7 @@ public void setUp() {
ServiceLocator.registerResourceService(resourceService);
resourceService.loadTextures(texture);
resourceService.loadTextureAtlases(atlas);
resourceService.loadSounds(sounds);
resourceService.loadAll();

mockEntity = TowerFactory.createFireTower(); // Replace with actual Droid Tower creation logic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class StunTowerAnimationControllerTest {
private Entity mockEntity;
private final String[] texture = {"images/towers/stun_tower.png"};
private final String[] atlas = {"images/towers/stun_tower.atlas"};
private static final String[] sounds = {
"sounds/towers/Desert-Eagle-Far-Single-Gunshot.mp3"
};

@BeforeEach
public void setUp() {
Expand All @@ -33,6 +36,7 @@ public void setUp() {
ServiceLocator.registerResourceService(resourceService);
resourceService.loadTextures(texture);
resourceService.loadTextureAtlases(atlas);
resourceService.loadSounds(sounds);
resourceService.loadAll();

mockEntity = TowerFactory.createStunTower(); // Replace with actual Droid Tower creation logic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class TNTAnimationControllerTest {
private final String[] texture = {"images/towers/TNTTower.png"};
private final String[] atlas = {"images/towers/TNTTower.atlas"};

private static final String[] sounds = {
"sounds/towers/explosion.mp3"
};


@BeforeEach
public void setUp() {
Expand All @@ -37,6 +41,7 @@ public void setUp() {
ServiceLocator.registerResourceService(resourceService);
resourceService.loadTextures(texture);
resourceService.loadTextureAtlases(atlas);
resourceService.loadSounds(sounds);
resourceService.loadAll();

mockEntity = TowerFactory.createTNTTower();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public class TowerFactoryTest {
private static final String[] sounds = {
"sounds/towers/gun_shot_trimmed.mp3",
"sounds/towers/deploy.mp3",
"sounds/towers/stow.mp3"
"sounds/towers/stow.mp3",
"sounds/towers/Desert-Eagle-Far-Single-Gunshot.mp3",
"sounds/towers/5.56_single_shot.mp3",
"sounds/towers/explosion.mp3",
"sounds/towers/eco_tower_ping.mp3"

};

@BeforeEach
Expand Down

0 comments on commit f403283

Please sign in to comment.