Skip to content

Commit

Permalink
condensed Pause classes into one, updated button layout and fadeout
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Oct 14, 2023
1 parent ad3f8c3 commit 58e8378
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* on the screen, handles their behaviour and sound effects.
*/
public class MainGameDisplay extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(MainGamePauseDisplay.class);
private static final Logger logger = LoggerFactory.getLogger(MainGameDisplay.class);
private static final float Z_INDEX = 2f;
private final Table towerTable = new Table();
private final Table buttonTable = new Table();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
Expand All @@ -26,7 +28,7 @@
* Displays a button to represent the remaining mobs left in the current wave and a button to skip to the next wave.
*/
public class UIElementsDisplay extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(MainGameExitDisplay.class);
private static final Logger logger = LoggerFactory.getLogger(UIElementsDisplay.class);
private static final float Z_INDEX = 2f;
private final Table buttonTable = new Table();
private TextButton remainingMobsButton;
Expand Down Expand Up @@ -101,7 +103,8 @@ public void updateTimerButton() {
}
timerButton.setText("Next wave in: " + finalTime);
} else {
buttonTable.removeActor(timerButton);
timerButton.addAction(new SequenceAction(Actions.fadeOut(1f), Actions.removeActor()));
// buttonTable.removeActor(timerButton);
stage.act();
stage.draw();
}
Expand Down
24 changes: 10 additions & 14 deletions source/core/src/main/com/csse3200/game/screens/MainGameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.csse3200.game.areas.ForestGameArea;
import com.csse3200.game.components.gamearea.PerformanceDisplay;
import com.csse3200.game.components.maingame.MainGameActions;
import com.csse3200.game.components.maingame.MainGameLoseDisplay;
import com.csse3200.game.components.maingame.MainGameDisplay;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.EntityService;
Expand Down Expand Up @@ -87,21 +86,19 @@ public class MainGameScreen extends ScreenAdapter {
private final PhysicsEngine physicsEngine;

private InputComponent upgradedInputHandler;
private final Stage stage;
static int screenWidth = Gdx.graphics.getWidth();
static int screenHeight = Gdx.graphics.getHeight();
private Entity ui;
private int random = 0;
public static int viewportWidth = screenWidth;
public static int viewportHeight= screenHeight;
int selectedLevel = GameLevelData.getSelectedLevel();

private OrthographicCamera camera;
private SpriteBatch batch;
private final OrthographicCamera camera;
private final SpriteBatch batch;

private Texture backgroundTexture;
private Music music;
private Array<String> ambientSounds = new Array<>(false, 5, String.class);
private final Array<String> ambientSounds = new Array<>(false, 5, String.class);

public MainGameScreen(GdxGame game) {
this.game = game;
Expand All @@ -111,7 +108,7 @@ public MainGameScreen(GdxGame game) {

batch = new SpriteBatch();

stage = new Stage(new ScreenViewport());
Stage stage = new Stage(new ScreenViewport());


logger.debug("Initialising main game screen services");
Expand Down Expand Up @@ -169,22 +166,22 @@ public Texture getBackgroundTexture() {
Texture background;
switch (selectedLevel) {
// Desert
case 1: // Ice
case 1 -> { // Ice
background = ServiceLocator.getResourceService().getAsset(ICE_BACKDROP, Texture.class);
music = ServiceLocator.getResourceService().getAsset(ICE_BGM, Music.class);
ambientSounds.addAll(iceSounds);
break;
case 2: // Lava
}
case 2 -> { // Lava
background = ServiceLocator.getResourceService().getAsset(LAVA_BACKDROP, Texture.class);
music = ServiceLocator.getResourceService().getAsset(LAVA_BGM, Music.class);
ambientSounds.addAll(lavaSounds);
break;
default:
}
default -> {
// Use a default background for other levels or planets
background = ServiceLocator.getResourceService().getAsset(DESERT_BACKDROP, Texture.class);
music = ServiceLocator.getResourceService().getAsset(DESERT_BGM, Music.class);
ambientSounds.addAll(desertSounds);
break;
}
}
return background;
}
Expand Down Expand Up @@ -304,7 +301,6 @@ private void createUI() {
.addComponent(new PerformanceDisplay())
.addComponent(new MainGameActions(this.game))
.addComponent(ServiceLocator.getWaveService().getDisplay())
.addComponent(new MainGameLoseDisplay())
//.addComponent(new MainGameWinDisplay()) <- needs to be uncommented when team 3 have implemented the ui
.addComponent(new MainGameDisplay(this.game))
.addComponent(new Terminal())
Expand Down

0 comments on commit 58e8378

Please sign in to comment.