Skip to content

Commit

Permalink
fix(tutorial): notify player if their waypoint is too far away
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminAmos committed Mar 30, 2023
1 parent 6285bb1 commit 670b073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ public void start() {
new ButtonPressStep(solGame.get().getScreens().mapScreen.getZoomInButton(), "Zoom In"),
new ButtonPressStep(solGame.get().getScreens().mapScreen.getZoomOutButton(), "Zoom Out"),
new MapDragStep("You can drag the map to move around."),
new CreateWaypointStep("Create a waypoint near your ship."),
new CreateWaypointStep("Create a waypoint near your ship.",
"That's too far away.\n\n" +
"Remove it and place one closer to your ship."),
new CloseScreenStep(
solGame.get().getScreens().mapScreen.getCloseButton(),
solGame.get().getScreens().mapScreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class CreateWaypointStep extends TutorialStep {
@Inject
protected GameScreens gameScreens;
private final String message;
private final String waypointTooFarMessage;
private UIWarnButton addWaypointButton;
private boolean buttonPressed = false;
private int lastWaypointCount;
Expand All @@ -45,8 +46,9 @@ protected CreateWaypointStep() {
throw new RuntimeException("Attempted to instantiate TutorialStep via DI. This is not supported.");
}

public CreateWaypointStep(String message) {
public CreateWaypointStep(String message, String waypointTooFarMessage) {
this.message = message;
this.waypointTooFarMessage = waypointTooFarMessage;
}

public void start() {
Expand All @@ -66,12 +68,16 @@ public boolean checkComplete(float timeStep) {
}

Hero hero = game.getHero();
if (hero.getWaypoints().size() == 0) {
setTutorialText(message);
}

if (hero.getWaypoints().size() > lastWaypointCount) {
Waypoint waypoint = hero.getWaypoints().get(hero.getWaypoints().size()-1);
if (waypoint.getPosition().dst(hero.getPosition()) < 100.0f) {
return true;
} else {
hero.removeWaypoint(waypoint);
setTutorialText(waypointTooFarMessage);
}
}
lastWaypointCount = game.getHero().getWaypoints().size();
Expand Down

0 comments on commit 670b073

Please sign in to comment.