public int distance( Char other ) { return Dungeon.level.distance( pos, other.pos ); }
public boolean adjacent( int a, int b ) { return distance( a, b ) == 1; }
public boolean adjacent( int a, int b ) { return distance( a, b ) == 1; }
public int distance( Char other ) { return Dungeon.level.distance( pos, other.pos ); }
@Override protected Char chooseEnemy() { Char enemy = super.chooseEnemy(); //will never attack something far from the player if (enemy != null && Dungeon.level.mobs.contains(enemy) && Dungeon.level.distance(enemy.pos, Dungeon.hero.pos) <= 8){ return enemy; } else { return null; } }
@Override protected Char chooseEnemy() { Char enemy = super.chooseEnemy(); //will never attack something far from the player if (enemy != null && Dungeon.level.mobs.contains(enemy) && Dungeon.level.distance(enemy.pos, Dungeon.hero.pos) <= 8){ return enemy; } else { return null; } }
@Override public int throwPos(Hero user, int dst) { if (hasEnchant(Projecting.class, user) && !Dungeon.level.solid[dst] && Dungeon.level.distance(user.pos, dst) <= 4){ return dst; } else { return super.throwPos(user, dst); } }
@Override public int throwPos(Hero user, int dst) { if (hasEnchant(Projecting.class, user) && !Dungeon.level.solid[dst] && Dungeon.level.distance(user.pos, dst) <= 4){ return dst; } else { return super.throwPos(user, dst); } }
public Swap( Char ch1, Char ch2 ) { this.ch1 = ch1; this.ch2 = ch2; delay = Dungeon.level.distance( ch1.pos, ch2.pos ) * 0.1f; eff1 = new Effect( ch1.sprite, ch1.pos, ch2.pos ); eff2 = new Effect( ch2.sprite, ch2.pos, ch1.pos ); Sample.INSTANCE.play( Assets.SND_TELEPORT ); }
@Override protected boolean getCloser(int target) { if (alignment == Alignment.ALLY && enemy == null && buff(Corruption.class) == null){ target = Dungeon.hero.pos; } else if (enemy != null && Actor.findById(potHolder) == enemy) { target = enemy.pos; } else if (potPos != -1 && (state == WANDERING || Dungeon.level.distance(target, potPos) > 3)) this.target = target = potPos; return super.getCloser( target ); }
@Override protected boolean getCloser(int target) { if (alignment == Alignment.ALLY && enemy == null && buff(Corruption.class) == null){ target = Dungeon.hero.pos; } else if (enemy != null && Actor.findById(potHolder) == enemy) { target = enemy.pos; } else if (potPos != -1 && (state == WANDERING || Dungeon.level.distance(target, potPos) > 3)) this.target = target = potPos; return super.getCloser( target ); }
public Swap( Char ch1, Char ch2 ) { this.ch1 = ch1; this.ch2 = ch2; delay = Dungeon.level.distance( ch1.pos, ch2.pos ) * 0.1f; eff1 = new Effect( ch1.sprite, ch1.pos, ch2.pos ); eff2 = new Effect( ch2.sprite, ch2.pos, ch1.pos ); Sample.INSTANCE.play( Assets.SND_TELEPORT ); }
@Override public void onComplete( Animation anim ) { super.onComplete( anim ); //FIXME should figure out why onComplete is called constantly when an animation is paused if (visible && emitter != null && anim == idle && !paused) { emitter.burst( Speck.factory( Speck.FORGE ), 3 ); float volume = 0.2f / (Dungeon.level.distance( ch.pos, Dungeon.hero.pos )); Sample.INSTANCE.play( Assets.SND_EVOKE, volume, volume, 0.8f ); } }
@Override protected boolean getCloser( int target ) { if (fieldOfView[target] && Dungeon.level.distance( pos, target ) > 2 && delay <= 0) { blink( target ); spend( -1 / speed() ); return true; } else { delay--; return super.getCloser( target ); } }
public void jump( int from, int to, Callback callback ) { jumpCallback = callback; int distance = Dungeon.level.distance( from, to ); jumpTweener = new JumpTweener( this, worldToCamera( to ), distance * 4, distance * 0.1f ); jumpTweener.listener = this; parent.add( jumpTweener ); turnTo( from, to ); }
@Override public void onComplete( Animation anim ) { super.onComplete( anim ); //FIXME should figure out why onComplete is called constantly when an animation is paused if (visible && emitter != null && anim == idle && !paused) { emitter.burst( Speck.factory( Speck.FORGE ), 3 ); float volume = 0.2f / (Dungeon.level.distance( ch.pos, Dungeon.hero.pos )); Sample.INSTANCE.play( Assets.SND_EVOKE, volume, volume, 0.8f ); } }
public void jump( int from, int to, Callback callback ) { jumpCallback = callback; int distance = Dungeon.level.distance( from, to ); jumpTweener = new JumpTweener( this, worldToCamera( to ), distance * 4, distance * 0.1f ); jumpTweener.listener = this; parent.add( jumpTweener ); turnTo( from, to ); }
@Override protected boolean getCloser( int target ) { if (fieldOfView[target] && Dungeon.level.distance( pos, target ) > 2 && delay <= 0) { blink( target ); spend( -1 / speed() ); return true; } else { delay--; return super.getCloser( target ); } }
public boolean canReach( Char owner, int target){ if (Dungeon.level.distance( owner.pos, target ) > reachFactor(owner)){ return false; } else { boolean[] passable = BArray.not(Dungeon.level.solid, null); for (Char ch : Actor.chars()) { if (ch != owner) passable[ch.pos] = false; } PathFinder.buildDistanceMap(target, passable, reachFactor(owner)); return PathFinder.distance[owner.pos] <= reachFactor(owner); } }
public boolean canReach( Char owner, int target){ if (Dungeon.level.distance( owner.pos, target ) > reachFactor(owner)){ return false; } else { boolean[] passable = BArray.not(Dungeon.level.solid, null); for (Char ch : Actor.chars()) { if (ch != owner) passable[ch.pos] = false; } PathFinder.buildDistanceMap(target, passable, reachFactor(owner)); return PathFinder.distance[owner.pos] <= reachFactor(owner); } }