Skip to content

Commit

Permalink
modified tower build to deselect after a tower placement
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Oct 9, 2023
1 parent 7c2c9b0 commit 8a75052
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Array;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.TowerFactory;
import com.csse3200.game.screens.TowerType;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashSet;
import java.util.Set;

/**
* Displays a button to represent the remaining mobs left in the current wave and a button to skip to the next wave.
Expand All @@ -40,8 +31,6 @@ public class UIElementsDisplay extends UIComponent {
};
private Sound click;
private Sound hover;
// private TextButton remainingMobsButton = new ButtonFactory().createButton("Mobs left:");
// private final TextButton timerButton = new ButtonFactory().createButton("Next wave:");
private TextButton remainingMobsButton;
private TextButton timerButton;
private final int timer = 110;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public void buildTower(int x, int y) {

long soundId = buildSound.play();
buildSound.setVolume(soundId, 0.4f);

// deselect the tower after building
ServiceLocator.getCurrencyService().setTowerType(null);
} else {
// play a sound to indicate an invalid action
long soundId = errorSound.play();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public CurrencyDisplay getDisplay() {
return display;
}

/**
* Sets the tower type to build - triggered by pressing a tower build button in-game
* newTower can be a towertype or a null value to indicate clearing the value?
* @param newTower The towertype to be set for building, null if deselecting
*/
public void setTowerType(TowerType newTower) {
if (tower == newTower) {
tower = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//package com.csse3200.game.input;
//
//import com.badlogic.gdx.Gdx;
//import com.badlogic.gdx.Graphics;
//import com.badlogic.gdx.graphics.g2d.TextureAtlas;
//import com.badlogic.gdx.maps.tiled.TiledMap;
//import com.badlogic.gdx.math.Vector2;
//import com.csse3200.game.GdxGame;
//import com.csse3200.game.components.CameraComponent;
//import com.csse3200.game.currency.Currency;
//import com.csse3200.game.entities.Entity;
Expand Down Expand Up @@ -58,6 +61,9 @@
//
// @BeforeEach
// void setup() {
// Gdx.graphics = mock(Graphics.class);
// when(Gdx.graphics.getDeltaTime()).thenReturn(10f);
//
// GameTime gameTime = mock(GameTime.class);
// CameraComponent camera = mock(CameraComponent.class);
// when(gameTime.getDeltaTime()).thenReturn(0.02f);
Expand All @@ -69,7 +75,8 @@
//
// CurrencyService currencyService = new CurrencyService();
// ResourceService resourceService = new ResourceService();
// MapService mapService = new MapService(camera);
// MapService mapService = mock(MapService.class);
// when(mapService.getComponent().tileToWorldPosition(0,0)).thenReturn(new Vector2(0,0));
// EntityService entityService = new EntityService();
//
// ServiceLocator.registerResourceService(resourceService);
Expand Down

0 comments on commit 8a75052

Please sign in to comment.