Skip to content

Commit

Permalink
Fixed moving to be smoother, removed the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandmcneilly committed Oct 14, 2023
1 parent 74d1190 commit 9d33fc9
Showing 1 changed file with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,16 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) {
// Case when engineer is not clicked
if (engineer == null || engineer.getComponent(HumanAnimationController.class) == null) {
if (selectedEngineer != null) {
// Clicked a tile with an engineer selected and clicked on not an engineer
moveEngineer(cursorPosition);
return true;
} else {
// Clicked a tile with no engineer selected or engineer on the tile
return false;
}
}
// Case when engineer is clicked
AnimationRenderComponent animator = engineer.getComponent(AnimationRenderComponent.class);
String currentAnimation = animator.getCurrentAnimation();
HumanAnimationController controller = engineer.getComponent(HumanAnimationController.class);

if (currentAnimation.contains("_outline")) {
animator.startAnimation(currentAnimation.substring(0, currentAnimation.lastIndexOf('_')));
controller.setClicked(false);
} else {
animator.startAnimation(currentAnimation + "_outline");
controller.setClicked(true);
}

// Selecting itself - deselecting
if (engineer.equals(selectedEngineer)) {
this.getWanderTask().setSelected(false);
selectedEngineer = null;
return true;
}

// Selecting different engineer
selectedEngineer = engineer;
this.getWanderTask().setSelected(true);
switchEngineer(engineer);
return true;
}

Expand All @@ -99,6 +80,40 @@ private void manualShoot() {
wander.startCombat();
}

private void switchEngineer(Entity engineer) {
if (engineer.equals(this.selectedEngineer)) {
this.getWanderTask().setSelected(false);
this.selectedEngineer = null;
switchOutline(engineer);
}
else if (selectedEngineer == null) {
this.selectedEngineer = engineer;
switchOutline(engineer);
this.getWanderTask().setSelected(true);

} else {
this.getWanderTask().setSelected(false);
switchOutline(this.selectedEngineer);
switchOutline(engineer);
this.selectedEngineer = engineer;
this.getWanderTask().setSelected(true);

}
}

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")) {
animator.startAnimation(currentAnimation.substring(0, currentAnimation.lastIndexOf('_')));
controller.setClicked(false);
} else {
animator.startAnimation(currentAnimation + "_outline");
controller.setClicked(true);
}
}

private HumanWanderTask getWanderTask() {
AITaskComponent movementTask = selectedEngineer.getComponent(AITaskComponent.class);
return movementTask.getTask(HumanWanderTask.class);
Expand Down

0 comments on commit 9d33fc9

Please sign in to comment.