diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index b353de146..2464b493b 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -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. @@ -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 diff --git a/source/core/src/main/com/csse3200/game/components/tasks/scanner/ScannerTask.java b/source/core/src/main/com/csse3200/game/components/tasks/scanner/ScannerTask.java index 7f665ee55..f04b7f2c9 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/scanner/ScannerTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/scanner/ScannerTask.java @@ -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(); /** @@ -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)); diff --git a/source/core/src/main/com/csse3200/game/input/EngineerInputComponent.java b/source/core/src/main/com/csse3200/game/input/EngineerInputComponent.java index 581a692a7..f938dc79c 100644 --- a/source/core/src/main/com/csse3200/game/input/EngineerInputComponent.java +++ b/source/core/src/main/com/csse3200/game/input/EngineerInputComponent.java @@ -24,7 +24,8 @@ 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; @@ -32,8 +33,9 @@ public EngineerInputComponent(Game game, 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); @@ -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); } } @@ -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; - } - }