Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 5 Added click sounds, updated tower descriptions and their fonts #305

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions source/core/src/main/com/csse3200/game/screens/TowerType.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Youve changed the costs of the tnt tower droid tower and weapon tower back to their original costs which is not what we want

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh sorry about that, ill update that now in alignment to what is in main

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconding Thivan's comment, you may need to pull main into your branch before merging

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

public enum TowerType {
WEAPON("Weapon Tower", "weapon_tower", "The Weapon Tower is a simple and basic turret that fires rapid shots at enemies dealing damage over time.",
0, "50", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/weapon-tower-selected.png"),
TNT("TNT Tower", "tnt_tower", "The TNT Tower launches explosive projectiles, dealing area damage to groups of enemies.",
1, "50", "images/turret-select/tnt-tower-default.png", "images/turret-select/tnt-tower-selected.png"),
DROID("Droid Tower", "droid_tower", "Droid Towers deploy robotic helpers that assist in combat and provide support to nearby turrets.",
2, "300", "images/turret-select/droid-tower-default.png", "images/turret-select/droid-tower-selected.png"),
0, "15", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/weapon-tower-selected.png"),
TNT("TNT Tower", "tnt_tower", "The TNT Tower explodes when touched, dealing area damage to groups of enemies.",
1, "30", "images/turret-select/tnt-tower-default.png", "images/turret-select/tnt-tower-selected.png"),
DROID("Droid Tower", "droid_tower", "Droid Towers are basic military towers that deal damage to enemies and slow down enemies",
2, "45", "images/turret-select/droid-tower-default.png", "images/turret-select/droid-tower-selected.png"),
WALL("Wall Tower", "wall", "The Wall Tower creates barriers to block enemy paths, slowing down their progress.",
3, "200", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-selected.png"),
FIRE("Fire Tower", "fire_tower", "The Fire Tower emits flames, causing damage over time to enemies caught in its fiery radius.",
4, "300", "images/turret-select/fire-tower-default.png", "images/turret-select/fire-tower-selected.png"),
STUN("Stun Tower", "stun_tower", "The Stun Tower releases electric shocks that temporarily immobilize and damage enemies.",
5, "500", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-selected.png"),
INCOME("Income Tower", "income_tower", "The Income Tower generates additional in-game currency over time.",
INCOME("Income Tower", "income_tower", "The Mine Tower generates additional in-game currency over time.",
6, "100", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"),
PIERCE("Pierce Tower", "pierce_tower", "The Pierce Tower fires a projectile that pierces through targets and does not dissipate upon contact.",
6, "400", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
Expand Down Expand Up @@ -37,6 +37,10 @@ public class TurretSelectionScreen extends ScreenAdapter {
private Stage stage;
private Label descText;
private List<TowerType> turretList;
private final String[] sounds = {
"sounds/ui/click/click_01.ogg",
};
private Sound click;
private TextButton confirmButton;
private String turretDescriptionText;

Expand Down Expand Up @@ -71,6 +75,8 @@ public TurretSelectionScreen(GdxGame game) {
stage = new Stage(new ScreenViewport());
table = new Table();

loadSounds();

ServiceLocator.registerResourceService(new ResourceService());
ServiceLocator.getResourceService().loadMusic(bgm);
ServiceLocator.getResourceService().loadAll();
Expand All @@ -90,33 +96,24 @@ public TurretSelectionScreen(GdxGame game) {

Skin skin = new Skin(Gdx.files.internal("images/ui/buttons/glass.json"));

// Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
backButton = new TextButton("Back", skin);
backButton = ButtonFactory.createButton("Back");
backButton.setPosition(10, Gdx.graphics.getHeight() - backButton.getHeight() - 10); // Adjust position as needed
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
click.play(0.4f);
// Handle the "back" action, e.g., return to the previous screen
game.setScreen(GdxGame.ScreenType.MAIN_MENU); // Replace PREVIOUS_SCREEN with the appropriate screen type
game.setScreen(GdxGame.ScreenType.LEVEL_SELECT); // Replace PREVIOUS_SCREEN with the appropriate screen type
}
});
Table topRightTable = new Table();
topRightTable.top().right();
topRightTable.add(backButton).pad(10);

stage.addActor(topRightTable);

message = new Label("Select your turrets", skin);
message = new Label("Select up to 5 towers", skin);

// confirmButton = createButton("images/turret-select/imageedit_4_5616741474.png",
// "images/ui/Sprites/UI_Glass_Button_Large_Press_01a1.png", "Continue", "", "");
// Drawable pressDrawable = new TextureRegionDrawable(new TextureRegion(
// new Texture("images/ui/Sprites/UI_Glass_Button_Large_Press_01a1.png")));
// confirmButton.getStyle().down = pressDrawable;
// confirmButton.pad(0,0,6,0);
confirmButton = ButtonFactory.createButton("Continue");
confirmButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
click.play(0.4f);
// Store the selected towers in the ServiceLocator for transferring across screens
// (as an Array)
Array<TowerType> towers = new Array<>();
Expand All @@ -131,9 +128,8 @@ public void clicked(InputEvent event, float x, float y) {
turretDescriptionLabel = createButton("images/turret-select/imageedit_28_4047785594.png",
"images/turret-select/imageedit_28_4047785594.png", "", "", turretDescriptionText);

BitmapFont font = new BitmapFont();
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = font; // Set your desired BitmapFont
labelStyle.font = getSkin().getFont("determination_mono_18"); // Set your desired BitmapFont
descText = new Label(turretDescriptionText, labelStyle);
descText.setWrap(true);
descText.setWidth(190f);
Expand All @@ -159,7 +155,7 @@ public void clicked(InputEvent event, float x, float y) {
turretTable.center(); // Center the contents of the nested table

descriptionLabel = createButton("images/turret-select/imageedit_15_5627113584.png",
"images/turret-select/imageedit_15_5627113584.png", "Description: ", turretName, "");
"images/turret-select/imageedit_15_5627113584.png", "", turretName, "");

TextButton button = createButton(turret.getDefaultImage(),
turret.getClickedImage(), turret.getPrice(), turret.getTowerName(), turret.getDescription());
Expand All @@ -173,7 +169,7 @@ public void clicked(InputEvent event, float x, float y) {
if (selectedTurrets.size() > MAX_SELECTED_TURRETS) {
message.setText("You can only select up to 5 turrets.");
} else {
message.setText("Select your turrets");
message.setText("Select up to 5 towers");
}
if (selectedTurrets.contains(turret)) {
// Turret is already selected, unselect it
Expand All @@ -195,6 +191,7 @@ public void clicked(InputEvent event, float x, float y) {

// You can change the button appearance to indicate selection
}
click.play(0.4f);
}
});

Expand All @@ -220,11 +217,12 @@ public void clicked(InputEvent event, float x, float y) {
float turretDescriptionLabelX = Gdx.graphics.getWidth() - turretDescriptionLabel.getWidth() - 11;
float turretDescriptionLabelY = Gdx.graphics.getHeight() - descriptionLabel.getHeight() - turretDescriptionLabel.getHeight() - 7; // Adjusted vertical position

// Set the position for turretDescriptionLabel
// Set the position for turretDescriptionLabel
turretDescriptionLabel.setPosition(turretDescriptionLabelX, turretDescriptionLabelY);
descText.setPosition(turretDescriptionLabelX + 18, turretDescriptionLabelY + 70);
descText.setPosition(turretDescriptionLabelX + 18, turretDescriptionLabelY + 65);

// Add the actors to the stage
// Add the actors to the stage
stage.addActor(backButton);
stage.addActor(turretDescriptionLabel);
stage.addActor(descriptionLabel);
stage.addActor(descText);
Expand All @@ -240,8 +238,8 @@ public void clicked(InputEvent event, float x, float y) {
music.setVolume(0.4f);
music.setLooping(true);
music.play();

}

@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Expand Down Expand Up @@ -333,7 +331,7 @@ public void exit(InputEvent event, float x, float y, int pointer, com.badlogic.g
* Updates the description label
*/
private void updateDescriptionLabel() {
descriptionLabel.setText("Description: " + turretDescription);
descriptionLabel.setText("Info: " + turretDescription);
}

/**
Expand All @@ -343,13 +341,23 @@ private void updateDescriptionText() {
descText.setText(turretDescriptionText);
}

public void loadSounds() {
ServiceLocator.getResourceService().loadSounds(sounds);
ServiceLocator.getResourceService().loadAll();
click = ServiceLocator.getResourceService().getAsset(sounds[0], Sound.class);
}

public void unloadSounds() {
ServiceLocator.getResourceService().unloadAssets(sounds);
}
/**
* Disposes of the stage
*/
@Override
public void dispose() {
stage.dispose();
music.dispose();
unloadSounds();
}

}
Loading