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

Team 2 UI - further improvements #271

Merged
merged 49 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3add298
fixed some code smells
Mohamad11Dab Oct 15, 2023
26995f3
fixed merge conflict
Mohamad11Dab Oct 15, 2023
1e76226
code smell fixes
The-AhmadAA Oct 15, 2023
ba0b4c2
Merge pull request #264 from UQcsse3200/Mohamad_Juice
The-AhmadAA Oct 15, 2023
c2ab57b
code smell fixes and updated levelSelect font
The-AhmadAA Oct 15, 2023
be6419c
Added A progress bar that keeps track of the level's progress
Mohamad11Dab Oct 15, 2023
a4676f7
Merge branch 'main' into Mohamad_Juice
Mohamad11Dab Oct 15, 2023
b69b1f2
initial implementation of new build menu
The-AhmadAA Oct 15, 2023
7f9c8c3
fixed merge conflicts
Mohamad11Dab Oct 15, 2023
fade9b8
removed resize of tower buttons
The-AhmadAA Oct 15, 2023
6f0c14b
Merge pull request #267 from UQcsse3200/Mohamad_Juice
The-AhmadAA Oct 15, 2023
04b86aa
mixed ferge conflicts
The-AhmadAA Oct 15, 2023
2c00bc9
Merge pull request #268 from UQcsse3200/team-2-ahmad
Mohamad11Dab Oct 15, 2023
31ca8f4
cleanup of code, added button updating for shortcut keys
The-AhmadAA Oct 15, 2023
126d427
removed unused arg to toggleTower
The-AhmadAA Oct 15, 2023
3406eab
code smell cleanup
The-AhmadAA Oct 15, 2023
e2cb2dd
Implemented functionality to pause the wave timer when the pause menu…
AlasdairS4698737 Oct 16, 2023
180c99d
updated engineer warning threshold, pause menu shortcut key
The-AhmadAA Oct 16, 2023
5b541ce
Updated pause menu tests to work with the new services invoked by the…
AlasdairS4698737 Oct 16, 2023
6813fba
added pause status, getter and setter in TimeSource
The-AhmadAA Oct 16, 2023
d003a1e
Merge branch 'team-2-ui' into team-2-ui-Alasdair
AlasdairS4698737 Oct 16, 2023
ad37fdb
Merge branch 'main' into Mohamad_Juice
Mohamad11Dab Oct 16, 2023
7e0b62b
Update WaveService.java
AlasdairS4698737 Oct 16, 2023
74ae017
Update MainGameDisplay.java
The-AhmadAA Oct 16, 2023
f757a9d
Merge pull request #269 from UQcsse3200/team-2-ahmad
The-AhmadAA Oct 16, 2023
c489bb1
Added sliding animations for pause button, timer button, mob button a…
shiv-0831 Oct 16, 2023
e3c9c33
Merge pull request #270 from UQcsse3200/team-2-ui-Alasdair
The-AhmadAA Oct 16, 2023
b001b87
resolved merge conflicts
shiv-0831 Oct 16, 2023
69e2558
code smell fixes
The-AhmadAA Oct 16, 2023
8950f1e
tweaking UI element positions
The-AhmadAA Oct 16, 2023
8df2f1f
Merge branch 'main' into team-2-ui
The-AhmadAA Oct 16, 2023
afeb827
disabling progress bar until positioned and working
The-AhmadAA Oct 16, 2023
9b11375
Merge branch 'team-2-ahmad' of github.com:UQcsse3200/2023-studio-3 in…
The-AhmadAA Oct 16, 2023
3e2eb4d
added level name display'
The-AhmadAA Oct 16, 2023
7b7af9e
fixed progress bar positioning
The-AhmadAA Oct 16, 2023
845e5f8
Merge pull request #274 from UQcsse3200/team-2-ahmad
Mohamad11Dab Oct 16, 2023
7bfa5fb
fixed pause menu closing issue
The-AhmadAA Oct 16, 2023
6f52147
Merge pull request #275 from UQcsse3200/team-2-ahmad
The-AhmadAA Oct 16, 2023
8636502
Merge branch 'team-2-ui' into Mohamad_Juice
Mohamad11Dab Oct 16, 2023
3e5c6ff
Finalised the animations for tower select buttons
shiv-0831 Oct 16, 2023
8badc4a
merging the latest commits
shiv-0831 Oct 16, 2023
f54bf8e
fixed pauseMenu bug
The-AhmadAA Oct 16, 2023
49caee2
Merge branch 'team-2-ui' of github.com:UQcsse3200/2023-studio-3 into …
The-AhmadAA Oct 16, 2023
dac4854
Merge branch 'main' into team-2-ui
The-AhmadAA Oct 16, 2023
f7e239f
Integrated Mob Count with Level Progress Bar
Mohamad11Dab Oct 16, 2023
d22f925
Merge branch 'team-2-ui' into Mohamad_Juice
Mohamad11Dab Oct 16, 2023
e8f9d2c
Merge pull request #276 from UQcsse3200/Mohamad_Juice
The-AhmadAA Oct 16, 2023
d620802
remove setDebug
The-AhmadAA Oct 16, 2023
781a328
Merge branch 'team-2-ui' of github.com:UQcsse3200/2023-studio-3 into …
The-AhmadAA Oct 16, 2023
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
Binary file added source/core/assets/images/skeleton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/core/assets/images/skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
191 changes: 191 additions & 0 deletions source/core/assets/images/ui/buttons/determination_mono_22.fnt

