diff --git a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java index a54d99b6b..5f2e7bbca 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -207,8 +207,7 @@ public class ForestGameArea extends GameArea { /** * Initialise this ForestGameArea to use the provided TerrainFactory. - * - * @requires terrainFactory != null + * @requires terrainFactory != null */ public ForestGameArea() { super(); @@ -457,9 +456,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; diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java index 3f569d147..78bc3863e 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java @@ -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; @@ -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(); @@ -45,7 +46,7 @@ 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); @@ -61,11 +62,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 diff --git a/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java b/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java index 5a0d9e1bb..139cf5776 100644 --- a/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.EventListener; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; @@ -29,13 +28,10 @@ public class MainGameDisplay extends UIComponent { private final Table buttonTable = new Table(); private String[] sounds = { "sounds/ui/click/click_01.ogg", - "sounds/ui/hover/hover_01.ogg", "sounds/ui/open_close/open_01.ogg" }; private Sound click; - private Sound hover; private Sound openSound; - private Sound closeSound; private GdxGame game; /** @@ -235,6 +231,6 @@ public void loadSounds() { ServiceLocator.getResourceService().loadSounds(sounds); ServiceLocator.getResourceService().loadAll(); click = ServiceLocator.getResourceService().getAsset(sounds[0], Sound.class); - openSound = ServiceLocator.getResourceService().getAsset(sounds[2], Sound.class); + openSound = ServiceLocator.getResourceService().getAsset(sounds[1], Sound.class); } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java index 353e96a19..203f14c03 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java @@ -30,11 +30,9 @@ public class MobDodgeTask extends MobTask { * Initialises a mob dodge task with a specified wander range, wait time, and * priority level. * - * @param wanderRange Distance in X and Y the entity can move from its position - * when start() is - * called. - * @param waitTime How long in seconds to wait between wandering. - * @param priority Priority level compared to other added tasks. + * @param mobType Distance in X and Y the entity can move from its position + * when start() is called. + * @param priority Priority level compared to other added tasks. */ public MobDodgeTask(MobType mobType, int priority) { super(mobType); diff --git a/source/core/src/main/com/csse3200/game/input/BuildInputComponent.java b/source/core/src/main/com/csse3200/game/input/BuildInputComponent.java index 666a6878a..8878e2f2e 100644 --- a/source/core/src/main/com/csse3200/game/input/BuildInputComponent.java +++ b/source/core/src/main/com/csse3200/game/input/BuildInputComponent.java @@ -98,7 +98,6 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) { logger.debug("spawning a tower at {}, {}", cursorPosition.x, cursorPosition.y); return buildTower((int)cursorPosition.x, (int)cursorPosition.y); } else { - // TODO: Create a tile indication of invalid placement here?? return false; } } @@ -144,7 +143,7 @@ public boolean keyUp(int keycode) { /** * * @param keycode one of the constants in {@link Input.Keys} - * @return + * @return true if the multipleBuild key is down, otherwise false */ public boolean keyDown(int keycode) { if (keycode == Input.Keys.CONTROL_LEFT) { diff --git a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java index 2676ec8bb..f02b02924 100644 --- a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java @@ -221,6 +221,7 @@ public void render(float delta) { ui.getEvents().trigger("lose"); } else if (ServiceLocator.getWaveService().isLevelCompleted()) { // Check if all waves are completed and the level has been completed + logger.info("Main game level completed detected, go to win screen"); ui.getEvents().trigger("lose"); // needs to change to: ui.getEvents().trigger("win"); // Add something in to unlock the next planet/level? diff --git a/source/core/src/main/com/csse3200/game/services/GameEndService.java b/source/core/src/main/com/csse3200/game/services/GameEndService.java index a97762059..c25b196a4 100644 --- a/source/core/src/main/com/csse3200/game/services/GameEndService.java +++ b/source/core/src/main/com/csse3200/game/services/GameEndService.java @@ -55,7 +55,7 @@ public void updateEngineerCount() { * @return the warning threshold int */ public float getThreshold() { - return (float)(0.25 * STARTING_COUNT); + return (float)( STARTING_COUNT); } /** diff --git a/source/core/src/main/com/csse3200/game/services/ServiceLocator.java b/source/core/src/main/com/csse3200/game/services/ServiceLocator.java index 7c16fc03f..f2273efae 100644 --- a/source/core/src/main/com/csse3200/game/services/ServiceLocator.java +++ b/source/core/src/main/com/csse3200/game/services/ServiceLocator.java @@ -14,11 +14,11 @@ /** * A simplified implementation of the Service Locator pattern: - * https://martinfowler.com/articles/injection.html#UsingAServiceLocator + * ... * *

Allows global access to a few core game services. * Warning: global access is a trap and should be used extremely sparingly. - * Read the wiki for details (https://github.com/UQcsse3200/game-engine/wiki/Service-Locator). + * Read the wiki for details (...). */ public class ServiceLocator { private static final Logger logger = LoggerFactory.getLogger(ServiceLocator.class); diff --git a/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java index 2b5aa28b7..832b82295 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java @@ -160,20 +160,13 @@ public void testCreateBaseTowerPhysicsComponentStaticBody() { PhysicsComponent physicsComponent5 = tntTower.getComponent(PhysicsComponent.class); PhysicsComponent physicsComponent6 = droidTower.getComponent(PhysicsComponent.class); - assertTrue(physicsComponent.getBody().getType() == BodyType.StaticBody, - "PhysicsComponent should be of type StaticBody"); - assertTrue(physicsComponent1.getBody().getType() == BodyType.StaticBody, - "PhysicsComponent1 should be of type StaticBody"); - assertTrue(physicsComponent2.getBody().getType() == BodyType.StaticBody, - "PhysicsComponent2 should be of type StaticBody"); - assertTrue(physicsComponent3.getBody().getType() == BodyType.StaticBody, - "StunTower's PhysicsComponent should be of type StaticBody"); - assertTrue(physicsComponent4.getBody().getType() == BodyType.StaticBody, - "FireTower's PhysicsComponent should be of type StaticBody"); - assertTrue(physicsComponent5.getBody().getType() == BodyType.StaticBody, - "TNT tower's PhysicsComponent should be of type StaticBody"); - assertTrue(physicsComponent6.getBody().getType() == BodyType.StaticBody, - "Droid Tower's PhysicsComponent should be of type StaticBody"); + assertSame(physicsComponent.getBody().getType(), BodyType.StaticBody, "PhysicsComponent should be of type StaticBody"); + assertSame(physicsComponent1.getBody().getType(), BodyType.StaticBody, "PhysicsComponent1 should be of type StaticBody"); + assertSame(physicsComponent2.getBody().getType(), BodyType.StaticBody, "PhysicsComponent2 should be of type StaticBody"); + assertSame(physicsComponent3.getBody().getType(), BodyType.StaticBody, "StunTower's PhysicsComponent should be of type StaticBody"); + assertSame(physicsComponent4.getBody().getType(), BodyType.StaticBody, "FireTower's PhysicsComponent should be of type StaticBody"); + assertSame(physicsComponent5.getBody().getType(), BodyType.StaticBody, "TNT tower's PhysicsComponent should be of type StaticBody"); + assertSame(physicsComponent6.getBody().getType(), BodyType.StaticBody, "Droid Tower's PhysicsComponent should be of type StaticBody"); } @Test @@ -214,12 +207,10 @@ public void testWeaponTowerCombatStatsComponentAndCostComponent() { @Test public void testWallTowerCombatStatsComponentAndCostComponent() { - assertTrue(wallTower.getComponent(CombatStatsComponent.class).getHealth() == 300, - "Health should be 300"); - assertTrue(wallTower.getComponent(CombatStatsComponent.class).getBaseAttack() == 0, - "BaseAttack should be 0"); - assertTrue(wallTower.getComponent(CostComponent.class).getCost() == 45, - "Cost should be 5"); + assertEquals(300, wallTower.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 20"); + assertEquals(0, wallTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "BaseAttack should be 0"); + assertEquals(45, wallTower.getComponent(CostComponent.class).getCost(), "Cost should be 5"); + }