Skip to content

Commit

Permalink
Merge branch 'main' into Team-7--Tower-Stat-Alterations
Browse files Browse the repository at this point in the history
  • Loading branch information
ThivanW committed Oct 16, 2023
2 parents f2e7d04 + bbd1028 commit db0073e
Show file tree
Hide file tree
Showing 55 changed files with 1,240 additions and 744 deletions.
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.
13 changes: 4 additions & 9 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,15 @@ public class ForestGameArea extends GameArea {
"sounds/mobs/archerArrow.mp3"

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

private static final String[] forestMusic = {backgroundMusic};
private static final String[] forestMusic = {BACKGROUND_MUSIC};
private Entity player;
private Entity waves;

/**
* 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 Expand Up @@ -893,7 +888,7 @@ private void spawnDroidTower() {
}

private void playMusic() {
Music music = ServiceLocator.getResourceService().getAsset(backgroundMusic, Music.class);
Music music = ServiceLocator.getResourceService().getAsset(BACKGROUND_MUSIC, Music.class);
music.setLooping(true);
music.setVolume(0.3f);
music.play();
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 @@ -28,7 +28,7 @@ public class CurrencyDisplay extends UIComponent {
private TextButton scrapsTb;
private TextButton crystalsTb;
private Sound clickSound;
private static final String defaultFont = "determination_mono_18";
private static final String DEFAULT_FONT = "determination_mono_18";

/**
* Adds actors to stage
Expand Down Expand Up @@ -58,12 +58,15 @@ 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) {
Drawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(imageFilePath)));
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(
drawable, drawable, drawable, getSkin().getFont(defaultFont));
drawable, drawable, drawable, getSkin().getFont(DEFAULT_FONT));

// create button
TextButton tb = new TextButton(String.format("%d", value), style);
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 @@ -16,7 +17,10 @@

public class EngineerCountDisplay extends UIComponent {
private TextButton engineerTb;
private static final String defaultFont = "determination_mono_18";

private static final String DEFAULT_FONT = "determination_mono_18";

private static final float Z_INDEX = 2f;

@Override
public void create() {
Expand All @@ -37,21 +41,23 @@ private void addActors() {
Drawable drawable = new TextureRegionDrawable(new TextureRegion(
new Texture("images/engineers/engineerBanner.png")));
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(
drawable, drawable, drawable, getSkin().getFont(defaultFont));
drawable, drawable, drawable, getSkin().getFont(DEFAULT_FONT));

String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount());
engineerTb = new TextButton(text, style);
engineerTb.setDisabled(true);
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 +67,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

0 comments on commit db0073e

Please sign in to comment.