v0.3.1: toolbar auto-target now actually auto-targets

This commit is contained in:
Evan Debenham 2015-07-19 02:41:44 -04:00 committed by Evan Debenham
parent 9655c5470d
commit d99e206b0e

View File

@ -22,6 +22,8 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.ui.Button; import com.watabou.noosa.ui.Button;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -77,6 +79,21 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
@Override @Override
protected void onClick() { protected void onClick() {
if (targeting) { if (targeting) {
//first try to directly target
if (new Ballistica(Dungeon.hero.pos, lastTarget.pos, Ballistica.PROJECTILE).collisionPos == lastTarget.pos) {
GameScene.handleCell(lastTarget.pos);
return;
}
//Otherwise pick nearby tiles to try and 'angle' the shot, auto-aim basically.
for (int i : Level.NEIGHBOURS9DIST2) {
if (new Ballistica(Dungeon.hero.pos, lastTarget.pos+i, Ballistica.PROJECTILE).collisionPos == lastTarget.pos){
GameScene.handleCell( lastTarget.pos+i );
return;
}
}
//couldn't find anything, just have it directly target
GameScene.handleCell( lastTarget.pos ); GameScene.handleCell( lastTarget.pos );
} else { } else {
Item item = select(slotNum); Item item = select(slotNum);