Skip to content

Commit

Permalink
Merge pull request #589 from UQcsse3200/feature/player
Browse files Browse the repository at this point in the history
Feature/player
  • Loading branch information
racheljadel authored Oct 19, 2023
2 parents e1eaf98 + f45c246 commit e26b340
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
Expand Down Expand Up @@ -45,7 +42,6 @@ public ShipInteractionPopup(List<ResourceCondition> requirements) {
titleLabel.setColor(Color.RED);
add(titleLabel).padTop(20).center().top().expandX();
row();

Label descriptionLabel = getLabel(requirements, labelStyle, popupWidth);
descriptionLabel.setAlignment(Align.center);
add(descriptionLabel).width(popupWidth * 0.9f).padTop(20).padLeft(popupWidth * 0.05f).expand().fill();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ public static Entity createShip(GdxGame game, List<ResourceCondition> requiremen
ServiceLocator.getGameStateObserverService().trigger("resourceAdd",
requirement.getResource(), -requirement.getThreshold());
}

String[] storytext= {"{SLOW}Astro: This is my ship having an in built AI.\n The AI will guide you throughout. "
,"{SLOW}Player: It is of great help to us \n Why dont you join us ?"
,"{SLOW}Astro: I was attacked and I know I cant make it. \n The AI will guide you.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Scaling;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.csse3200.game.GdxGame;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.input.InputOverrideComponent;
import com.csse3200.game.utils.LoadUtils;
import com.csse3200.game.components.spacenavigation.NavigationBackground;
import com.csse3200.game.services.PlanetTravel;
Expand Down Expand Up @@ -42,6 +46,9 @@ public class SpaceNavigationScreen implements Screen {
private static final String IMAGE_PATH = "images/navigationmap/";

private final PlanetTravel planetTravel;
Entity entity;
private InputOverrideComponent inputOverrideComponent;


/**
* Constructs a new SpaceNavigationScreen with a reference to the main game.
Expand Down Expand Up @@ -150,18 +157,43 @@ private void spawnPlanets(Stage stage) {

String currentPlanetName = (String) ServiceLocator.getGameStateObserverService().getStateData("currentPlanet");
String nextPlanetName = (String) ServiceLocator.getGameStateObserverService().getStateData("nextPlanet");
for (int i = 0; i < planetNames.length; i++) {

// Create planet sprite,
table.add(createPlanetTable(i, planetSize,
(Objects.equals(LoadUtils.formatName(planetNames[i]), currentPlanetName)) ? 1 :
(Objects.equals(LoadUtils.formatName(planetNames[i]), nextPlanetName)) ? 2 : 0
));

if (i != planetNames.length - 1) {
table.add(createArrow(
Objects.equals(LoadUtils.formatName(planetNames[i]), currentPlanetName) ? "right" : "right-grey"
)).pad(arrowPadding).width(arrowSize).height(arrowSize);
if (nextPlanetName.equals("END")) {
Texture endScreen = new Texture(Gdx.files.internal("images/Deathscreens/endscreen.jpg"));
TextureRegionDrawable endBackground = new TextureRegionDrawable(endScreen);
Image image = new Image(endBackground);
image.setHeight((float) Gdx.graphics.getHeight());
image.setWidth(Gdx.graphics.getWidth());
image.setPosition(0,stage.getHeight()-image.getHeight());
stage.clear();
stage.addActor(image);
inputOverrideComponent = new InputOverrideComponent();
ServiceLocator.getInputService().register(inputOverrideComponent);
entity.getEvents().trigger("pauseGame");
final Timer timer = new Timer();
Timer.Task switchToMainMenu = new Timer.Task() {
@Override
public void run() {
game.setScreen(GdxGame.ScreenType.MAIN_MENU);
ServiceLocator.getInputService().unregister(inputOverrideComponent);
entity.getEvents().trigger("resumeGame");
timer.clear();
}
};
timer.schedule(switchToMainMenu, 5);
} else {
for (int i = 0; i < planetNames.length; i++) {

// Create planet sprite,
table.add(createPlanetTable(i, planetSize,
(Objects.equals(LoadUtils.formatName(planetNames[i]), currentPlanetName)) ? 1 :
(Objects.equals(LoadUtils.formatName(planetNames[i]), nextPlanetName)) ? 2 : 0
));

if (i != planetNames.length - 1) {
table.add(createArrow(
Objects.equals(LoadUtils.formatName(planetNames[i]), currentPlanetName) ? "right" : "right-grey"
)).pad(arrowPadding).width(arrowSize).height(arrowSize);
}
}
}

Expand Down

0 comments on commit e26b340

Please sign in to comment.