Skip to content

Commit

Permalink
Merge branch 'Team-5--Engineer-Bug-Fix' of https://github.com/UQcsse3…
Browse files Browse the repository at this point in the history
…200/2023-studio-3 into Team-5--Engineer-Bug-Fix
  • Loading branch information
ryandmcneilly committed Oct 16, 2023
2 parents b4128ea + 5321096 commit b67d1e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class EngineerCombatTask extends DefaultTask implements PriorityTask {
// The Engineer's attributes.
private final float maxRange; // The maximum range of the Engineer's weapon.
// weaponCapacity is the number of shots fired before the engineer has to reload
private static final int weaponCapacity = 10;
private static final int WEAPON_CAPACITY = 10;
private int shotsFired = 0; // Tracks the number of shots fired in the current cycle

private Vector2 engineerPosition = new Vector2(10, 50); // Placeholder value for the Engineer's position.
Expand Down Expand Up @@ -110,7 +110,7 @@ public void updateEngineerState() {
owner.getEntity().getEvents().trigger(IDLE_RIGHT);
engineerState = STATE.IDLE_RIGHT;
} else {
if (shotsFired <= weaponCapacity) {
if (shotsFired <= WEAPON_CAPACITY) {
owner.getEntity().getEvents().trigger(FIRING);
owner.getEntity().getEvents().trigger(ENGINEER_PROJECTILE_FIRED);
// this might be changed to an event which gets triggered everytime the tower enters the firing state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ScannerTask extends DefaultTask implements PriorityTask {
private boolean mobs = false;

// track the number of engineers spawned.
private static final int maxEngineers = ServiceLocator.getGameEndService().getEngineerCount();
private static final int MAX_ENGINEERS = ServiceLocator.getGameEndService().getEngineerCount();


/**
Expand Down Expand Up @@ -69,7 +69,7 @@ public void update() {
scan();
if (!towers && !engineers && mobs) {
// spawn engineers now
if (ServiceLocator.getGameEndService().getNumSpawnedEngineers() < maxEngineers) {
if (ServiceLocator.getGameEndService().getNumSpawnedEngineers() < MAX_ENGINEERS) {
Entity engineer = EngineerFactory.createEngineer();

engineer.setPosition(new Vector2((int)(selfPosition.x + 1),(int) selfPosition.y));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ public class EngineerInputComponent extends InputComponent {
private EntityService entityService;

public Entity selectedEngineer = null;
private boolean moveClicked = false;

private final String OUTLINE_STRING = "_outline";

public EngineerInputComponent(Game game, Camera camera) {
this.game = game;
this.camera = camera;
this.entityService = ServiceLocator.getEntityService();
}

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Vector3 worldCoordinates = new Vector3((float) screenX , (float) screenY, 0);
Vector3 worldCoordinates = new Vector3(screenX , screenY, 0);
camera.unproject(worldCoordinates);
Vector2 cursorPosition = new Vector2(worldCoordinates.x, worldCoordinates.y);
camera.project(worldCoordinates);
Expand Down Expand Up @@ -100,11 +102,11 @@ private void switchOutline(Entity engineer) {
AnimationRenderComponent animator = engineer.getComponent(AnimationRenderComponent.class);
String currentAnimation = animator.getCurrentAnimation();
HumanAnimationController controller = engineer.getComponent(HumanAnimationController.class);
if (currentAnimation.contains("_outline")) {
if (currentAnimation.contains(OUTLINE_STRING)) {
animator.startAnimation(currentAnimation.substring(0, currentAnimation.lastIndexOf('_')));
controller.setClicked(false);
} else {
animator.startAnimation(currentAnimation + "_outline");
animator.startAnimation(currentAnimation + OUTLINE_STRING);
controller.setClicked(true);
}
}
Expand All @@ -126,9 +128,4 @@ public void moveEngineer(Vector2 cursorPosition) {
Vector2 dest = cursorPosition.add(offset);
wander.startMoving(dest);
}

public void setMoveClicked(boolean moveClicked) {
this.moveClicked = moveClicked;
}

}

0 comments on commit b67d1e7

Please sign in to comment.