v1.4.0: fixed wait/pickup action not working if item can't be collected
This commit is contained in:
@@ -744,6 +744,7 @@ public class Hero extends Char {
|
|||||||
if (sprite.looping()) sprite.idle();
|
if (sprite.looping()) sprite.idle();
|
||||||
curAction = null;
|
curAction = null;
|
||||||
damageInterrupt = true;
|
damageInterrupt = true;
|
||||||
|
waitOrPickup = false;
|
||||||
ready = true;
|
ready = true;
|
||||||
|
|
||||||
AttackIndicator.updateState();
|
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 ) {
|
private boolean actPickUp( HeroAction.PickUp action ) {
|
||||||
int dst = action.dst;
|
int dst = action.dst;
|
||||||
if (pos == dst) {
|
if (pos == dst) {
|
||||||
@@ -888,8 +893,12 @@ public class Hero extends Char {
|
|||||||
curAction = null;
|
curAction = null;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
//
|
||||||
|
if (waitOrPickup) {
|
||||||
|
spendAndNext(TIME_TO_REST);
|
||||||
|
|
||||||
//allow the hero to move between levels even if they can't collect the item
|
//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));
|
return actTransition(new HeroAction.LvlTransition(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ public class Toolbar extends Component {
|
|||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
if (Dungeon.hero.ready && !GameScene.cancel()) {
|
if (Dungeon.hero.ready && !GameScene.cancel()) {
|
||||||
|
Dungeon.hero.waitOrPickup = true;
|
||||||
if (Dungeon.level.heaps.get(Dungeon.hero.pos) != null
|
if (Dungeon.level.heaps.get(Dungeon.hero.pos) != null
|
||||||
&& Dungeon.hero.handle(Dungeon.hero.pos)){
|
&& Dungeon.hero.handle(Dungeon.hero.pos)){
|
||||||
Dungeon.hero.next();
|
Dungeon.hero.next();
|
||||||
|
|||||||
Reference in New Issue
Block a user