From 06aa051410aa8856f34f8051e0fa85b82a1c8382 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 27 Apr 2015 15:54:41 -0400 Subject: [PATCH] v0.3.0: added a safety check to danger indicator --- .../ui/DangerIndicator.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/DangerIndicator.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/DangerIndicator.java index 7830a0bcf..2b4df98a6 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/DangerIndicator.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/DangerIndicator.java @@ -93,14 +93,16 @@ public class DangerIndicator extends Tag { @Override protected void onClick() { - - Mob target = Dungeon.hero.visibleEnemy( enemyIndex++ ); - - HealthIndicator.instance.target( target == HealthIndicator.instance.target() ? null : target ); - - if (Dungeon.hero.curAction == null) { - Camera.main.target = null; - Camera.main.focusOn(target.sprite); - } + if (Dungeon.hero.visibleEnemies() > 0) { + + Mob target = Dungeon.hero.visibleEnemy(enemyIndex++); + + HealthIndicator.instance.target(target == HealthIndicator.instance.target() ? null : target); + + if (Dungeon.hero.curAction == null) { + Camera.main.target = null; + Camera.main.focusOn(target.sprite); + } + } } }