Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamad11Dab committed Oct 15, 2023
2 parents a4676f7 + ba0b4c2 commit 7f9c8c3
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ public class ForestGameArea extends GameArea {

/**
* Initialise this ForestGameArea to use the provided TerrainFactory.
*
* @requires terrainFactory != null
* @requires terrainFactory != null
*/
public ForestGameArea() {
super();
Expand Down Expand Up @@ -457,9 +456,6 @@ private void spawnProjectile(Vector2 position, short targetLayer, int space, int
public void spawnMob(String entity, GridPoint2 randomPos, int health) {
Entity mob;
switch (entity) {
case "Xeno":
mob = NPCFactory.createXenoGrunt(health);
break;
case "SplittingWaterSlime":
mob = NPCFactory.createSplittingWaterSlime(health);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
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.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
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;
Expand All @@ -17,7 +18,7 @@
public class EngineerCountDisplay extends UIComponent {
private TextButton engineerTb;
private static final String defaultFont = "determination_mono_18";

private static final float Z_INDEX = 2f;
@Override
public void create() {
super.create();
Expand Down Expand Up @@ -45,7 +46,7 @@ private void addActors() {
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);
Expand All @@ -61,11 +62,16 @@ public void updateCount() {
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))));
// }
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
public float getZIndex() {
return Z_INDEX;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.EventListener;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
Expand All @@ -29,13 +28,10 @@ public class MainGameDisplay extends UIComponent {
private final Table buttonTable = new Table();
private String[] sounds = {
"sounds/ui/click/click_01.ogg",
"sounds/ui/hover/hover_01.ogg",
"sounds/ui/open_close/open_01.ogg"
};
private Sound click;
private Sound hover;
private Sound openSound;
private Sound closeSound;
private GdxGame game;

/**
Expand Down Expand Up @@ -235,6 +231,6 @@ public void loadSounds() {
ServiceLocator.getResourceService().loadSounds(sounds);
ServiceLocator.getResourceService().loadAll();
click = ServiceLocator.getResourceService().getAsset(sounds[0], Sound.class);
openSound = ServiceLocator.getResourceService().getAsset(sounds[2], Sound.class);
openSound = ServiceLocator.getResourceService().getAsset(sounds[1], Sound.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ public class MobDodgeTask extends MobTask {
* Initialises a mob dodge task with a specified wander range, wait time, and
* priority level.
*
* @param wanderRange Distance in X and Y the entity can move from its position
* when start() is
* called.
* @param waitTime How long in seconds to wait between wandering.
* @param priority Priority level compared to other added tasks.
* @param mobType Distance in X and Y the entity can move from its position
* when start() is called.
* @param priority Priority level compared to other added tasks.
*/
public MobDodgeTask(MobType mobType, int priority) {
super(mobType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) {
logger.debug("spawning a tower at {}, {}", cursorPosition.x, cursorPosition.y);
return buildTower((int)cursorPosition.x, (int)cursorPosition.y);
} else {
// TODO: Create a tile indication of invalid placement here??
return false;
}
}
Expand Down Expand Up @@ -144,7 +143,7 @@ public boolean keyUp(int keycode) {
/**
*
* @param keycode one of the constants in {@link Input.Keys}
* @return
* @return true if the multipleBuild key is down, otherwise false
*/
public boolean keyDown(int keycode) {
if (keycode == Input.Keys.CONTROL_LEFT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public void render(float delta) {
ui.getEvents().trigger("lose");
} else if (ServiceLocator.getWaveService().isLevelCompleted()) {
// Check if all waves are completed and the level has been completed

logger.info("Main game level completed detected, go to win screen");
ui.getEvents().trigger("lose"); // needs to change to: ui.getEvents().trigger("win");
// Add something in to unlock the next planet/level?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void updateEngineerCount() {
* @return the warning threshold int
*/
public float getThreshold() {
return (float)(0.25 * STARTING_COUNT);
return (float)( STARTING_COUNT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

/**
* A simplified implementation of the Service Locator pattern:
* https://martinfowler.com/articles/injection.html#UsingAServiceLocator
* <a href="https://martinfowler.com/articles/injection.html#UsingAServiceLocator">...</a>
*
* <p>Allows global access to a few core game services.
* Warning: global access is a trap and should be used <i>extremely</i> sparingly.
* Read the wiki for details (https://github.com/UQcsse3200/game-engine/wiki/Service-Locator).
* Read the wiki for details (<a href="https://github.com/UQcsse3200/game-engine/wiki/Service-Locator">...</a>).
*/
public class ServiceLocator {
private static final Logger logger = LoggerFactory.getLogger(ServiceLocator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,13 @@ public void testCreateBaseTowerPhysicsComponentStaticBody() {
PhysicsComponent physicsComponent5 = tntTower.getComponent(PhysicsComponent.class);
PhysicsComponent physicsComponent6 = droidTower.getComponent(PhysicsComponent.class);

assertTrue(physicsComponent.getBody().getType() == BodyType.StaticBody,
"PhysicsComponent should be of type StaticBody");
assertTrue(physicsComponent1.getBody().getType() == BodyType.StaticBody,
"PhysicsComponent1 should be of type StaticBody");
assertTrue(physicsComponent2.getBody().getType() == BodyType.StaticBody,
"PhysicsComponent2 should be of type StaticBody");
assertTrue(physicsComponent3.getBody().getType() == BodyType.StaticBody,
"StunTower's PhysicsComponent should be of type StaticBody");
assertTrue(physicsComponent4.getBody().getType() == BodyType.StaticBody,
"FireTower's PhysicsComponent should be of type StaticBody");
assertTrue(physicsComponent5.getBody().getType() == BodyType.StaticBody,
"TNT tower's PhysicsComponent should be of type StaticBody");
assertTrue(physicsComponent6.getBody().getType() == BodyType.StaticBody,
"Droid Tower's PhysicsComponent should be of type StaticBody");
assertSame(physicsComponent.getBody().getType(), BodyType.StaticBody, "PhysicsComponent should be of type StaticBody");
assertSame(physicsComponent1.getBody().getType(), BodyType.StaticBody, "PhysicsComponent1 should be of type StaticBody");
assertSame(physicsComponent2.getBody().getType(), BodyType.StaticBody, "PhysicsComponent2 should be of type StaticBody");
assertSame(physicsComponent3.getBody().getType(), BodyType.StaticBody, "StunTower's PhysicsComponent should be of type StaticBody");
assertSame(physicsComponent4.getBody().getType(), BodyType.StaticBody, "FireTower's PhysicsComponent should be of type StaticBody");
assertSame(physicsComponent5.getBody().getType(), BodyType.StaticBody, "TNT tower's PhysicsComponent should be of type StaticBody");
assertSame(physicsComponent6.getBody().getType(), BodyType.StaticBody, "Droid Tower's PhysicsComponent should be of type StaticBody");
}

@Test
Expand Down Expand Up @@ -214,12 +207,10 @@ public void testWeaponTowerCombatStatsComponentAndCostComponent() {
@Test
public void testWallTowerCombatStatsComponentAndCostComponent() {

assertTrue(wallTower.getComponent(CombatStatsComponent.class).getHealth() == 300,
"Health should be 300");
assertTrue(wallTower.getComponent(CombatStatsComponent.class).getBaseAttack() == 0,
"BaseAttack should be 0");
assertTrue(wallTower.getComponent(CostComponent.class).getCost() == 45,
"Cost should be 5");
assertEquals(300, wallTower.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 20");
assertEquals(0, wallTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "BaseAttack should be 0");
assertEquals(45, wallTower.getComponent(CostComponent.class).getCost(), "Cost should be 5");


}

Expand Down

0 comments on commit 7f9c8c3

Please sign in to comment.