Skip to content

Commit

Permalink
Merge branch 'innovate_showcase' of https://github.com/UQdeco2800/202…
Browse files Browse the repository at this point in the history
…1-studio-7 into innovate_showcase
  • Loading branch information
E-Roderick committed Nov 4, 2021
2 parents 16c8fd3 + 7a4636b commit eaa552c
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 8 deletions.
1 change: 1 addition & 0 deletions source/core/assets/configs/leaderboard.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0,1470,
9 changes: 9 additions & 0 deletions source/core/src/main/com/deco2800/game/GdxGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions source/core/src/main/com/deco2800/game/chores/ChoreList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -35,6 +36,7 @@ public void create() {
movementComponent = entity.getComponent(PhysicsMovementComponent.class);
entity.getEvents().trigger("update_animation", "standing_south");
bringCameraToMum();

}

@Override
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void update() {
this.energydrinkticks = 0;
}
}
entity.getEvents().trigger("change_score", -1);
}
// update the stamina value of player
updateStamina();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -42,6 +44,8 @@ public static Home getHome() {
return home;
}

public static ScoreComponent getScoreComponent() {return scoreComponent;}

public static EntityService getEntityService() {
return entityService;
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eaa552c

Please sign in to comment.