Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/t3branch' into t3branch
Browse files Browse the repository at this point in the history
# Conflicts:
#	source/core/src/main/com/csse3200/game/screens/LevelSelectScreen.java
  • Loading branch information
aadityayadav17 committed Oct 16, 2023
2 parents 0156ebf + fb9f76b commit 9b8a3a6
Show file tree
Hide file tree
Showing 11 changed files with 476 additions and 48 deletions.
Binary file added source/core/assets/images/HelpScreen/hs.jpg
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 @@ -91,7 +91,8 @@ public class AssetLoader {
"images/towers/PierceTower.png",
"images/towers/RicochetTower.png",
"images/mobboss/iceBaby.png",
"images/bombship/bombship.png"
"images/bombship/bombship.png",
"images/HelpScreen/hs.jpg"
};

public static final String[] textureAtlases = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.csse3200.game.GdxGame;
import com.csse3200.game.entities.factories.PauseMenuFactory;


public class GameDescriptionHelpScreen extends ScreenAdapter {
Expand Down Expand Up @@ -135,12 +136,11 @@ public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, f
@Override
public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
game.setScreen(GdxGame.ScreenType.TUTORIAL_SCREEN);
PauseCompTutorial.TutorialMenu(game);

}
});



Table buttonTable = new Table();
buttonTable.add(BackButton).padRight(10);
Table table1 = new Table();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.csse3200.game.screens.HelpScreen;


import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.GdxGame;
import com.csse3200.game.components.maingame.MainGamePauseDisplay;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.PauseMenuFactory;
import com.csse3200.game.services.ServiceLocator;

import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Displays a button in the pause menu to resume the game and put away the pause menu.
*/
public class HelpContinueButton extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(com.csse3200.game.components.pausemenu.PauseMenuContinueButton.class);
private static final float Z_INDEX = 2f;
private Table table;
private Table table1;
private GdxGame game;
private final String[] sounds = {
"sounds/ui/Open_Close/NA_SFUI_Vol1_Close_01.ogg"
};
private Sound closeSound;

@Override
public void create() {
super.create();
addActors();
loadSounds();
}

private void addActors() {
table = new Table();
table.center();
table.setFillParent(true);
ButtonFactory buttonFactory = new ButtonFactory();
// TextButton pauseMenuBtn = buttonFactory.createButton("Continue");
TextButton pauseMenuBtn = new TextButton("Continue", skin);

// Triggers an event when the button is pressed.
pauseMenuBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Continue button clicked");
closeSound.play(0.4f);
entity.dispose();
NextButtonMenu.nextMenu(game);

}
});

table.add(pauseMenuBtn);
stage.addActor(table);

}

@Override
public void draw(SpriteBatch batch) {
// draw is handled by the renderer component
}

@Override
public float getZIndex() {
return Z_INDEX;
}

@Override
public void dispose() {
table.clear();
super.dispose();
}

public void loadSounds() {
ServiceLocator.getResourceService().loadSounds(sounds);
ServiceLocator.getResourceService().loadAll();
closeSound = ServiceLocator.getResourceService().getAsset(sounds[0], Sound.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.csse3200.game.screens.HelpScreen;



import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.GdxGame;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.PauseMenuFactory;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Displays a button to pause the game and bring up a pause menu.
*/
public class NextButton extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(com.csse3200.game.screens.HelpScreen.NextButton.class);
private static final float Z_INDEX = 2f;
private Table table;
private GdxGame game;
private final String[] sounds = {
"sounds/ui/Open_Close/NA_SFUI_Vol1_Open_01.ogg"
};
private Sound openSound;


public NextButton(GdxGame screenSwitchHandle) {
game = screenSwitchHandle;
}

@Override
public void create() {
super.create();
addActors();
loadSounds();
}

private void addActors() {
table = new Table();
table.top().right();
table.setFillParent(true);

TextButton mainMenuBtn = new TextButton("Pause", skin);

// Spawns a pause menu when the button is pressed.
mainMenuBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Pause button clicked");
openSound.play(0.4f);
// PauseMenuFactory.createPauseMenu(game, false);
PauseMenuFactory.createPauseMenu(game);

}
});

