Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post sprint bug fixes for showcasing #306

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void update() {
if ((mob.getComponent(CombatStatsComponent.class).getHealth() <= 0 && !deathFlag)) {
// decrement engineer count
// ! tests failing because of textbox
ServiceLocator.getGameEndService().updateEngineerCount();
// ServiceLocator.getGameEndService().updateEngineerCount();
changeState(State.DEATH);
animate();
movementTask.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public WaveClass getWave(int index) {
public void spawnWave() {
if (gameTime.getTime() >= startTime + spawnDelay * 1000) {
do {
currentRandom = MathUtils.random(0, ServiceLocator.getMapService().getHeight());
currentRandom = MathUtils.random(0, ServiceLocator.getMapService().getHeight() - 1);
} while (currentRandom == previousRandom);
ServiceLocator.getWaveService().setNextLane(currentRandom);
GridPoint2 randomPos = new GridPoint2(19, currentRandom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void render(float delta) {
logger.info("Main game level completed detected, go to win screen");
} else {
// For other levels, go to the "NextLevelScreen"
game.setScreen(new NextLevelScreen(game, selectedLevel));
game.setScreen(GdxGame.ScreenType.Next_Screen);
logger.info("game level completed detected, go to NextLevelScreen");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class LevelSelectScreen extends ScreenAdapter {
float timeCounter = 0;

private static final String BG_PATH = "planets/background.png";
String[] bgm = {
"sounds/background/pre_game/Sci-Fi8Loop_story.ogg"
};

// Description Box
private final Label descriptionBox;
Expand Down Expand Up @@ -115,9 +118,6 @@ public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, f
stage.addActor(descriptionTable);

ServiceLocator.registerResourceService(new ResourceService());
String[] bgm = {
"sounds/background/pre_game/Sci-Fi8Loop_story.ogg"
};
ServiceLocator.getResourceService().loadMusic(bgm);
ServiceLocator.getResourceService().loadAll();
music = ServiceLocator.getResourceService().getAsset(bgm[0], Music.class);
Expand Down Expand Up @@ -237,7 +237,8 @@ private void spawnPlanetBorders() {
private void loadPlanetLevel(int[] planet) {
logger.info("Loading level {}", planet[4]);
GameLevelData.setSelectedLevel(planet[4]);
game.setScreen(new TurretSelectionScreen(game));
music.stop();
game.setScreen(GdxGame.ScreenType.TURRET_SELECTION);
}

/**
Expand Down Expand Up @@ -365,6 +366,7 @@ public void resize(int width, int height) {
*/
@Override
public void dispose() {
ServiceLocator.getResourceService().unloadAssets(bgm);
stage.dispose();
batch.dispose();
music.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public void render(float delta) {
private void next() {
currentIndex++;
if (currentIndex >= images.length) {
music.stop();
game.setScreen(new LevelSelectScreen(game, -1));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ public TurretSelectionScreen(GdxGame game) {
@Override
public void clicked(InputEvent event, float x, float y) {
click.play(0.4f);
music.stop();
// Handle the "back" action, e.g., return to the previous screen
game.setScreen(GdxGame.ScreenType.LEVEL_SELECT); // Replace PREVIOUS_SCREEN with the appropriate screen type
game.setScreen(GdxGame.ScreenType.LEVEL_SELECT); // Replace PREVIOU
// S_SCREEN with the appropriate screen type
}
});

Expand All @@ -120,6 +122,7 @@ public void clicked(InputEvent event, float x, float y) {
for (TowerType t : selectedTurrets) {
towers.add(t);
}
music.stop();
ServiceLocator.setTowerTypes(towers);;
game.setScreen(GdxGame.ScreenType.LOAD_SCREEN);
}
Expand Down Expand Up @@ -234,7 +237,7 @@ public void clicked(InputEvent event, float x, float y) {
stage.addActor(table);
table.setFillParent(true);
Gdx.input.setInputProcessor(stage);

logger.info("Playing music");
music.setVolume(0.4f);
music.setLooping(true);
music.play();
Expand Down Expand Up @@ -349,6 +352,7 @@ public void loadSounds() {

public void unloadSounds() {
ServiceLocator.getResourceService().unloadAssets(sounds);
ServiceLocator.getResourceService().unloadAssets(bgm);
}
/**
* Disposes of the stage
Expand Down
Loading