Skip to content

Commit

Permalink
Optimised titlebox spawwing on planets
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketgupta17 committed Oct 19, 2023
1 parent 0891d09 commit 5381eb8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.csse3200.game.physics.components.PhysicsComponent;
import com.csse3200.game.physics.components.PhysicsMovementComponent;
import com.csse3200.game.rendering.TextureRenderComponent;
import com.csse3200.game.screens.PlanetScreen;
import com.csse3200.game.services.GameStateObserver;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.TitleBox;
Expand Down Expand Up @@ -270,6 +271,10 @@ public static Entity createShip(GdxGame game, List<ResourceCondition> requiremen
TextButton okButton = new TextButton("Start Journey", skin);

}
else {
ShipInteractionPopup shipPopup = new ShipInteractionPopup();
ServiceLocator.getRenderService().getStage().addActor(shipPopup);
}
}, 5));

ship.addComponent(new SaveableComponent<ShipConfig>(s -> {
Expand Down
22 changes: 10 additions & 12 deletions source/core/src/main/com/csse3200/game/screens/PlanetScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class PlanetScreen extends ScreenAdapter {
/** Service Instances */
private Renderer renderer;
private PhysicsEngine physicsEngine;
public static boolean titleBoxDisplayed = false;
public static boolean titleBoxDisplayed;

/** file paths of textures for screen to load. */
private AssetsConfig assets;
Expand All @@ -87,7 +87,6 @@ public PlanetScreen(GdxGame game, String name) {
this.game = game;
this.name = name;
this.assets = FileLoader.readClass(AssetsConfig.class, "levels/global_assets.json");

String levelName = LoadUtils.formatName(name);
try {
this.levelConfig = ConfigLoader.loadLevel(levelName);
Expand Down Expand Up @@ -115,7 +114,6 @@ public void show() {
} else {
ServiceLocator.getGameStateObserverService().trigger("updatePlanet", "gameArea", currentAreaName);
}
ServiceLocator.registerGameArea(this.allGameAreas.get(currentAreaName));

this.allGameAreas.get(currentAreaName).create();
this.player = allGameAreas.get(currentAreaName).getPlayer();
Expand All @@ -135,34 +133,34 @@ private void showTitleBox() {

titleBox = new TitleBox(game, title, description, skin, window);
}
else if ("blazes_refuge".equals(name)) {
if ("blazes_refuge".equals(name)) {
// Create and display the TitleBox
String[] title = {"", ""};
String[] description = {"NPC: (Desperately pleading) Please, you have to get me out of here!\n They captured me when I landed on this planet.", ""};
String[] window = {"dialogue_1", "dialogue_2"};
String[] description = {"Emily : Blaze's Refuge, a fiery world filled with danger.\n Let's explore and gather data for the ship's AI. ", "Player: We should be careful.\n I can sense some danger here."};
String[] window = {"dialogue_2", "dialogue_3"};

titleBox = new TitleBox(game, title, description, skin, window);
}
else if ("flora_haven".equals(name)) {
if ("flora_haven".equals(name)) {
// Create and display the TitleBox
String[] title = {"", ""};
String[] description = {"NPC(Dying): I'm grateful you're here.\n I've fallen victim to the toxic plants of Flora Haven.", ""};
String[] window = {"dialogue_1", "dialogue_2"};

titleBox = new TitleBox(game, title, description, skin, window);
}
else if ("cryoheim".equals(name)) {
if ("cryoheim".equals(name)) {
// Create and display the TitleBox
String[] title = {"", "", "", "", ""};
String[] description = {"Stranded Astronaut (Greeting): Welcome to Cryoheim, the land of ice and danger.\n I've been stuck on this freezing world for ages.", "Player: How do we survive and navigate through this planet?", "Astronaut: The key to survival here is to stick close to the heat sources.\n Don't venture too far away.", "Hellman (challenger): You seem tough, but can you face\n the mightiest boss of this ice world?", "Hellman (challenger): If you can defeat it, I'll share critical information\n that can upgrade your ship's AI, helping it find a better habitable planet."};
String[] window = {"dialogue_4", "dialogue_3", "dialogue_4", "dialogue_6", "dialogue_6"};

titleBox = new TitleBox(game, title, description, skin, window);
}
// Adjust title and skin as needed
titleBox.showDialog(ServiceLocator.getRenderService().getStage());
// Adjust title and skin as needed
titleBox.showDialog(ServiceLocator.getRenderService().getStage());
// Adjust title and skin as needed
titleBox.showDialog(ServiceLocator.getRenderService().getStage());
// Adjust title and skin as needed
titleBox.showDialog(ServiceLocator.getRenderService().getStage());

// Pause the game while the TitleBox is displayed
Gdx.graphics.setContinuousRendering(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public void clicked(InputEvent event, float x, float y) {
if (planetType == 1) {
planetTravel.returnToCurrent();
} else {
PlanetScreen.titleBoxDisplayed = false;
planetTravel.beginInstantTravel();
}
}
Expand Down

0 comments on commit 5381eb8

Please sign in to comment.