v1.4.0: fixed wait/pickup action not working if item can't be collected

This commit is contained in:
Evan Debenham
2022-08-02 13:05:55 -04:00
parent 59d8e81052
commit adc33890f8
2 changed files with 11 additions and 1 deletions

View File

@@ -744,6 +744,7 @@ public class Hero extends Char {
if (sprite.looping()) sprite.idle();
curAction = null;
damageInterrupt = true;
waitOrPickup = false;
ready = true;
AttackIndicator.updateState();
@@ -858,6 +859,10 @@ public class Hero extends Char {
}
}
//used to keep track if the wait/pickup action was used
// so that the hero spends a turn even if the fail to pick up an item
public boolean waitOrPickup = false;
private boolean actPickUp( HeroAction.PickUp action ) {
int dst = action.dst;
if (pos == dst) {
@@ -888,8 +893,12 @@ public class Hero extends Char {
curAction = null;
} else {
//
if (waitOrPickup) {
spendAndNext(TIME_TO_REST);
//allow the hero to move between levels even if they can't collect the item
if (Dungeon.level.getTransition(pos) != null){
} else if (Dungeon.level.getTransition(pos) != null){
return actTransition(new HeroAction.LvlTransition(pos));
}

View File

@@ -249,6 +249,7 @@ public class Toolbar extends Component {
@Override
protected void onClick() {
if (Dungeon.hero.ready && !GameScene.cancel()) {
Dungeon.hero.waitOrPickup = true;
if (Dungeon.level.heaps.get(Dungeon.hero.pos) != null
&& Dungeon.hero.handle(Dungeon.hero.pos)){
Dungeon.hero.next();