Large diffs are not rendered by default.

203 changes: 105 additions & 98 deletions source/core/assets/images/ui/buttons/glass.atlas

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion source/core/assets/images/ui/buttons/glass.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ com.badlogic.gdx.graphics.g2d.BitmapFont: {
markupEnabled: false
flip: false
}
determination_mono_22: {
file: determination_mono_22.fnt
scaledSize: -1
markupEnabled: false
flip: false
}
determination_mono_32: {
file: determination_mono_32.fnt
scaledSize: -1
Expand Down Expand Up @@ -402,7 +408,7 @@ com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
fontColor: White
}
small: {
font: determination_mono_18_bold
font: determination_mono_22
fontColor: White
}
}
Expand Down
Binary file modified source/core/assets/images/ui/buttons/glass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ public class ForestGameArea extends GameArea {

/**
* Initialise this ForestGameArea to use the provided TerrainFactory.
*
* @requires terrainFactory != null
* @requires terrainFactory != null
*/
public ForestGameArea() {
super();
Expand Down Expand Up @@ -292,7 +291,6 @@ public void create() {

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 @@ -439,9 +437,6 @@ private void spawnProjectile(Vector2 position, short targetLayer, int space, int
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* shows the 'ground' in the game. Enabling/disabling this component will show/hide the terrain.
*/
public class TerrainComponent extends RenderComponent {
private static final Logger logger = LoggerFactory.getLogger(TerrainComponent.class);
private static final int TERRAIN_LAYER = 0;

private final TiledMap tiledMap;
Expand All @@ -33,7 +32,6 @@ public class TerrainComponent extends RenderComponent {
private final TerrainOrientation orientation;
private final float tileSize;
private TiledMapTileLayer.Cell lastHoveredCell = null;
private TiledMapTile originalTile = null;
private TextureRegion originalRegion = null;


Expand Down Expand Up @@ -107,41 +105,6 @@ public int getLayer() {
return TERRAIN_LAYER;
}

// TODO : This is just a visual effect that we might not need in the end but just keeping it here for now
public void colorTile(final int x, final int y) {
final TiledMapTileLayer tileLayer = (TiledMapTileLayer) tiledMap.getLayers().get(0);
final TiledMapTile originalTile = tileLayer.getCell(x, y).getTile();

ResourceService resourceService = ServiceLocator.getResourceService();

// Load all the tiles into an array
final TerrainTile[] terrainTiles = new TerrainTile[7];
for (int i = 0; i < 7; i++) {
Texture texture = resourceService.getAsset("images/GrassTile/grass_tile_" + (i + 1) + ".png", Texture.class);
terrainTiles[i] = new TerrainTile(new TextureRegion(texture));
}

final float interval = 0.2f; // Switch every 0.2 seconds
final float duration = 1.4f; // 7 images * 0.2 seconds each

Timer.schedule(new Timer.Task() {
float timeElapsed = 0.0f;

@Override
public void run() {
timeElapsed += interval;

if (timeElapsed >= duration) {
tileLayer.getCell(x, y).setTile(originalTile); // Reset to original tile after the total duration
this.cancel(); // End the timer task
} else {
int index = (int) (timeElapsed / interval);
tileLayer.getCell(x, y).setTile(terrainTiles[index]);
}
}
}, 0, interval, (int) (duration / interval) - 1); // Scheduling the task
}

/**
* Highlights the tile under the mouse cursor by changing its texture region.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.csse3200.game.areas.terrain;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile;
import com.badlogic.gdx.math.GridPoint2;
import com.csse3200.game.components.CameraComponent;
import com.csse3200.game.services.ResourceService;
Expand Down Expand Up @@ -52,14 +50,12 @@ public TerrainComponent createTerrain(TerrainType terrainType) {
ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.loadTextures(new String[]{"images/terrain_use.png"});
resourceService.loadAll();
switch (terrainType) {
case ALL_DEMO:
TextureRegion orthogonal =
new TextureRegion(resourceService.getAsset("images/terrain_use.png", Texture.class));
return createTerrain(1f, orthogonal);
default:
return null;
if (terrainType == TerrainType.ALL_DEMO) {
TextureRegion orthogonal =
new TextureRegion(resourceService.getAsset("images/terrain_use.png", Texture.class));
return createTerrain(1f, orthogonal);
}
return null;
}

/**
Expand All @@ -86,12 +82,10 @@ private TerrainComponent createTerrain(float tileWorldSize, TextureRegion terrai
*/

public TiledMapRenderer createRenderer(TiledMap tiledMap, float tileScale) {
switch (orientation) {
case ORTHOGONAL:
return new OrthogonalTiledMapRenderer(tiledMap, tileScale);
default:
return null;
if (orientation == TerrainComponent.TerrainOrientation.ORTHOGONAL) {
return new OrthogonalTiledMapRenderer(tiledMap, tileScale);
}
return null;
}

/**
Expand All @@ -104,9 +98,9 @@ public TiledMapRenderer createRenderer(TiledMap tiledMap, float tileScale) {
private TiledMap createTiles(GridPoint2 tileSize, TextureRegion terrain) {
TiledMap tiledMap = new TiledMap();

TiledMapTileLayer Layer = new TiledMapTileLayer(20, 6, tileSize.x, tileSize.y);
fillInvisibleTiles(Layer, new GridPoint2(20, 6), terrain);
tiledMap.getLayers().add(Layer);
TiledMapTileLayer layer = new TiledMapTileLayer(20, 6, tileSize.x, tileSize.y);
fillInvisibleTiles(layer, new GridPoint2(20, 6), terrain);
tiledMap.getLayers().add(layer);

return tiledMap;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private void addActors() {
table.add(scrapsTb).width(scrapsTb.getWidth() * 0.5f).height(scrapsTb.getHeight() * 0.5f);
table.add(crystalsTb).width(crystalsTb.getWidth() * 0.5f).height(crystalsTb.getHeight() * 0.5f);
stage.addActor(table);

scrapsTb.addAction(new SequenceAction(Actions.fadeIn(4f)));
crystalsTb.addAction(new SequenceAction(Actions.fadeIn(8f)));
}

private TextButton createButton(String imageFilePath, int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextTooltip;
import com.badlogic.gdx.scenes.scene2d.ui.TooltipManager;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
Expand All @@ -17,7 +18,7 @@
public class EngineerCountDisplay extends UIComponent {
private TextButton engineerTb;
private static final String defaultFont = "determination_mono_18";

private static final float Z_INDEX = 2f;
@Override
public void create() {
super.create();
Expand Down Expand Up @@ -45,13 +46,15 @@ private void addActors() {
engineerTb.getLabel().setAlignment(Align.right);
engineerTb.setTouchable(Touchable.enabled);
engineerTb.pad(0, 0, 0, 50);
// engineerTb.setTransform(true);
engineerTb.setTransform(true);
TextTooltip tooltip = new TextTooltip(
"Humans left. If this reaches 0, the game ends", getSkin());
engineerTb.addListener(tooltip);

table.add(engineerTb).width(engineerTb.getWidth() * 0.5f).height(engineerTb.getHeight() * 0.5f);
stage.addActor(table);

engineerTb.addAction(new SequenceAction(Actions.fadeIn(4f)));
}

/**
Expand All @@ -61,11 +64,16 @@ public void updateCount() {
int currentCount = ServiceLocator.getGameEndService().getEngineerCount();
String text = String.format("%d", currentCount);
engineerTb.getLabel().setText(text);
// if (currentCount < ServiceLocator.getGameEndService().getThreshold()) {
//// engineerTb.addAction(Actions.color(Color.RED, 0.5f, Interpolation.swingIn));
// engineerTb.addAction(Actions.forever(new SequenceAction(Actions.fadeOut(0.5f),
// Actions.fadeIn(0.5f))));
// }
if (currentCount < ServiceLocator.getGameEndService().getThreshold()) {
// engineerTb.addAction(Actions.color(Color.RED, 0.5f, Interpolation.swingIn));
engineerTb.addAction(Actions.forever(new SequenceAction(Actions.fadeOut(0.5f),
Actions.fadeIn(0.5f))));
}
}

@Override
public float getZIndex() {
return Z_INDEX;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.csse3200.game.components.maingame;

import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.csse3200.game.screens.GameLevelData;
import com.csse3200.game.services.ServiceLocator;

public class LevelProgressBar extends ProgressBar {

static int selectedLevel = GameLevelData.getSelectedLevel();

/**
* @param width of the health bar
* @param height of the health bar
*/
public LevelProgressBar(int width, int height) {
super(0f, getMobCount(), 0.01f, false, new ProgressBarStyle());
getStyle().background = getColoredDrawable(width, height, Color.RED);
getStyle().knob = new TextureRegionDrawable(new TextureRegion(new Texture("images/skeleton.png")));
getStyle().knobBefore = getColoredDrawable(width, height, Color.GREEN);

setWidth(width);
setHeight(height);

setAnimateDuration(0.0f);
setValue(1f);

setAnimateDuration(0.25f);
}

/**
* Color filling for the Progress Bar
* @param width the width in pixels
* @param height the height in pixels
* @param color the color of the filling
* @return Drawable
*/
public static Drawable getColoredDrawable(int width, int height, Color color) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fill();

TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap)));

pixmap.dispose();

return drawable;
}

/**
* Get the number of mobs based on the level
* @return number of total mobs
*/
public static int getMobCount() {

switch (selectedLevel) {
// Desert
case 1 -> { // Ice
ServiceLocator.getWaveService().setTotalMobs(91);
return 91;
}
case 2 -> { // Lava
ServiceLocator.getWaveService().setTotalMobs(204);
return 204;
}
default -> {
ServiceLocator.getWaveService().setTotalMobs(27);
return 27;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ private void onExit() {
private void onLose() {
game.setScreen(GdxGame.ScreenType.LOSING_SCREEN);
}

// private void onWin() { game.setScreen(GdxGame.ScreenType.WIN_SCREEN);} // TODO : Uncomment this once win screen implemented
}
Loading
Loading