diff --git a/source/core/src/main/com/csse3200/game/GdxGame.java b/source/core/src/main/com/csse3200/game/GdxGame.java index e349821ee..77917b431 100644 --- a/source/core/src/main/com/csse3200/game/GdxGame.java +++ b/source/core/src/main/com/csse3200/game/GdxGame.java @@ -77,6 +77,8 @@ private Screen newScreen(ScreenType screenType) { return new SpaceMapScreen(this); case EXTRACTOR_GAME: return new ExtractorMiniGameScreen(this); + case NAVIGATION_SCREEN: + return new SpaceNavigationScreen(this); default: return null; } @@ -84,7 +86,7 @@ private Screen newScreen(ScreenType screenType) { public enum ScreenType { - MAIN_MENU, MAIN_GAME, SETTINGS, TITLE_SCREEN,SPACE_MAP ,EXTRACTOR_GAME, GAME_STORY + MAIN_MENU, MAIN_GAME, SETTINGS, TITLE_SCREEN,SPACE_MAP ,EXTRACTOR_GAME, GAME_STORY, NAVIGATION_SCREEN } diff --git a/source/core/src/main/com/csse3200/game/areas/NavigationArea.java b/source/core/src/main/com/csse3200/game/areas/NavigationArea.java deleted file mode 100644 index 729c1675a..000000000 --- a/source/core/src/main/com/csse3200/game/areas/NavigationArea.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.csse3200.game.areas; - -import com.badlogic.gdx.Game; -import com.badlogic.gdx.Gdx; -import com.csse3200.game.GdxGame; -import com.csse3200.game.areas.terrain.TerrainFactory; -import com.csse3200.game.components.gamearea.GameAreaDisplay; -import com.csse3200.game.components.navigation.NavigationPlanetComponent; -import com.csse3200.game.entities.Entity; -import com.csse3200.game.services.PlanetTravel; -import com.csse3200.game.services.ResourceService; -import com.csse3200.game.services.ServiceLocator; - -/** - * A GameArea that displays all the possible planets the player can travel to and - * allows for the selection of which planet to go to next. - */ -public class NavigationArea extends GameArea{ - - // Textures to be loaded - private static final String[] spaceMapTextures = { - "images/heart.png" - }; - - // The game this area is in - private final GdxGame game; - - // The Factory to generate the new areas terrain - private final TerrainFactory terrainFactory; - - // Handler of the transition point between planets - private final PlanetTravel planetTravel; - - /** - * Constructor for the Navigation Game Area - * @param game Game its being played on - * @param terrainFactory The terrain factor used to generate the next planet area. - */ - public NavigationArea(GdxGame game, TerrainFactory terrainFactory) { - this.game = game; - this.terrainFactory = terrainFactory; - this.planetTravel = new PlanetTravel(game); - } - - /** - * Creates the NavigationArea buttons and assets - */ - @Override - public void create() { - loadAssets(); - displayUI(); - createNavigationPlanets(); - } - - /** - * Disposes of the NavigationArea - */ - @Override - public void dispose() { - super.dispose(); - unloadAssets(); - } - - /** - * Display the UI GameArea - */ - private void displayUI() { - Entity ui = new Entity(); - ui.addComponent(new GameAreaDisplay("Space Map")); - spawnEntity(ui); - } - - /** - * Create all the planet button options - */ - private void createNavigationPlanets() { - createPlanetUI("Level 1", 100, 100); - createPlanetUI("Level 2", 300, 100); - createPlanetUI("Level 3", 500, 100); - createPlanetUI("Level 4", 700, 100); - - } - - /** - * Create a single planet button - * @param planetName The name of the planet - * @param x The x-coord of the button - * @param y The y-coord of the button - */ - private void createPlanetUI(String planetName, int x, int y) { - Entity planet = new Entity().addComponent(new NavigationPlanetComponent( - "images/heart.png", x, y, planetName)); - planet.getEvents().addListener("Navigate" + planetName, () -> - navigateToArea(new EarthGameArea(terrainFactory, game))); - spawnEntity(planet); - } - - /** - * Transition from current NavigationArea to the new area - * @param nextArea Next area to transition to. - */ - private void navigateToArea(GameArea nextArea) { - this.dispose(); - nextArea.create(); - } - - /** - * Load all required assets - */ - private void loadAssets() { - ServiceLocator.getResourceService().loadTextures(spaceMapTextures); - } - - /** - * Unload the assets used - */ - private void unloadAssets() { - ServiceLocator.getResourceService().unloadAssets(spaceMapTextures); - } - -} diff --git a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java index f0b8420c5..b35c9f2f7 100644 --- a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java +++ b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java @@ -93,9 +93,8 @@ private void onExtractor(){ } private void onSpaceMap() { - logger.info("Launching Space Map in Screen"); - game.setScreen(GdxGame.ScreenType.MAIN_GAME); - ((MainGameScreen)game.getScreen()).loadSpaceMap(); + logger.info("Launching space map screen"); + game.setScreen(GdxGame.ScreenType.NAVIGATION_SCREEN); } } diff --git a/source/core/src/main/com/csse3200/game/components/navigation/NavigationPlanetComponent.java b/source/core/src/main/com/csse3200/game/components/navigation/NavigationPlanetComponent.java deleted file mode 100644 index bab0561da..000000000 --- a/source/core/src/main/com/csse3200/game/components/navigation/NavigationPlanetComponent.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.csse3200.game.components.navigation; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.ui.Button; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Table; -import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.badlogic.gdx.utils.Align; -import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.ui.UIComponent; - -/** - * The `PlanetComponent` class represents a navigational component in the game, allowing players - * to interact with and navigate to different game areas represented as planets. - */ -public class NavigationPlanetComponent extends UIComponent { - - // The path to the planet image - private final String PlanetImage; - - // The x and y coords - private final float x; - private final float y; - - // Table of UI elements - private Table table; - - // The name of the planet - private final String name; - - /** - * Constructs a `PlanetComponent` instance with the specified planet image and coordinates. - * - * @param PlanetImage The path to the image representing the planet. - * @param x The x-coordinate of the planet's position. - * @param y The y-coordinate of the planet's position. - */ - public NavigationPlanetComponent(String PlanetImage, float x, float y, String name) { - this.PlanetImage = PlanetImage; - this.x = x; - this.y = y; - this.name = name; - } - - /** - * Creates the planet UI component, including the planet image and navigation button. - * Sets up event listeners for navigation triggers. - */ - @Override - public void create() { - super.create(); - - // Create and configure the UI elements - table = new Table(); - Image planetImage = new Image(ServiceLocator.getResourceService().getAsset(PlanetImage, Texture.class)); - Label label = new Label(name, skin, "large"); - Button button = new Button(label, skin); - - // Add a listener to the navigation button - button.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent changeEvent, Actor actor) { - // Trigger navigation event when the button is clicked - entity.getEvents().trigger("Navigate"+name); - } - }); - - // Configure the layout of UI elements within the table - table.add(planetImage).align(Align.top).size(100f); - table.row(); - table.add(button); - - // Set the position and size of the table - table.setPosition(x, y); - table.setSize(20, 20); - - // Add the table to the stage for rendering - stage.addActor(table); - } - - /** - * Draws the UI component. This method is intentionally left empty as the drawing - * is handled by the LibGDX scene2d framework. - * - * @param batch The sprite batch used for rendering. - */ - @Override - protected void draw(SpriteBatch batch) { - // Drawing is managed by the LibGDX scene2d framework - } - - /** - * Disposes of resources used by the `PlanetComponent`. Clears the internal table - * and performs the parent class disposal. Removes the table from the stage. - */ - @Override - public void dispose() { - // Clear and remove the table from the stage - table.clear(); - super.dispose(); - table.remove(); - } -} \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/navigation/PlanetComponent.java b/source/core/src/main/com/csse3200/game/components/navigation/PlanetComponent.java deleted file mode 100644 index 7e460e853..000000000 --- a/source/core/src/main/com/csse3200/game/components/navigation/PlanetComponent.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.csse3200.game.components.navigation; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.ui.Button; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Table; -import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.badlogic.gdx.utils.Align; -import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.ui.UIComponent; - -/** - * The PlanetComponent class represents a UI component that displays a planet image, - * along with a button for navigation to a different level. - */ -public class PlanetComponent extends UIComponent { - - // The path to the planet image - private final String PlanetImage; - - // The x and y coords - private final float x; - private final float y; - - // Table of UI elements - private Table table; - - /** - * Constructs a new PlanetComponentt instance. - * - * @param PlanetImage The path to the planet image. - * @param x The x-coordinate for the position of the planet component. - * @param y The y-coordinate for the position of the planet component. - */ - public PlanetComponent(String PlanetImage, float x, float y) { - this.PlanetImage=PlanetImage; - this.x=x; - this.y=y; - } - - /** - * Creates the UI elements for the planet component. - */ - @Override - public void create() { - super.create(); - table=new Table(); - Image planetImage = new Image(ServiceLocator.getResourceService().getAsset(PlanetImage, Texture.class)); - Label label=new Label("Level 2 ",skin,"large"); - Button button=new Button(label,skin); - button.addListener( - new ChangeListener() { - @Override - public void changed(ChangeEvent changeEvent, Actor actor) { - - entity.getEvents().trigger("Navigatee"); - } - }); - - table.add(planetImage).align(Align.top).size(100f); - table.row(); - table.add(button); - table.setPosition(x,y); - table.setSize(20,20); - stage.addActor(table); - } - - /** - * Draws the planet component (not implemented in this class). - * - * @param batch The SpriteBatch to use for drawing. - */ - @Override - protected void draw(SpriteBatch batch) { - - } - - /** - * Disposes of resources and clears the table. - */ - @Override - public void dispose() { - table.clear(); - super.dispose(); - table.remove(); - } -} - diff --git a/source/core/src/main/com/csse3200/game/components/navigation/level3.java b/source/core/src/main/com/csse3200/game/components/navigation/level3.java deleted file mode 100644 index 4b5dd263b..000000000 --- a/source/core/src/main/com/csse3200/game/components/navigation/level3.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.csse3200.game.components.navigation; - -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.ui.Button; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Table; -import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.badlogic.gdx.utils.Align; -import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.ui.UIComponent; - -/** - * The {@code level3} class represents a specialized UI component used to display and interact with - * level 3 in the game. It extends {@code UIComponent} and provides functionality for creating and - * managing the UI elements associated with level 3. - * - *
This class includes methods for creating the UI components, handling user interactions, and
- * disposing of resources when no longer needed.
- */
-public class level3 extends UIComponent {
- private final String PlanetImage;
- private final float x;
- private final float y;
- private Table table;
-
- /**
- * Constructs a new {@code level3} instance with the specified planet image path, x and y
- * coordinates.
- *
- * @param PlanetImage The path to the image representing the planet.
- * @param x The x-coordinate position of the UI component.
- * @param y The y-coordinate position of the UI component.
- */
- public level3(String PlanetImage, float x, float y) {
- this.PlanetImage = PlanetImage;
- this.x = x;
- this.y = y;
- }
-
- /**
- * Creates the UI components for level 3, including the planet image, label, and button for
- * interaction. This method sets up the layout and positioning of these components on the screen.
- */
- @Override
- public void create() {
- super.create();
- table = new Table();
- Image planetImage = new Image(ServiceLocator.getResourceService().getAsset(PlanetImage, Texture.class));
- Label label = new Label("Level 3 ", skin, "large");
- Button button = new Button(label, skin);
- button.addListener(
- new ChangeListener() {
- @Override
- public void changed(ChangeEvent changeEvent, Actor actor) {
- entity.getEvents().trigger("Navigateee");
- }
- });
-
- table.add(planetImage).align(Align.top).size(100f);
- table.row();
- table.add(button);
- table.setPosition(x, y);
- table.setSize(20, 20);
- stage.addActor(table);
- }
-
- /**
- * This method is responsible for drawing UI elements but is currently empty as there is no
- * custom drawing logic.
- *
- * @param batch The SpriteBatch used for rendering.
- */
- @Override
- protected void draw(SpriteBatch batch) {
- // Currently no custom drawing logic.
- }
-
- /**
- * Disposes of the resources associated with this UI component. This includes clearing the table
- * and removing it from the stage.
- */
- @Override
- public void dispose() {
- table.clear();
- super.dispose();
- table.remove();
- }
-}
diff --git a/source/core/src/main/com/csse3200/game/components/navigation/level4.java b/source/core/src/main/com/csse3200/game/components/navigation/level4.java
deleted file mode 100644
index c601c1601..000000000
--- a/source/core/src/main/com/csse3200/game/components/navigation/level4.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.csse3200.game.components.navigation;
-import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.scenes.scene2d.Actor;
-import com.badlogic.gdx.scenes.scene2d.ui.Button;
-import com.badlogic.gdx.scenes.scene2d.ui.Image;
-import com.badlogic.gdx.scenes.scene2d.ui.Label;
-import com.badlogic.gdx.scenes.scene2d.ui.Table;
-import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
-import com.badlogic.gdx.utils.Align;
-import com.csse3200.game.services.ServiceLocator;
-import com.csse3200.game.ui.UIComponent;
-
-/**
- * The level4 class represents a UI component for Level 4 in a game's navigation system.
- * It displays a planet image and a button for navigation to a different level.
- */
-public class level4 extends UIComponent {
-
- // The path to the planet image
- private final String PlanetImage;
-
- // The x and y coords
- private final float x;
- private final float y;
-
- // Table of UI elements
- private Table table;
-
- /**
- * Constructs a new level4 instance.
- *
- * @param PlanetImage The path to the planet image.
- * @param x The x-coordinate for the position of the planet component.
- * @param y The y-coordinate for the position of the planet component.
- */
- public level4(String PlanetImage,float x,float y) {
- this.PlanetImage=PlanetImage;
- this.x=x;
- this.y=y;
- }
-
- /**
- * Creates the UI elements for Level 4 component.
- */
- @Override
- public void create() {
- super.create();
- table=new Table();
- Image planetImage = new Image(ServiceLocator.getResourceService().getAsset(PlanetImage, Texture.class));
- Label label=new Label("Level 4 ",skin,"large");
- Button button=new Button(label,skin);
- button.addListener(
- new ChangeListener() {
- @Override
- public void changed(ChangeEvent changeEvent, Actor actor) {
-
- entity.getEvents().trigger("Navigateeee");
- }
- });
-
- table.add(planetImage).align(Align.top).size(100f);
- table.row();
- table.add(button);
- table.setPosition(x,y);
- table.setSize(20,20);
- stage.addActor(table);
- }
-
- /**
- * Draws the Level 4 component (not implemented in this class).
- *
- * @param batch The SpriteBatch to use for drawing.
- */
- @Override
- protected void draw(SpriteBatch batch) {
-
- }
-
- /**
- * Disposes of resources and clears the table.
- */
- @Override
- public void dispose() {
- table.clear();
- super.dispose();
- table.remove();
- }
-}
-
-
-
diff --git a/source/core/src/main/com/csse3200/game/components/spacenavigation/NavigationBackground.java b/source/core/src/main/com/csse3200/game/components/spacenavigation/NavigationBackground.java
new file mode 100644
index 000000000..ef429769b
--- /dev/null
+++ b/source/core/src/main/com/csse3200/game/components/spacenavigation/NavigationBackground.java
@@ -0,0 +1,100 @@
+package com.csse3200.game.components.spacenavigation;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.Animation;
+import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import com.badlogic.gdx.scenes.scene2d.Actor;
+import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.math.MathUtils;
+import com.badlogic.gdx.graphics.g2d.Batch;
+
+public class NavigationBackground extends Actor {
+ /**
+ * The texture for the space background of the navigation screen.
+ */
+ private Texture spaceBackground;
+
+ /**
+ * Array of animations for individual star sprites.
+ */
+ private Animation