diff --git a/source/core/assets/images/turret-select/imageedit_2_8132799771.png b/source/core/assets/images/turret-select/imageedit_2_8132799771.png new file mode 100644 index 000000000..6fafcf62f Binary files /dev/null and b/source/core/assets/images/turret-select/imageedit_2_8132799771.png differ diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java index 5f3a12996..33e22aeaf 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java @@ -18,6 +18,7 @@ import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.ui.UIComponent; import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import org.w3c.dom.Text; /** * A UI component for displaying the currency owned @@ -28,6 +29,7 @@ public class CurrencyDisplay extends UIComponent { private TextButton scrapsTb; private TextButton crystalsTb; private Sound clickSound; + private TextButton test; /** * Adds actors to stage @@ -53,9 +55,11 @@ private void addActors() { ServiceLocator.getCurrencyService().getScrap().getAmount()); crystalsTb = createButton("images/economy/crystalBanner.png", ServiceLocator.getCurrencyService().getCrystal().getAmount()); + test = createButton("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", 100); table.add(scrapsTb).width(scrapsTb.getWidth() * 0.5f).height(scrapsTb.getHeight() * 0.5f); table.add(crystalsTb).width(crystalsTb.getWidth() * 0.5f).height(crystalsTb.getHeight() * 0.5f); + table.add(test).width(test.getWidth() * 0.5f).height(test.getHeight() * 0.5f); stage.addActor(table); } @@ -69,7 +73,7 @@ private TextButton createButton(String imageFilePath, int value) { tb.setDisabled(true); tb.getLabel().setAlignment(Align.right); - tb.pad(0, 0, 0, 50); + tb.pad(0, 0, 0, 0); tb.setTransform(true); return tb; 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 1dd3eadf5..7b1dcd525 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -1,19 +1,19 @@ package com.csse3200.game.screens; public enum TowerType { - WEAPON("images/towers/turret_deployed.png", "Weapon Tower", + WEAPON("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "Weapon Tower", "The Weapon Tower is a simple and basic turret that fires rapid shots at enemies dealing damage over time."), - TNT("images/towers/turret_deployed.png", "TNT Tower", + TNT("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "TNT Tower", "The TNT Tower launches explosive projectiles, dealing area damage to groups of enemies."), - DROID("images/towers/turret_deployed.png", "Droid Tower", + DROID("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "Droid Tower", "Droid Towers deploy robotic helpers that assist in combat and provide support to nearby turrets."), - WALL("images/towers/turret_deployed.png", "Wall Tower", + WALL("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "Wall Tower", "The Wall Tower creates barriers to block enemy paths, slowing down their progress."), - FIRE("images/towers/turret_deployed.png", "Fire Tower", + FIRE("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "Fire Tower", "The Fire Tower emits flames, causing damage over time to enemies caught in its fiery radius."), - STUN("images/towers/turret_deployed.png", "Stun Tower", + STUN("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "Stun Tower", "The Stun Tower releases electric shocks that temporarily immobilize and damage enemies."), - INCOME("images/towers/turret_deployed.png", "Income Tower", + INCOME("images/ui/Sprites/UI_Glass_Frame_Standard_01a.png", "Income Tower", "The Income Tower generates additional in-game currency over time."); private final String imagePath; 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 d120d8854..e10f07dbc 100644 --- a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java @@ -3,9 +3,12 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.ScreenAdapter; import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Pixmap; 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; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Label; @@ -13,11 +16,15 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.scenes.scene2d.utils.Drawable; +import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; +import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.csse3200.game.GdxGame; import com.badlogic.gdx.scenes.scene2d.ui.Image; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.w3c.dom.Text; import java.util.*; @@ -92,59 +99,21 @@ public void clicked(InputEvent event, float x, float y) { Table turretTable = new Table(); turretTable.center(); // Center the contents of the nested table + Pixmap pixmap200 = new Pixmap(Gdx.files.internal(String.valueOf(Gdx.files.internal(turret.getImagePath())))); + Pixmap pixmap100 = new Pixmap(150, 150, pixmap200.getFormat()); + pixmap100.drawPixmap(pixmap200, + 0, 0, pixmap200.getWidth(), pixmap200.getHeight(), + 0, 0, pixmap100.getWidth(), pixmap100.getHeight() + ); + // Load the turret image - Texture turretTexture = new Texture(Gdx.files.internal(turret.getImagePath())); + Texture turretTexture = new Texture(pixmap100); Image turretImage = new Image(turretTexture); - + TextButton button = createButton("images/turret-select/imageedit_2_8132799771.png", + "images/ui/Sprites/UI_Glass_Frame_Lite_01a.png", 100); // Add the image to the nested table - turretTable.add(turretImage).pad(10).row(); - - // Create a label for the turret description - Label turretDescriptionLabel = new Label(turret.getDescription(), skin); - turretDescriptionLabel.setWrap(true); // Wrap text if it's too long - - // Add the description label to the nested table - turretTable.add(turretDescriptionLabel).center().width(200).pad(10).row(); // Adjust width if needed - - // Create a TextButton for the turret name - TextButton turretButton = new TextButton(turret.getTowerName(), skin); - turretButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - logger.info(String.valueOf(selectedTurrets.size())); - if (selectedTurrets.size() > MAX_SELECTED_TURRETS) { - message.setText("You can only select up to 5 turrets."); - } else { - message.setText("Select your turrets"); - } - if (selectedTurrets.contains(turret)) { - // Turret is already selected, unselect it - selectedTurrets.remove(turret); - // You can also change the button appearance to indicate unselection - logger.info(selectedTurrets.toString()); - turretsPicked.setText("Turrets picked: " + selectedTurrets.toString()); - } else if (selectedTurrets.size() == MAX_SELECTED_TURRETS) { - // Turret is not selected, but the max number of turrets has been reached - message.setText("You can only select up to 5 turrets."); - } else if (selectedTurrets.size() < MAX_SELECTED_TURRETS) { - // Turret is not selected, select it - selectedTurrets.add(turret); - turretsPicked.setText("Turrets picked: " + selectedTurrets.toString()); - logger.info(selectedTurrets.toString()); - } - else { - // Turret is not selected, select it - selectedTurrets.add(turret); - turretsPicked.setText("Turrets picked: " + selectedTurrets.toString()); - //logger.info(selectedTurrets.toString()); - - // You can change the button appearance to indicate selection - } - } - }); - - // Add the turret name button to the nested table - turretTable.add(turretButton).center(); + //turretTable.add(turretImage).pad(10).row(); + turretTable.add(button).pad(10).row(); // Add the nested table to the main table table.add(turretTable).pad(10).center(); @@ -161,6 +130,7 @@ public void clicked(InputEvent event, float x, float y) { // Centered the "continue" button table.add(confirmButton).center().colspan(4).padBottom(20).row(); + // Center the table within the stage table.center(); stage.addActor(table); @@ -178,6 +148,44 @@ public void render(float delta) { stage.draw(); } + private TextButton createButton(String defaultImageFilePath, String alternateImageFilePath, int cost) { + Drawable defaultDrawable = new TextureRegionDrawable(new TextureRegion(new Texture(defaultImageFilePath))); + Drawable alternateDrawable = new TextureRegionDrawable(new TextureRegion(new Texture(alternateImageFilePath))); + + TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle(); + buttonStyle.font = new BitmapFont(); // Set your desired font + buttonStyle.up = defaultDrawable; // Default state + + // Create button + TextButton tb = new TextButton(String.format("%d", cost), buttonStyle); + + // Add click listener to toggle the image + final boolean[] isDefaultImage = {true}; // Keep track of the image state + + tb.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + + // Toggle the image + if (isDefaultImage[0]) { + tb.getStyle().up = alternateDrawable; + } else { + tb.getStyle().up = defaultDrawable; + } + + // Update the image state + isDefaultImage[0] = !isDefaultImage[0]; + } + }); + + tb.setDisabled(true); + + return tb; + } + + + public List getTurretList() { return turretList; } diff --git a/source/core/src/main/com/csse3200/game/screens/Turrets.java b/source/core/src/main/com/csse3200/game/screens/Turrets.java new file mode 100644 index 000000000..dcd126fef --- /dev/null +++ b/source/core/src/main/com/csse3200/game/screens/Turrets.java @@ -0,0 +1,8 @@ +package com.csse3200.game.screens; + +import com.badlogic.gdx.Gdx; + +public class Turrets { + public final static int[] BASIC = { + }; +}