v0.2.3d: hopefully fixed bug where attack indicator would sometimes not be pressable

This commit is contained in:
Evan Debenham 2015-01-15 02:39:44 -05:00
parent 6cbb50a179
commit 61f296907f

View File

@ -33,7 +33,7 @@ public class AttackIndicator extends Tag {
private static final float ENABLED = 1.0f; private static final float ENABLED = 1.0f;
private static final float DISABLED = 0.3f; private static final float DISABLED = 0.3f;
private static float delay = 0.5f; private static float delay = 0.75f;
private static AttackIndicator instance; private static AttackIndicator instance;
@ -72,21 +72,22 @@ public class AttackIndicator extends Tag {
public void update() { public void update() {
super.update(); super.update();
if (lastTarget == null){ if (!bg.visible){
enable(false);
if (delay > 0f) delay -= Game.elapsed; if (delay > 0f) delay -= Game.elapsed;
if (delay <= 0f) active = false; if (delay <= 0f) active = false;
} else { } else {
delay = 0.5f; delay = 0.75f;
active = true; active = true;
}
if (Dungeon.hero.isAlive()) { if (Dungeon.hero.isAlive()) {
enable(Dungeon.hero.ready); enable(Dungeon.hero.ready);
} else { } else {
visible( false ); visible( false );
enable( false ); enable( false );
}
} }
} }
@ -106,12 +107,14 @@ public class AttackIndicator extends Tag {
if (candidates.isEmpty()) { if (candidates.isEmpty()) {
lastTarget = null; lastTarget = null;
} else { } else {
active = true;
lastTarget = Random.element( candidates ); lastTarget = Random.element( candidates );
updateImage(); updateImage();
flash(); flash();
} }
} else { } else {
if (!bg.visible) { if (!bg.visible) {
active = true;
flash(); flash();
} }
} }
@ -159,7 +162,7 @@ public class AttackIndicator extends Tag {
@Override @Override
protected void onClick() { protected void onClick() {
if (enabled && lastTarget != null) { if (enabled) {
Dungeon.hero.handle( lastTarget.pos ); Dungeon.hero.handle( lastTarget.pos );
} }
} }