From c7ac03eb142aad720e519c15a84aa027bef1812e Mon Sep 17 00:00:00 2001 From: SonjaMcNeilly Date: Tue, 17 Oct 2023 13:56:01 +1000 Subject: [PATCH 1/5] Added back button and clicking sounds --- .../com/csse3200/game/screens/TowerType.java | 2 +- .../game/screens/TurretSelectionScreen.java | 54 +++++++++++-------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/TowerType.java b/source/core/src/main/com/csse3200/game/screens/TowerType.java index 11bbf590a..e5f021ddb 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -13,7 +13,7 @@ public enum TowerType { 4, "45", "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, "45", "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("Mine Tower", "income_tower", "The Income Tower generates additional in-game currency over time.", 6, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"), PIERCE("Pierce Tower", "", "The Pierce Tower fires a projectile that pierces through targets and does not dissipate upon contact.", 6, "0", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"), diff --git a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java index 1b500d615..39b2be22c 100644 --- a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java @@ -3,6 +3,7 @@ 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; @@ -37,6 +38,12 @@ public class TurretSelectionScreen extends ScreenAdapter { private Stage stage; private Label descText; private List turretList; + private final String[] sounds = { + "sounds/ui/click/click_01.ogg", + }; + private Sound click; + private Sound hoverSound; + private Sound openSound; private TextButton confirmButton; private String turretDescriptionText; @@ -71,6 +78,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(); @@ -89,30 +98,20 @@ public TurretSelectionScreen(GdxGame game) { // Restrictions can be added to the arrays i.e. map == "Forest" && level == 1 using for loop 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) { // 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(backButton); - stage.addActor(topRightTable); + message = new Label("Select up to 5 turrets", skin); - message = new Label("Select your turrets", 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 @@ -159,7 +158,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()); @@ -173,7 +172,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 turrets"); } if (selectedTurrets.contains(turret)) { // Turret is already selected, unselect it @@ -195,6 +194,7 @@ public void clicked(InputEvent event, float x, float y) { // You can change the button appearance to indicate selection } + click.play(0.4f); } }); @@ -220,11 +220,11 @@ 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); -// Add the actors to the stage + // Add the actors to the stage stage.addActor(turretDescriptionLabel); stage.addActor(descriptionLabel); stage.addActor(descText); @@ -240,8 +240,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); @@ -333,7 +333,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); } /** @@ -343,6 +343,15 @@ 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 */ @@ -350,6 +359,7 @@ private void updateDescriptionText() { public void dispose() { stage.dispose(); music.dispose(); + unloadSounds(); } } From 17329566ac58760582131dd3fd6f66924473f1fe Mon Sep 17 00:00:00 2001 From: SonjaMcNeilly Date: Tue, 17 Oct 2023 14:22:59 +1000 Subject: [PATCH 2/5] Added click sounds to every button and adjusted description text font --- .../game/screens/TurretSelectionScreen.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java index 39b2be22c..a4ed1d1e5 100644 --- a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java @@ -104,18 +104,19 @@ public TurretSelectionScreen(GdxGame game) { 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.LEVEL_SELECT); // Replace PREVIOUS_SCREEN with the appropriate screen type } }); - stage.addActor(backButton); - message = new Label("Select up to 5 turrets", skin); + message = new Label("Select up to 5 towers", skin); 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 towers = new Array<>(); @@ -130,9 +131,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); @@ -172,7 +172,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 up to 5 turrets"); + message.setText("Select up to 5 towers"); } if (selectedTurrets.contains(turret)) { // Turret is already selected, unselect it @@ -222,9 +222,10 @@ public void clicked(InputEvent event, float x, float y) { // 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 + stage.addActor(backButton); stage.addActor(turretDescriptionLabel); stage.addActor(descriptionLabel); stage.addActor(descText); From 2390ce3477b4b393e896e8d626d4ec4aa2537fc7 Mon Sep 17 00:00:00 2001 From: SonjaMcNeilly Date: Tue, 17 Oct 2023 14:24:44 +1000 Subject: [PATCH 3/5] removed unnecessary imports/variables --- .../main/com/csse3200/game/screens/TurretSelectionScreen.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java index a4ed1d1e5..5c1ca6813 100644 --- a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java @@ -6,7 +6,6 @@ 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; @@ -42,8 +41,6 @@ public class TurretSelectionScreen extends ScreenAdapter { "sounds/ui/click/click_01.ogg", }; private Sound click; - private Sound hoverSound; - private Sound openSound; private TextButton confirmButton; private String turretDescriptionText; From a1a25c29e60da47d8dbb0ef4f4e5fdc02c29178c Mon Sep 17 00:00:00 2001 From: SonjaMcNeilly Date: Tue, 17 Oct 2023 14:30:14 +1000 Subject: [PATCH 4/5] Updating tower description --- .../core/src/main/com/csse3200/game/screens/TowerType.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/TowerType.java b/source/core/src/main/com/csse3200/game/screens/TowerType.java index e5f021ddb..7b41da2e1 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -3,9 +3,9 @@ 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, "15", "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.", + 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 deploy robotic helpers that assist in combat and provide support to nearby turrets.", + 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, "45", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-selected.png"), @@ -13,7 +13,7 @@ public enum TowerType { 4, "45", "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, "45", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-selected.png"), - INCOME("Mine Tower", "income_tower", "The Income Tower generates additional in-game currency over time.", + INCOME("Mine Tower", "income_tower", "The Mine Tower generates additional in-game currency over time.", 6, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"), PIERCE("Pierce Tower", "", "The Pierce Tower fires a projectile that pierces through targets and does not dissipate upon contact.", 6, "0", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"), From e24316aabad63c7fb58c3086845b8b000d619cd9 Mon Sep 17 00:00:00 2001 From: SonjaMcNeilly Date: Tue, 17 Oct 2023 14:44:30 +1000 Subject: [PATCH 5/5] Updated costs to align with main --- .../com/csse3200/game/screens/TowerType.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/TowerType.java b/source/core/src/main/com/csse3200/game/screens/TowerType.java index 7b41da2e1..f5823ba9e 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -2,25 +2,25 @@ 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, "15", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/weapon-tower-selected.png"), + 0, "50", "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"), + 1, "50", "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"), + 2, "300", "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, "45", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-selected.png"), + 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, "45", "images/turret-select/fire-tower-default.png", "images/turret-select/fire-tower-selected.png"), + 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, "45", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-selected.png"), + 5, "500", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-selected.png"), INCOME("Mine Tower", "income_tower", "The Mine Tower generates additional in-game currency over time.", - 6, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"), + 6, "100", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"), PIERCE("Pierce Tower", "", "The Pierce Tower fires a projectile that pierces through targets and does not dissipate upon contact.", - 6, "0", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"), + 6, "400", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"), RICOCHET("Ricochet Tower", "", "The Ricochet Tower fires a projectile that upon contact does damage and changes direction", - 7, "0", "images/turret-select/ricochet-tower-default.png", "images/turret-select/ricochet-tower-selected.png"), + 7, "400", "images/turret-select/ricochet-tower-default.png", "images/turret-select/ricochet-tower-selected.png"), FIREWORK("Firework Tower", "", "The Firework Tower fires a projectile that splits on contact with its target", - 8, "0", "images/turret-select/firework-tower-default.png", "images/turret-select/firework-tower-selected.png"); + 8, "400", "images/turret-select/firework-tower-default.png", "images/turret-select/firework-tower-selected.png"); private final String towerName; private final String skinName;