diff --git a/source/core/assets/configs/leaderboard.txt b/source/core/assets/configs/leaderboard.txt index e69de29b..e2dcbf13 100644 --- a/source/core/assets/configs/leaderboard.txt +++ b/source/core/assets/configs/leaderboard.txt @@ -0,0 +1 @@ +0,1470, \ No newline at end of file diff --git a/source/core/src/main/com/deco2800/game/GdxGame.java b/source/core/src/main/com/deco2800/game/GdxGame.java index 9e71aae3..a368a562 100644 --- a/source/core/src/main/com/deco2800/game/GdxGame.java +++ b/source/core/src/main/com/deco2800/game/GdxGame.java @@ -48,6 +48,15 @@ public void setUsername(String username) { this.username = username; } + public String getUsername() { + if (this.username.isEmpty()) { + String placeholder = ""; + return placeholder; + } else { + return this.username + "! "; + } + } + public void setLevel(int level) { this.level = level; } diff --git a/source/core/src/main/com/deco2800/game/ai/tasks/SlipTask.java b/source/core/src/main/com/deco2800/game/ai/tasks/SlipTask.java index 0a37fac1..eede9764 100644 --- a/source/core/src/main/com/deco2800/game/ai/tasks/SlipTask.java +++ b/source/core/src/main/com/deco2800/game/ai/tasks/SlipTask.java @@ -9,7 +9,7 @@ public class SlipTask extends DefaultTask implements PriorityTask{ private static final Logger logger = LoggerFactory.getLogger(SlipTask.class); - private Vector2 slipRange = new Vector2(2,2); + private Vector2 slipRange = new Vector2(1.5f,1.5f); private Vector2 startPos; private MovementTask movementTask; private int priority = -1; diff --git a/source/core/src/main/com/deco2800/game/chores/ChoreController.java b/source/core/src/main/com/deco2800/game/chores/ChoreController.java index 33cdee2f..ee3c9f6a 100644 --- a/source/core/src/main/com/deco2800/game/chores/ChoreController.java +++ b/source/core/src/main/com/deco2800/game/chores/ChoreController.java @@ -1,6 +1,9 @@ package com.deco2800.game.chores; import com.deco2800.game.entities.Entity; +import com.deco2800.game.generic.ServiceLocator; +import com.deco2800.game.screens.game.GameScreen; +import com.deco2800.game.screens.game.TimerWidget; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,6 +58,8 @@ public void addChore(Entity entity, ChoreList object) { */ private void markCompleted(ChoreList object) { Chore chore = getChoreOf(object); + int choreScore = ServiceLocator.getScreen(GameScreen.class).getGameUI().getComponent(TimerWidget.class).getMinutes() * 10; + ServiceLocator.getScoreComponent().changeScore(choreScore); if (chore != null) { // Reduce the count of the remaining chore entities chore.decreaseAmount(); diff --git a/source/core/src/main/com/deco2800/game/chores/ChoreList.java b/source/core/src/main/com/deco2800/game/chores/ChoreList.java index 1287e382..29515a48 100644 --- a/source/core/src/main/com/deco2800/game/chores/ChoreList.java +++ b/source/core/src/main/com/deco2800/game/chores/ChoreList.java @@ -69,4 +69,14 @@ public String getDescription(int amount) { return null; } } + + /*public String getComplete() { + switch(this) { + case TV: + return "Turning the TV off was hard... but now theres no evidence"; + case DRINK: + return "Ah... now the temptation of energy drink is finally vanquished"; + case DISHWASHER: + } + }*/ } diff --git a/source/core/src/main/com/deco2800/game/entities/components/ScoreComponent.java b/source/core/src/main/com/deco2800/game/entities/components/ScoreComponent.java index dfd0b4bc..c58410ef 100644 --- a/source/core/src/main/com/deco2800/game/entities/components/ScoreComponent.java +++ b/source/core/src/main/com/deco2800/game/entities/components/ScoreComponent.java @@ -28,11 +28,9 @@ public int getScore(){ public void changeScore(int change){ - - if (this.score>0){ - this.score += change; - entity.getEvents().trigger("update_score",score); - } + logger.info("Incrementing score by {}", change); + this.score += change; + entity.getEvents().trigger("update_score", score); } public void tickScore() { diff --git a/source/core/src/main/com/deco2800/game/entities/components/npc/MumActions.java b/source/core/src/main/com/deco2800/game/entities/components/npc/MumActions.java index 83fd6d6b..6d4baa9d 100644 --- a/source/core/src/main/com/deco2800/game/entities/components/npc/MumActions.java +++ b/source/core/src/main/com/deco2800/game/entities/components/npc/MumActions.java @@ -27,6 +27,7 @@ public class MumActions extends InteractionComponent { private Vector2 dest; private long startWaitTime; private long startActionTime; + private String PROMPT_MESSAGE= "What are you still doing awake!? When I get my hands on you...!"; @Override public void create() { @@ -35,6 +36,7 @@ public void create() { movementComponent = entity.getComponent(PhysicsMovementComponent.class); entity.getEvents().trigger("update_animation", "standing_south"); bringCameraToMum(); + } @Override @@ -46,6 +48,8 @@ public void update() { } else if (phase.equals(MumCinematicPhase.WALK)) { if (Math.abs(dest.dst(entity.getPosition())) < 0.2) { waitInHome(); + String text = ServiceLocator.getGame().getUsername(); + ServiceLocator.getScreen(GameScreen.class).getGameUI().getEvents().trigger("create_textbox", text + PROMPT_MESSAGE); } } else if (phase.equals(MumCinematicPhase.WAIT)) { if (ServiceLocator.getTimeSource().getTime() - startWaitTime >= WAIT_TIME_LENGTH) { diff --git a/source/core/src/main/com/deco2800/game/entities/components/player/PlayerActions.java b/source/core/src/main/com/deco2800/game/entities/components/player/PlayerActions.java index 2a40e9f5..e589e2ed 100644 --- a/source/core/src/main/com/deco2800/game/entities/components/player/PlayerActions.java +++ b/source/core/src/main/com/deco2800/game/entities/components/player/PlayerActions.java @@ -50,7 +50,6 @@ public void update() { this.energydrinkticks = 0; } } - entity.getEvents().trigger("change_score", -1); } // update the stamina value of player updateStamina(); diff --git a/source/core/src/main/com/deco2800/game/entities/factories/PlayerFactory.java b/source/core/src/main/com/deco2800/game/entities/factories/PlayerFactory.java index e67d9d32..9cdc21ff 100644 --- a/source/core/src/main/com/deco2800/game/entities/factories/PlayerFactory.java +++ b/source/core/src/main/com/deco2800/game/entities/factories/PlayerFactory.java @@ -41,12 +41,15 @@ public class PlayerFactory { FileLoader.readClass(PlayerConfig.class, "configs/player.json"); public static Entity createPlayer(String[] assets) { + ScoreComponent score = new ScoreComponent(0); + ServiceLocator.registerScoreComponent(score); + Entity player = createBasePlayer(assets) .addComponent(new CombatStatsComponent(stats.health, stats.baseAttack, stats.stamina)) .addComponent(new PlayerStatDisplay()) .addComponent(new InteractionControllerComponent()) .addComponent(new PlayerActions()) - .addComponent(new ScoreComponent(2500)) + .addComponent(score) .addComponent(new PhysicsMovementComponent()) .addComponent(new AITaskComponent().addTask(new SlipTask())); diff --git a/source/core/src/main/com/deco2800/game/generic/ServiceLocator.java b/source/core/src/main/com/deco2800/game/generic/ServiceLocator.java index efaa3f7a..161a758a 100644 --- a/source/core/src/main/com/deco2800/game/generic/ServiceLocator.java +++ b/source/core/src/main/com/deco2800/game/generic/ServiceLocator.java @@ -4,6 +4,7 @@ import com.deco2800.game.GdxGame; import com.deco2800.game.chores.ChoreController; import com.deco2800.game.entities.EntityService; +import com.deco2800.game.entities.components.ScoreComponent; import com.deco2800.game.input.InputService; import com.deco2800.game.maps.Home; import com.deco2800.game.physics.PhysicsService; @@ -29,6 +30,7 @@ public class ServiceLocator { private static InputService inputService; private static ResourceService resourceService; private static ChoreController choreController; + private static ScoreComponent scoreComponent; public static GdxGame getGame() { return game; @@ -42,6 +44,8 @@ public static Home getHome() { return home; } + public static ScoreComponent getScoreComponent() {return scoreComponent;} + public static EntityService getEntityService() { return entityService; } @@ -116,6 +120,11 @@ public static void registerChoreController(ChoreController source) { choreController = source; } + public static void registerScoreComponent(ScoreComponent source) { + logger.debug("Register score component {}", source); + scoreComponent = source; + } + public static void clear() { entityService = null; renderService = null; diff --git a/source/core/src/main/com/deco2800/game/screens/game/GameScreen.java b/source/core/src/main/com/deco2800/game/screens/game/GameScreen.java index 04fdabb4..75147416 100644 --- a/source/core/src/main/com/deco2800/game/screens/game/GameScreen.java +++ b/source/core/src/main/com/deco2800/game/screens/game/GameScreen.java @@ -5,6 +5,7 @@ import com.deco2800.game.chores.ChoreController; import com.deco2800.game.chores.ChoreUI; import com.deco2800.game.entities.Entity; +import com.deco2800.game.entities.components.ScoreComponent; import com.deco2800.game.entities.components.player.CameraComponent; import com.deco2800.game.entities.factories.PlayerFactory; import com.deco2800.game.generic.ServiceLocator;