Skip to content

Commit

Permalink
Merge branch 'main' into t3branch
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityayadav17 committed Oct 17, 2023
2 parents e011f17 + 32e7fb1 commit f926875
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 14 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added source/core/assets/sounds/towers/explosion.mp3
Binary file not shown.
55 changes: 44 additions & 11 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ public class ForestGameArea extends GameArea {
"sounds/mobBoss/patrickThunder.mp3",
"sounds/mobBoss/patrickHit.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",
"sounds/towers/ar15_single_shot_far.mp3",
"sounds/mobs/skeletonHit.mp3",
"sounds/mobs/coatAttack.mp3",
"sounds/mobs/archerArrow.mp3"

};
private static final String BACKGROUND_MUSIC = "sounds/background/Sci-Fi1.ogg";

Expand Down Expand Up @@ -244,6 +248,37 @@ private void stopWaveTimer() {
}
}

/**
* Cases to spawn a wave
*/
// private void spawnWave() {
// wave++;
// switch (wave) {
// case 1:
// case 2:
// spawnFireWorm();
// spawnDragonKnight();
//
// break;
// case 3:
// spawnSkeleton();
// spawnWizard();
// // mobBoss2 = spawnMobBoss2();
// break;
// case 4:
// spawnWaterQueen();
// spawnWaterSlime();
// // mobBoss2 = spawnMobBoss2();
//
// break;
// case 5:
// spawnDemonBoss();
// default:
// // Handle other wave scenarios if needed
// break;
// }
// }

/**
* Create the game area, including terrain, static entities (trees), dynamic entities (player)
*/
Expand All @@ -268,9 +303,10 @@ public void create() {
spawnScrap();
spawnGapScanners();
}

private void displayUI() {
Entity ui = new Entity();
// ui.addComponent(new GameAreaDisplay("Box Forest")); TODO: This should be the level name?
ui.addComponent(ServiceLocator.getGameEndService().getDisplay());
ui.addComponent(ServiceLocator.getCurrencyService().getDisplay());
spawnEntity(ui);
Expand Down Expand Up @@ -333,6 +369,9 @@ private void spawnTerrain() {
public void spawnMob(String entity, GridPoint2 randomPos, int health) {
Entity mob;
switch (entity) {
case "Xeno":
mob = NPCFactory.createXenoGrunt(health);
break;
case "SplittingWaterSlime":
mob = NPCFactory.createSplittingWaterSlime(health);
break;
Expand All @@ -357,6 +396,7 @@ public void spawnMob(String entity, GridPoint2 randomPos, int health) {
case "IceBoss":
mob = MobBossFactory.createIceBoss(health);
break;

case "Coat":
mob = NPCFactory.createCoat(health);
break;
Expand All @@ -369,15 +409,7 @@ public void spawnMob(String entity, GridPoint2 randomPos, int health) {
case "ArcaneArcher":
mob = NPCFactory.createDodgingArcaneArcher(health);
break;
case "SplittingRocky":
mob = NPCFactory.createSplittingRocky(health);
break;
case "Necromancer":
mob = NPCFactory.createNecromancer(health);
break;
case "DeflectFireWizard":
mob = NPCFactory.createDeflectFireWizard(health);
break;

case "PatrickBoss":
mob = MobBossFactory.createPatrickBoss(health);
break;
Expand All @@ -395,6 +427,7 @@ public void spawnMob(String entity, GridPoint2 randomPos, int health) {
spawnEntityAt(mob, randomPos, true, false);
}


private void loadAssets() {
logger.debug("Loading assets");
ResourceService resourceService = ServiceLocator.getResourceService();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.csse3200.game.components.tower;

import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.math.Vector2;
import com.csse3200.game.components.Component;
import com.csse3200.game.components.ProjectileEffects;
Expand All @@ -16,6 +17,11 @@
public class DroidAnimationController extends Component {
private AnimationRenderComponent animator;

private static final String FIRE_SINGLE_SFX = "sounds/towers/5.56_single_shot.mp3";

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

/**
* Creation call for a DroidAnimationController, fetches the animationRenderComponent that this controller will
* be attached to and registers all the event listeners required to trigger the animations and sounds.
Expand Down Expand Up @@ -66,6 +72,7 @@ void animateGoDown() {
*/
void animateAttackUp() {
animator.startAnimation("attackUp");
fireSingleSound.play();
}

/**
Expand All @@ -74,6 +81,7 @@ void animateAttackUp() {
*/
void animateAttackDown() {
animator.startAnimation("attackDown");
fireSingleSound.play();
}

/**
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
@@ -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;

/**
* This class listens to events relevant to DroidTower entity's state and plays the animation when one
Expand All @@ -10,6 +12,11 @@
public class FireworksTowerAnimationController extends Component {
private AnimationRenderComponent animator;

private static final String FIRE_SINGLE_SFX = "sounds/towers/5.56_single_shot.mp3";

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

/**
* Creation call for a DroidAnimationController, fetches the animationRenderComponent that this controller will
* be attached to and registers all the event listeners required to trigger the animations and sounds.
Expand All @@ -30,6 +37,7 @@ public void create() {
*/
void animateAttack() {
animator.startAnimation("Attack");
fireSingleSound.play();
}


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 to triggers phrases and executes the required animations.
Expand All @@ -19,7 +21,10 @@ public class PierceTowerAnimationController extends Component {
private static final String ALERT_ANIM = "Warning";

//further sounds can be added for the tower attacks/movement
private static final String FIRE_SINGLE_SFX = "sounds/towers/5.56_single_shot.mp3";

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
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 DroidTower entity's state and plays the animation when one
* of the events is triggered.
*/
public class RicochetTowerAnimationController extends Component {
private static final String FIRE_SINGLE_SFX = "sounds/towers/5.56_single_shot.mp3";

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

/**
Expand All @@ -30,6 +36,7 @@ public void create() {
*/
void animateAttack() {
animator.startAnimation("Attack");
fireSingleSound.play();
}


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/ar15_single_shot_far.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 DroidAnimationControllerTest {
private final String[] texture = {"images/towers/DroidTower.png"};
private final String[] atlas = {"images/towers/DroidTower.atlas"};

private static final String[] sounds = {
"sounds/towers/5.56_single_shot.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.createDroidTower(); // Replace with actual Droid Tower creation logic
Expand Down
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/ar15_single_shot_far.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
Loading

0 comments on commit f926875

Please sign in to comment.