Skip to content

Commit

Permalink
Fix code smells at GameAreaDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhatminh451 committed Oct 11, 2023
1 parent 2e1107b commit e49d687
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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 static final String DEFAULT_STYLE = "default";

private Vector2[] towerPositions1;
private Vector2[] towerPositions2; // Store the positions of the towers
Expand Down Expand Up @@ -65,16 +66,13 @@ public void 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(DEFAULT_STYLE, 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");
Expand Down Expand Up @@ -129,7 +127,7 @@ public void create() {
// }
// 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(DEFAULT_STYLE, 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);
Expand Down Expand Up @@ -184,7 +182,7 @@ public void create() {
//
// 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(DEFAULT_STYLE, 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");
Expand Down Expand Up @@ -268,10 +266,10 @@ private Dialog createTowerDetailsDialog() {
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = new BitmapFont();
labelStyle.fontColor = Color.WHITE;
skin.add("default", labelStyle);
skin.add(DEFAULT_STYLE, labelStyle);

// Create the dialog using the registered label style
Dialog dialog = new Dialog("Tower Details", skin,"default");
Dialog dialog = new Dialog("Tower Details", skin,DEFAULT_STYLE);
dialog.text("Health: 100"); // Set tower health here
dialog.getContentTable().row();
dialog.text("Attack: 50"); // Set tower attack here
Expand All @@ -280,7 +278,7 @@ private Dialog createTowerDetailsDialog() {
return dialog;
}
private void addActors() {
title = new Label(this.gameAreaName, skin, "default");
title = new Label(this.gameAreaName, skin, DEFAULT_STYLE);
stage.addActor(title);
}

Expand Down

0 comments on commit e49d687

Please sign in to comment.