Skip to content

Commit

Permalink
Change pop up text to image, few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajiejackie committed Oct 2, 2023
1 parent a649a1b commit e23abeb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 5 additions & 5 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,16 @@ public void create() {
// spawnSplittingXenoGrunt(15, 4);
// spawnScrap();
// spawnTNTTower();
spawnWeaponTower();
// spawnWeaponTower();
// spawnGapScanners();
// spawnDroidTower();
spawnScrap();
spawnDroidTower();
spawnTNTTower();
// spawnScrap();
// spawnDroidTower();
// spawnTNTTower();
spawnIncome();

}

private void displayUI() {
Entity ui = new Entity();
ui.addComponent(new GameAreaDisplay("Box Forest"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.csse3200.game.services.ServiceLocator;
import static java.lang.Math.round;

// test
/**
* The TowerCombatTask runs the AI for the WeaponTower class. The tower will scan for targets in a straight line
* from its center point until a point at (x + maxRange, y), where x,y are the cooridinates of the tower's center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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.scenes.scene2d.ui.Image;
import com.csse3200.game.ai.tasks.AITaskComponent;
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.areas.ForestGameArea;
Expand Down Expand Up @@ -136,7 +137,7 @@ private Table createUpgradeTable(Entity turretEntity) {
turretEntity.getComponent(CombatStatsComponent.class).setHealth(5); // for testing
int attack = turretEntity.getComponent(CombatStatsComponent.class).getBaseAttack();
float fireRate = turretEntity.getComponent(UpgradableStatsComponent.class).getAttackRate();
Label healthLabel = new Label(String.format("Health:%d/%d", currentHealth, maxHealth), createLabelStyle());
Label healthLabel = new Label(String.format("%d/%d", currentHealth, maxHealth), createLabelStyle());
Label attackLabel = new Label(String.format("Attack: %d", attack), createLabelStyle());
Label fireRateLabel = new Label(String.format("Fire Rate: %.2f", fireRate), createLabelStyle());
TextButton closeButton = new TextButton("X", style);
Expand All @@ -149,6 +150,11 @@ public void clicked(InputEvent event, float x, float y) {
}
});

// Create an Image for the health icon
Drawable healthIconDrawable = new TextureRegionDrawable(new TextureRegion(new Texture("images/heart.png")));
Image healthIconImage = new Image(healthIconDrawable);


TextButton upgradeHealth = new TextButton("+H", style);
upgradeHealth.addListener(new ClickListener() {
@Override
Expand All @@ -162,7 +168,7 @@ public void clicked(InputEvent event, float x, float y) {
turretEntity.getComponent(TowerUpgraderComponent.class).upgradeTower(TowerUpgraderComponent.UPGRADE.MAXHP, 10);
int currentHealth = turretEntity.getComponent(CombatStatsComponent.class).getHealth();
int maxHealth = turretEntity.getComponent(CombatStatsComponent.class).getMaxHealth();
healthLabel.setText(String.format("Health:%d/%d", currentHealth, maxHealth));
healthLabel.setText(String.format("%d/%d", currentHealth, maxHealth));
}
}
});
Expand Down Expand Up @@ -214,7 +220,7 @@ public void clicked(InputEvent event, float x, float y) {
ServiceLocator.getCurrencyService().getDisplay().updateScrapsStats();
turretEntity.getComponent(TowerUpgraderComponent.class).upgradeTower(TowerUpgraderComponent.UPGRADE.REPAIR, 0);
int currentHealth = turretEntity.getComponent(CombatStatsComponent.class).getHealth();
healthLabel.setText(String.format("Health:%d/%d", currentHealth, maxHealth));
healthLabel.setText(String.format("%d/%d", currentHealth, maxHealth));
}
}
});
Expand All @@ -223,6 +229,7 @@ public void clicked(InputEvent event, float x, float y) {
upgradeTable.row();

innerUpgradeTable.row();
innerUpgradeTable.add(healthIconImage).padRight(5); // Add health icon
innerUpgradeTable.add(healthLabel).expandX().left();
innerUpgradeTable.row();
if (attack != 0) {
Expand Down

0 comments on commit e23abeb

Please sign in to comment.