Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into team2_upgrades2
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinJohn99 committed Oct 17, 2024
2 parents 9d6b61f + c7f5dd7 commit 9af35b1
Show file tree
Hide file tree
Showing 54 changed files with 787 additions and 488 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public class HoverBoxComponent extends RenderComponent {
private Texture hoverImage;
private ShapeRenderer shapeRenderer;
private Vector2 position;
private Vector2 scale;
Vector2 position;
Vector2 scale;
private static final float X_OFFSET = 0.45f;
private static final float Y_OFFSET = 1.0F;

Expand Down Expand Up @@ -79,4 +79,9 @@ public int getLayer() {
public void setStage(Stage mock) {
// setStage is empty
}

public Object getTexture() {
// TODO Auto-generated method stub
return hoverImage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Specific cutscene class handling the backstory of the game.
*/
public class BackstoryCutscene extends Cutscene {
private String foodCriticBackground = "images/Cutscenes/Food_Critic_Background.png";

/**
* Constructor for BackstoryCutscene.
Expand Down Expand Up @@ -77,12 +78,13 @@ protected void setupScenes() {
scene2.setDuration(4.0f);
scenes.add(scene2);

Scene scene3 = new Scene("images/Cutscenes/Food_Critic_Background.png");

Scene scene3 = new Scene(foodCriticBackground);
scene3.setSceneText(scene3Text);
scene3.setDuration(3.0f);
scenes.add(scene3);

Scene scene4 = new Scene("images/Cutscenes/Food_Critic_Background.png");
Scene scene4 = new Scene(foodCriticBackground);
scene4.setSceneText(scene4Text);
scene4.setDuration(3.0f);
scenes.add(scene4);
Expand Down Expand Up @@ -139,8 +141,7 @@ protected void loadAssets() {
textures = new String[] {
"images/Cutscenes/Brooklyn_Bistro_Background.png",
"images/Cutscenes/Kitchen_Background.png",
"images/Cutscenes/Food_Critic_Background.png",
"images/Cutscenes/Food_Critic_Background.png",
foodCriticBackground,
"images/Cutscenes/Animals_in_Kitchen_Background.png",
"images/Cutscenes/Farm_Background.png",
"images/Cutscenes/graveyard_mafia.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BadEndCutscene extends Cutscene {
*/
public BadEndCutscene() {
super();
this.IsAnimatedScenes = true;
this.isAnimatedScenes = true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class Cutscene extends Component {
protected String animName;

// Whether the scenes are fully animated
public boolean IsAnimatedScenes = false;
public boolean isAnimatedScenes = false;

// Game time service to keep track of time
protected GameTime gameTime;
Expand All @@ -69,7 +69,7 @@ public abstract class Cutscene extends Component {
/**
* Constructor for the Cutscene class. Initializes the game time and loads assets and scenes.
*/
public Cutscene() {
protected Cutscene() {
this.gameTime = ServiceLocator.getTimeSource();
loadAssets();
setupScenes();
Expand All @@ -94,7 +94,7 @@ public void create() {
public void update() {
float currentTime = gameTime.getTime();
// Check if the current scene has finished
if (!IsAnimatedScenes) {
if (!isAnimatedScenes) {
if ((currentScene != null) && (currentTime - timeStart) > currentScene.getDuration()) {
logger.info("Scene {} finished. Moving to next scene.", currentSceneIndex);
nextCutscene();
Expand All @@ -114,17 +114,17 @@ protected void nextCutscene() {
disposeEntities(); // Dispose of current entities before moving to the next scene

currentSceneIndex++;
if (!IsAnimatedScenes) {
if (!isAnimatedScenes) {
if (currentSceneIndex < scenes.size()) {
logger.info("Loading next scene: {}", currentSceneIndex);
logger.info("Loading next animated scene: {}", currentSceneIndex);
loadScene(currentSceneIndex);
} else {
logger.info("Cutscene finished. Triggering next event.");
ServiceLocator.getCutsceneScreen().getCutsceneScreenDisplay().getEntity().getEvents().trigger("cutsceneEnded");
}
} else {
if (currentSceneIndex < animatedScenes.size()) {
logger.info("Loading next scene: {}", currentSceneIndex);
logger.info("Loading next non animated scene: {}", currentSceneIndex);
loadScene(currentSceneIndex);
} else {
logger.info("Cutscene finished. Triggering next event.");
Expand Down Expand Up @@ -152,7 +152,7 @@ protected void nextCutsceneMoral() {
* @param sceneIndex Index of the scene to load
*/
protected void loadScene(int sceneIndex) {
if (!IsAnimatedScenes) {
if (!isAnimatedScenes) {
if (sceneIndex >= scenes.size()) {
logger.error("No more scenes available.");
nextCutscene();
Expand Down Expand Up @@ -447,4 +447,54 @@ public String[] getAnimations() {
public void setAnimations(String[] animations) {
this.animations = animations;
}

/**
* Gets the current scene index.
* This method returns the index of the scene that is currently being displayed
* in the cutscene. The index corresponds to the position of the scene in the
* list of scenes.
*
* @return the index of the current scene.
*/
public int getCurrentSceneIndex() {
return currentSceneIndex;
}

/**
* Sets the current scene index and transitions to the specified scene.
* This method allows for manually setting the current scene index, which
* transitions the cutscene to the scene corresponding to the provided index.
* It first validates the scene index to ensure it's within the valid range.
* If the index is valid, it disposes of the entities in the current scene,
* updates the scene index, and loads the new scene.
*
* @param newSceneIndex the index of the scene to switch to.
* Must be a valid index within the list of scenes.
* @throws IllegalArgumentException if the provided index is outside the range
* of available scenes.
*/

public void setCurrentScene(int newSceneIndex) {
if (newSceneIndex < 0 || newSceneIndex >= scenes.size()) {
logger.error("Invalid scene index: {}. Scene index must be between 0 and {}.", newSceneIndex, scenes.size() - 1);
return;
}

// Dispose of the current entities
disposeEntities();

// Set the new scene index
currentSceneIndex = newSceneIndex;

logger.info("Setting current scene to index {}", currentSceneIndex);

// Load the new scene
loadScene(currentSceneIndex);

// Ensure no automatic progression occurs here
logger.info("Scene {} loaded successfully. Not triggering next scene.", currentSceneIndex);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ private void nextCutscene() {
private void cutsceneEnded() {
logger.debug("Transitioning to next cutscene, game level or main menu.");
// Logic for determining what the next screen should be (either next level or cutscene).
logger.debug(String.valueOf(ServiceLocator.getCutsceneScreen().getVal()));
if(logger.isDebugEnabled()) {
logger.debug(String.valueOf(ServiceLocator.getCutsceneScreen().getVal()));
}
if (ServiceLocator.getCutsceneScreen().getVal() == GdxGame.CutsceneType.GOOD_END ||
ServiceLocator.getCutsceneScreen().getVal() == GdxGame.CutsceneType.BAD_END ||
ServiceLocator.getCutsceneScreen().getVal() == GdxGame.CutsceneType.LOSE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* and disposal of cutscenes, and ensures that transitions occur once cutscenes are completed.
*/
public class CutsceneArea extends GameArea {
private static final Logger logger = LoggerFactory.getLogger(ForestGameArea.class);
private static final Logger logger = LoggerFactory.getLogger(CutsceneArea.class);

// Index representing which cutscene to load (could be part of an enum in the future)
private GdxGame.CutsceneType cutsceneValue;
Expand Down Expand Up @@ -93,7 +93,6 @@ public void create() {
ServiceLocator.setCurrentCutscene(currentCutscene); // Set the current cutscene in the service locator
break;
case BAD_END:
//ServiceLocator.clear(Le);
logger.debug("Loading bad end cutscene");
currentCutscene = new BadEndCutscene();
ServiceLocator.setCurrentCutscene(currentCutscene);
Expand All @@ -114,8 +113,6 @@ public void create() {
cutsceneEntity.addComponent(currentCutscene);
ServiceLocator.getEntityService().register(cutsceneEntity);



// Start the cutscene
currentCutscene.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* A factory class for creating entities used in cutscenes, such as backgrounds and animations.
*/
public class CutsceneFactory {
private CutsceneFactory() {
//This does nothing
}

/**
* Creates a background entity with the specified image path. The background
Expand Down Expand Up @@ -89,7 +92,9 @@ public static Entity createImage(String imgPath, float imageScale) {
animation.addComponent(textureComponent);

// Scale the entity based on the texture size
textureComponent.scaleEntity();
if (textureComponent.getTexture() != null){
textureComponent.scaleEntity();
}

animation.setScale(animation.getScale().x * imageScale, animation.getScale().y * imageScale);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class CutsceneScreenDisplay extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(CutsceneScreenDisplay.class);
private Table table;
private TextDisplay textDisplay;
private Skin skin = null;

public CutsceneScreenDisplay(Skin skin) {
super(skin);
Expand Down Expand Up @@ -87,8 +86,8 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
table.add(nextSceneBtn).padBottom(10f).padRight(10f);

// Create "Exit" button to transition back to the main menu
TextButton Exitbutton = new TextButton("Exit", skin);
Exitbutton.addListener(new ChangeListener() {
TextButton exitButton = new TextButton("Exit", skin);
exitButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Main Menu button clicked");
Expand All @@ -100,7 +99,7 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
Table topRightTable = new Table();
topRightTable.setFillParent(true);
topRightTable.top().right();
topRightTable.add(Exitbutton).padTop(20f).padRight(20f);
topRightTable.add(exitButton).padTop(20f).padRight(20f);
stage.addActor(topRightTable);
stage.addActor(table);
}
Expand Down Expand Up @@ -180,8 +179,4 @@ public Table getTable() {
*/
public void setTextDisplay(TextDisplay textDisplay) { this.textDisplay = textDisplay; }

/**
* Function that enables or disables the text box.
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public CutsceneTextDisplay(boolean visible) {
super();
this.table = new Table();
this.visible = visible;
System.out.print("###############################################################################\n");
System.out.print(this.visible);
System.out.print("\n###############################################################################");
}

public CutsceneTextDisplay(Skin skin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import com.csse3200.game.services.ServiceLocator;

public class Day2Cutscene extends Cutscene{
private final String reporterImage = "images/Cutscenes/Character Artwork/reporter_sprite.png";
private final String playerImage = "images/Cutscenes/Character Artwork/player_sprite_back_turned.png";
private final String day2Background = "images/Cutscenes/Day2_Scene.png";
/**
* Constructor for the IntroCutscene class.
*/
Expand All @@ -33,19 +36,18 @@ private void createScene2() {
sceneText.add("Reporter > They are all very curious");
sceneText.add("Reporter > Dont be surprised if you see a few more animals than your first day");
// Add scenes with background images, animations, text, and duration
String reporterImage = "images/Cutscenes/Character Artwork/reporter_sprite.png";

Vector2 reporterPosition = new Vector2(-5, 1);
float reporterScale = 4.0f;

String playerImage = "images/Cutscenes/Character Artwork/player_sprite_back_turned.png";
Vector2 playerPosition = new Vector2(4, -5);
float playerScale = 4.0f;

String exclamationMark = "images/Cutscenes/ExclamationMark.png";
Vector2 exclamationPosition = new Vector2(5.5f, 2);
float exclamationScale = 0.5f;

Scene scene = new Scene("images/Cutscenes/Day2_Scene.png");
Scene scene = new Scene(day2Background);
scene.setImages(
new String[]{reporterImage, playerImage, exclamationMark},
new Vector2[] {reporterPosition, playerPosition, exclamationPosition},
Expand All @@ -64,16 +66,14 @@ private void createScene1() {
sceneText.add("Reporter > The whole animal kingdom has heard about your reverse zoo of a restaurant.");
sceneText.add("Reporter > A human running a restaurant? Its the story of the century.");

String reporterImage = "images/Cutscenes/Character Artwork/reporter_sprite.png";
Vector2 reporterPosition = new Vector2(-5, 1);
float reporterScale = 4.0f;

String playerImage = "images/Cutscenes/Character Artwork/player_sprite_back_turned.png";
Vector2 playerPosition = new Vector2(4, -5);
float playerScale = 4.0f;

// Add scenes with background images, animations, text, and duration
Scene scene = new Scene("images/Cutscenes/Day2_Scene.png");
Scene scene = new Scene(day2Background);
scene.setImages(
new String[]{reporterImage, playerImage},
new Vector2[] {reporterPosition, playerPosition},
Expand All @@ -100,7 +100,7 @@ protected void loadAssets() {
animations = new String[] {};

images = new String[] {
"images/Cutscenes/Character Artwork/reporter_sprite.png",
reporterImage,
"images/Cutscenes/Character Artwork/player_sprite_back_turned.png",
"images/Cutscenes/ExclamationMark.png"};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

public class Day3Cutscene extends Cutscene {

private final String backgroundImage = "images/Cutscenes/Day3_Scene.png";

String playerImage = "images/Cutscenes/Character Artwork/player_sprite_back_turned.png";

public Day3Cutscene() {
super();
}
Expand All @@ -25,14 +29,12 @@ private void createScene1() {
sceneText.add("Mafia Boss > If you mess up today, its five coins out of your pocket.");
sceneText.add("Mafia Boss > Make those orders perfect or you'll be paying for it.");

String backgroundImage = "images/Cutscenes/Day3_Scene.png";


String mafiaBossImage = "images/Cutscenes/Character Artwork/rhino_sprite.png";
Vector2 mafiaBossPosition = new Vector2(-8, -7f);
float mafiaBossScale = 5.0f;

String playerImage = "images/Cutscenes/Character Artwork/player_sprite_back_turned.png";
Vector2 playerPosition = new Vector2(4, -7f);
float playerScale = 5.0f;

Expand Down Expand Up @@ -62,11 +64,10 @@ private void createScene2() {
Vector2 healthInspectorPosition = new Vector2(-8, -7);
float healthInspectorScale = 5.0f;

String playerImage = "images/Cutscenes/Character Artwork/player_sprite_back_turned.png";
Vector2 playerPosition = new Vector2(4, -7f);
float playerScale = 5.0f;

Scene scene = new Scene("images/Cutscenes/Day3_Scene.png");
Scene scene = new Scene(backgroundImage);
scene.setImages(
new String[]{healthInspectorImage, playerImage},
new Vector2[]{healthInspectorPosition, playerPosition},
Expand All @@ -83,15 +84,15 @@ private void createScene2() {
protected void loadAssets() {
// Load the background and character images for the cutscene
textures = new String[] {
"images/Cutscenes/Day3_Scene.png",
backgroundImage,
};

animations = new String[] {};

images = new String[] {
"images/Cutscenes/Character Artwork/rhino_sprite.png",
"images/Cutscenes/Character Artwork/panda_sprite.png",
"images/Cutscenes/Character Artwork/player_sprite_back_turned.png"
playerImage
};

ResourceService resourceService = ServiceLocator.getResourceService();
Expand Down
Loading

0 comments on commit 9af35b1

Please sign in to comment.