table.add(mainMenuBtn).padTop(100f).padRight(10f);

stage.addActor(table);
}

@Override
public void draw(SpriteBatch batch) {
// draw is handled by the stage
}

@Override
public float getZIndex() {
return Z_INDEX;
}

@Override
public void dispose() {
table.clear();
super.dispose();
}

public void loadSounds() {
ServiceLocator.getResourceService().loadSounds(sounds);
ServiceLocator.getResourceService().loadAll();
openSound = ServiceLocator.getResourceService().getAsset(sounds[0], Sound.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.csse3200.game.screens.HelpScreen;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.csse3200.game.GdxGame;
import com.csse3200.game.components.pausemenu.*;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.rendering.TextureRenderComponent;
import com.csse3200.game.services.ServiceLocator;
import com.badlogic.gdx.utils.Array;

import static com.badlogic.gdx.utils.Align.center;
import static com.badlogic.gdx.utils.Align.top;

public class NextButtonMenu {

public static Entity nextMenu(GdxGame game) {

Entity Menu = new Entity()
.addComponent(new PauseMenuTimeStopComponent())
.addComponent(new NextContinueButton())
.addComponent(new TowerSelectionInstruct());
Menu.setScale(8, 8.2f);
Menu.setPosition(6.3f,2f);

ServiceLocator.getEntityService().register(Menu);
return Menu;

}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.csse3200.game.screens.HelpScreen;


import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.GdxGame;
import com.csse3200.game.components.maingame.MainGamePauseDisplay;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.PauseMenuFactory;
import com.csse3200.game.services.ServiceLocator;

import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
* Displays a button in the pause menu to resume the game and put away the pause menu.
*/
public class NextContinueButton extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(com.csse3200.game.components.pausemenu.PauseMenuContinueButton.class);
private static final float Z_INDEX = 2f;
private Table table1;
private GdxGame game;
private final String[] sounds = {
"sounds/ui/Open_Close/NA_SFUI_Vol1_Close_01.ogg"
};
private Sound closeSound;

@Override
public void create() {
super.create();
addActors();
loadSounds();
}

private void addActors() {

table1 = new Table();

table1.setFillParent(true);
// TextButton NextMenuBtn = buttonFactory.createButton("Continue");
TextButton NextMenuBtn = new TextButton("Continue", skin);

// Triggers an event when the button is pressed.
NextMenuBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Continue button clicked");
closeSound.play(0.4f);
entity.dispose();

}
});

table1.add(NextMenuBtn);
stage.addActor(table1);
table1.top().right();
table1.padTop(240f).padRight(100f);
}

@Override
public void draw(SpriteBatch batch) {
// draw is handled by the renderer component
}

@Override
public float getZIndex() {
return Z_INDEX;
}

@Override
public void dispose() {
table1.clear();
super.dispose();
}

public void loadSounds() {
ServiceLocator.getResourceService().loadSounds(sounds);
ServiceLocator.getResourceService().loadAll();
closeSound = ServiceLocator.getResourceService().getAsset(sounds[0], Sound.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.csse3200.game.screens.HelpScreen;



import com.csse3200.game.GdxGame;
import com.csse3200.game.components.pausemenu.*;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.rendering.TextureRenderComponent;
import com.csse3200.game.services.ServiceLocator;
import com.badlogic.gdx.utils.Array;

import static com.badlogic.gdx.utils.Align.center;

public class PauseCompTutorial {

public static Entity TutorialMenu(GdxGame game) {

Entity TutorialMenu = new Entity()
.addComponent(new PauseMenuTimeStopComponent())
.addComponent(new HelpContinueButton())
.addComponent(new TextureRenderComponent("images/HelpScreen/hs.jpg"));
TutorialMenu.setScale(16, 8.2f);
TutorialMenu.setPosition(center+1.3f, center);
ServiceLocator.getEntityService().register(TutorialMenu);
return TutorialMenu;

}
}
Loading

0 comments on commit 9b8a3a6

Please sign in to comment.