Skip to content

Commit

Permalink
fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamad11Dab committed Oct 15, 2023
2 parents 3add298 + b5e2cc3 commit 26995f3
Show file tree
Hide file tree
Showing 30 changed files with 1,226 additions and 1,043 deletions.
191 changes: 191 additions & 0 deletions source/core/assets/images/ui/buttons/determination_mono_18.fnt

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions source/core/assets/images/ui/buttons/determination_mono_18_bold.fnt

Large diffs are not rendered by default.

246 changes: 158 additions & 88 deletions source/core/assets/images/ui/buttons/glass.atlas

Large diffs are not rendered by default.

332 changes: 293 additions & 39 deletions source/core/assets/images/ui/buttons/glass.json

Large diffs are not rendered by default.

Binary file modified source/core/assets/images/ui/buttons/glass.png
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 @@ -2,11 +2,10 @@

import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
Expand All @@ -16,7 +15,6 @@
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.UIComponent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
Expand All @@ -30,6 +28,7 @@ public class CurrencyDisplay extends UIComponent {
private TextButton scrapsTb;
private TextButton crystalsTb;
private Sound clickSound;
private static final String defaultFont = "determination_mono_18";

/**
* Adds actors to stage
Expand Down Expand Up @@ -64,7 +63,7 @@ private void addActors() {
private TextButton createButton(String imageFilePath, int value) {
Drawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(imageFilePath)));
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(
drawable, drawable, drawable, new BitmapFont());
drawable, drawable, drawable, getSkin().getFont(defaultFont));

// create button
TextButton tb = new TextButton(String.format("%d", value), style);
Expand Down Expand Up @@ -96,8 +95,9 @@ public void updateScrapsStats() {
* build something that costs more than the balance
*/
public void scrapBalanceFlash() {
// TODO: IMPLEMENT THIS
scrapsTb.setText("Insufficient!");
scrapsTb.addAction(Actions.repeat(2,
new SequenceAction(Actions.fadeOut(0.5f, Interpolation.bounce),
Actions.fadeIn(0.5f, Interpolation.bounce))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.csse3200.game.components.gamearea;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextTooltip;
import com.badlogic.gdx.scenes.scene2d.ui.TooltipManager;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.UIComponent;

public class EngineerCountDisplay extends UIComponent {
private Table table;
private TextButton engineerTb;
private static final String defaultFont = "determination_mono_18";

@Override
public void create() {
Expand All @@ -27,23 +29,26 @@ public void create() {
* Positions it on the stage using a table
*/
private void addActors() {
table = new Table();
Table table = new Table();
table.top().left();
table.setFillParent(true);
table.padTop(80f).padLeft(20f);

Drawable drawable = new TextureRegionDrawable(new TextureRegion(
new Texture("images/engineers/engineerBanner.png")));
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(
drawable, drawable, drawable, new BitmapFont());
drawable, drawable, drawable, getSkin().getFont(defaultFont));

String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount());
engineerTb = new TextButton(text, style);
engineerTb.setDisabled(true);
engineerTb.getLabel().setAlignment(Align.right);

engineerTb.setTouchable(Touchable.enabled);
engineerTb.pad(0, 0, 0, 50);
engineerTb.setTransform(true);
// engineerTb.setTransform(true);
TextTooltip tooltip = new TextTooltip(
"Humans left. If this reaches 0, the game ends", getSkin());
engineerTb.addListener(tooltip);

table.add(engineerTb).width(engineerTb.getWidth() * 0.5f).height(engineerTb.getHeight() * 0.5f);
stage.addActor(table);
Expand All @@ -53,8 +58,14 @@ private void addActors() {
* Updates the engineer count on the UI component
*/
public void updateCount() {
String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount());
int currentCount = ServiceLocator.getGameEndService().getEngineerCount();
String text = String.format("%d", currentCount);
engineerTb.getLabel().setText(text);
// if (currentCount < ServiceLocator.getGameEndService().getThreshold()) {
//// engineerTb.addAction(Actions.color(Color.RED, 0.5f, Interpolation.swingIn));
// engineerTb.addAction(Actions.forever(new SequenceAction(Actions.fadeOut(0.5f),
// Actions.fadeIn(0.5f))));
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
Expand All @@ -19,238 +15,19 @@
*/
public class GameAreaDisplay extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(GameAreaDisplay.class);
private static final float Z_INDEX = 2f;
// Dialog for displaying tower details

private Vector2[] towerPositions1;
private Vector2[] towerPositions2; // Store the positions of the towers
private Vector2[] towerPositions3; // Store the positions of the towers

private Dialog towerDetailsDialog1;
private Dialog towerDetailsDialog2;
private Dialog towerDetailsDialog3;// Dialog for displaying tower details
private String gameAreaName = "";
private Label title;
private int numTowers1 = 2; // Total number of towers
private int numTowers2 = 2; // Total number of towers
private int numTowers3 = 2; // Total number of towers
private Label numTowersLabel1;
private Label numTowersLabel2;
private Label numTowersLabel3;

private boolean[] towerMoved1;
private boolean[] towerMoved2;// Array of flags to track if each tower has been moved
private boolean[] towerMoved3;// Array of flags to track if each tower has been moved


public GameAreaDisplay(String gameAreaName) {
this.gameAreaName = gameAreaName;
towerPositions1 = new Vector2[2]; // Initialize for two towers
towerMoved1 = new boolean[2]; // Initialize for two towers

towerPositions2 = new Vector2[2]; // Initialize for two towers
towerMoved2 = new boolean[2]; // Initialize for two towers

towerPositions3 = new Vector2[2]; // Initialize for two towers
towerMoved3 = new boolean[2]; // Initialize for two towers

towerDetailsDialog1 = createTowerDetailsDialog(); // Create the tower details dialog
towerDetailsDialog2 = createTowerDetailsDialog(); // Create the tower details dialog
towerDetailsDialog3 = createTowerDetailsDialog(); // Create the tower details dialog
}

@Override
public void create() {
super.create();
addActors();
final Skin skin = new Skin();




Image[] towers1 = new Image[2]; // Create an array for two towers
Image[] towers2 = new Image[2]; // Create an array for two towers
Image[] towers3 = new Image[3]; // Create an array for two towers

// for (int i = 0; i < 2; i++) {
// // Use "building1" for the first tower and "building2" for the second tower
// skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
// skin.add("building1", new Texture("images/towers/wallTower.png"));
// // Load textures for building1 and building2
// towers1[i] = new Image(skin, "building1");
// towers1[i].setBounds(Gdx.graphics.getWidth() * 40f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
// // stage.addActor(towers1[i]);
//
// final int towerIndex1 = i; // Capture the index in a final variable for the listener
// towerPositions1[towerIndex1] = new Vector2(towers1[towerIndex1].getX(), towers1[towerIndex1].getY());
//
// towers1[i].addListener(new InputListener() {
// private float startX, startY;
//
// public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// startX = towers1[towerIndex1].getX();
// startY = towers1[towerIndex1].getY();
// Gdx.app.log("GameAreaDisplay", "Touch Down on Tower " + towerIndex1);
// towerDetailsDialog1.setVisible(true);
// towerDetailsDialog1.show(stage);
//
// return true; // Return true to indicate that the event was handled
// }
//
// public void touchDragged(InputEvent event, float x, float y, int pointer) {
// float deltaX = towers1[towerIndex1].getX() - startX;
// float deltaY = towers1[towerIndex1].getY() - startY;
//
// // Calculate the distance moved
// float distanceMoved = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY);
//
// // Check if the tower has been moved for a significant distance
// if (!towerMoved1[towerIndex1] && distanceMoved >= 100f) {
// // Decrement the number of towers and set the flag for this tower
// numTowers1--;
// towerMoved1[towerIndex1] = true; // Set the flag to indicate tower movement
// }
//
// // Implement dragging logic here
// towers1[towerIndex1].moveBy(x - towers1[towerIndex1].getWidth() / 2,
// y - towers1[towerIndex1].getHeight() / 2);
//
// towerPositions1[towerIndex1] = new Vector2(towers1[towerIndex1].getX(), towers1[towerIndex1].getY());
// towerDetailsDialog1.setPosition(
// towerPositions1[towerIndex1].x + towers1[towerIndex1].getWidth(),
// towerPositions1[towerIndex1].y);
//
// }
//
// public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
// towerDetailsDialog1.hide();
// }
// });
// }
// for (int i = 0; i < 2; i++) {
// // Use "building1" for the first tower and "building2" for the second tower
// skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
// skin.add("building2", new Texture("images/towers/wallTower.png"));
// towers2[i] = new Image(skin, "building2");
// towers2[i].setBounds(Gdx.graphics.getWidth() * 50f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
// stage.addActor(towers2[i]);
//
// final int towerIndex2 = i; // Capture the index in a final variable for the listener
// towerPositions2[towerIndex2] = new Vector2(towers2[towerIndex2].getX(), towers2[towerIndex2].getY());
//
// towers2[i].addListener(new InputListener() {
// private float startX, startY;
//
// public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// startX = towers2[towerIndex2].getX();
// startY = towers2[towerIndex2].getY();
// Gdx.app.log("GameAreaDisplay", "Touch Down on Tower " + towerIndex2);
// towerDetailsDialog2.setVisible(true);
// towerDetailsDialog2.show(stage);
// return true; // Return true to indicate that the event was handled
// }
//
// public void touchDragged(InputEvent event, float x, float y, int pointer) {
// float deltaX = towers2[towerIndex2].getX() - startX;
// float deltaY = towers2[towerIndex2].getY() - startY;
//
// // Calculate the distance moved
// float distanceMoved = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY);
//
// // Check if the tower has been moved for a significant distance
// if (!towerMoved2[towerIndex2] && distanceMoved >= 100f) {
// // Decrement the number of towers and set the flag for this tower
// numTowers2--;
// numTowersLabel2.setText("TowersA: " + numTowers2);
// towerMoved2[towerIndex2] = true; // Set the flag to indicate tower movement
// }
//
// // Implement dragging logic here
// towers2[towerIndex2].moveBy(x - towers2[towerIndex2].getWidth() / 2,
// y - towers2[towerIndex2].getHeight() / 2);
//
// towerPositions2[towerIndex2] = new Vector2(towers2[towerIndex2].getX(), towers2[towerIndex2].getY());
// towerDetailsDialog2.setPosition(
// towerPositions2[towerIndex2].x + towers2[towerIndex2].getWidth(),
// towerPositions2[towerIndex2].y
// );
// }
//
// public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
// towerDetailsDialog2.hide();
// }
// });
// }
//
// for (int i = 0; i < 2; i++) {
// // Use "building1" for the first tower and "building2" for the second tower
// skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
// skin.add("building3", new Texture("images/towers/mine_tower.png"));
// // Load textures for building1 and building2
// towers3[i] = new Image(skin, "building3");
// towers3[i].setBounds(Gdx.graphics.getWidth() * 60f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
// stage.addActor(towers3[i]);
//
// final int towerIndex3 = i; // Capture the index in a final variable for the listener
// towerPositions3[towerIndex3] = new Vector2(towers3[towerIndex3].getX(), towers3[towerIndex3].getY());
//
// towers3[i].addListener(new InputListener() {
// private float startX, startY;
//
// public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// startX = towers3[towerIndex3].getX();
// startY = towers3[towerIndex3].getY();
// Gdx.app.log("GameAreaDisplay", "Touch Down on Tower " + towerIndex3);
// towerDetailsDialog3.setVisible(true);
// towerDetailsDialog3.show(stage);
// return true; // Return true to indicate that the event was handled
// }
//
// public void touchDragged(InputEvent event, float x, float y, int pointer) {
// float deltaX = towers3[towerIndex3].getX() - startX;
// float deltaY = towers3[towerIndex3].getY() - startY;
//
// // Calculate the distance moved
// float distanceMoved = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY);
//
// // Check if the tower has been moved for a significant distance
// if (!towerMoved3[towerIndex3] && distanceMoved >= 100f) {
// // Decrement the number of towers and set the flag for this tower
// numTowers3--;
// numTowersLabel3.setText("TowersB: " + numTowers3);
// towerMoved3[towerIndex3] = true; // Set the flag to indicate tower movement
// }
//
// // Implement dragging logic here
// towers3[towerIndex3].moveBy(x - towers3[towerIndex3].getWidth() / 2,
// y - towers3[towerIndex3].getHeight() / 2);
//
// towerPositions3[towerIndex3] = new Vector2(towers3[towerIndex3].getX(), towers3[towerIndex3].getY());
// towerDetailsDialog3.setPosition(
// towerPositions3[towerIndex3].x + towers3[towerIndex3].getWidth(),
// towerPositions3[towerIndex3].y
// );
//
// }
//
// public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
// towerDetailsDialog3.hide();
// }
// });
// }

// Create and add the label for the number of towers
// numTowersLabel1 = new Label("TowersA: " + numTowers1, skin);
// numTowersLabel1.setPosition(Gdx.graphics.getWidth() * 41f / 100f, Gdx.graphics.getHeight() * 75f / 100f); // Adjust the position as needed
// // stage.addActor(numTowersLabel1);
//
// numTowersLabel2 = new Label("TowersA: " + numTowers2, skin);
// numTowersLabel2.setPosition(Gdx.graphics.getWidth() * 51f / 100f, Gdx.graphics.getHeight() * 75f / 100f); // Adjust the position as needed
// stage.addActor(numTowersLabel2);
//
// numTowersLabel3 = new Label("TowersB: " + numTowers3, skin);
// numTowersLabel3.setPosition(Gdx.graphics.getWidth() * 61f / 100f, Gdx.graphics.getHeight() * 75f / 100f); // Adjust the position as needed
// stage.addActor(numTowersLabel3);
}

public void render(float delta) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class MainGameActions extends Component {
private static final Logger logger = LoggerFactory.getLogger(MainGameActions.class);
private GdxGame game;
private final GdxGame game;

public MainGameActions(GdxGame game) {
this.game = game;
Expand Down
Loading

0 comments on commit 26995f3

Please sign in to comment.