Skip to content

Commit

Permalink
fixed tower select bug if 4 towers selected
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Oct 16, 2023
1 parent 2846aec commit db8dd72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,16 @@ private void setTowers() {

// If no towers set, populate with default towers
if (towers.isEmpty() || towers.size < 5) {
if (towers.isEmpty()) {
towers.addAll(defaultTowers);
} else {
for (TowerType tower : defaultTowers) {
if (towers.size < 5 && !towers.contains(tower, false)) {
towers.add(tower);
}
// if (towers.isEmpty()) {
// towers.addAll(defaultTowers);
// } else {
for (TowerType tower : defaultTowers) {
if (towers.size < 5 && !towers.contains(tower, true)) {
towers.add(tower);
}
}
}
ServiceLocator.setTowerTypes(towers);
}

private void createTowerButtons() {
Expand Down Expand Up @@ -289,6 +289,10 @@ public void updateLevelProgressBar() {
* depending on button selection and currency balance
*/
private void towerUpdate() {
// Check for small tower array
if (towers.size < 5) {
setTowers();
}
// no tower selected, set all to off
if (ServiceLocator.getCurrencyService().getTower() == null) {
// toggle all buttons to off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ public BuildInputComponent(Camera camera) {
Array<TowerType> defaultTowers = new Array<>();
defaultTowers.addAll(defaultTowerTypes);

if (towers.isEmpty()) {
ServiceLocator.setTowerTypes(defaultTowers);
towers = defaultTowers;
if (towers.isEmpty() || towers.size < 5) {
for (TowerType tower : defaultTowers) {
if (towers.size < 5 && !towers.contains(tower, true)) {
towers.add(tower);
}
}
}
}

Expand Down

0 comments on commit db8dd72

Please sign in to comment.