v0.3.0: reworked the ballistica system

This commit is contained in:
Evan Debenham
2015-03-26 22:43:23 -04:00
parent 9c1cfc095f
commit 99f853c190
27 changed files with 230 additions and 162 deletions
@@ -64,19 +64,14 @@ public class Eye extends Mob {
return 10;
}
private int hitCell;
private Ballistica beam;
@Override
protected boolean canAttack( Char enemy ) {
hitCell = Ballistica.cast( pos, enemy.pos, true, false );
for (int i=1; i < Ballistica.distance; i++) {
if (Ballistica.trace[i] == enemy.pos) {
return true;
}
}
return false;
beam = new Ballistica( pos, enemy.pos, Ballistica.STOP_TERRAIN);
return beam.subPath(1, beam.dist).contains(enemy.pos);
}
@Override
@@ -96,14 +91,14 @@ public class Eye extends Mob {
boolean rayVisible = false;
for (int i=0; i < Ballistica.distance; i++) {
if (Dungeon.visible[Ballistica.trace[i]]) {
for (int i : beam.subPath(0, beam.dist)) {
if (Dungeon.visible[i]) {
rayVisible = true;
}
}
if (rayVisible) {
sprite.attack( hitCell );
sprite.attack( beam.collisionPos );
return false;
} else {
attack( enemy );
@@ -114,10 +109,8 @@ public class Eye extends Mob {
@Override
public boolean attack( Char enemy ) {
for (int i=1; i < Ballistica.distance; i++) {
int pos = Ballistica.trace[i];
for (int pos : beam.subPath(1, beam.dist)) {
Char ch = Actor.findChar( pos );
if (ch == null) {
continue;
@@ -66,7 +66,7 @@ public class Goo extends Mob {
pumpedUp = 0;
for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i];
if (j >= 0 && j <= 1023 && Level.passable[j])
if (Level.insideMap(j) && Level.passable[j])
CellEmitter.get(j).burst(ElmoParticle.FACTORY, 10);
}
Sample.INSTANCE.play( Assets.SND_BURNING );
@@ -122,7 +122,7 @@ public class Goo extends Mob {
((GooSprite)sprite).pumpUp();
for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i];
if (j >= 0 && j <= 1023 && Level.passable[j])
if (Level.insideMap(j) && Level.passable[j])
GameScene.add(Blob.seed(j, 2, GooWarn.class));
}
pumpedUp++;
@@ -68,7 +68,8 @@ public class Scorpio extends Mob {
@Override
protected boolean canAttack( Char enemy ) {
return !Level.adjacent( pos, enemy.pos ) && Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos;
Ballistica attack = new Ballistica( pos, enemy.pos, Ballistica.PROJECTILE);
return !Level.adjacent( pos, enemy.pos ) && attack.collisionPos == enemy.pos;
}
@Override
@@ -72,7 +72,7 @@ public class Shaman extends Mob implements Callback {
@Override
protected boolean canAttack( Char enemy ) {
return Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos;
return new Ballistica( pos, enemy.pos, Ballistica.MAGIC_BOLT).collisionPos == enemy.pos;
}
@Override
@@ -92,11 +92,12 @@ public class Succubus extends Mob {
private void blink( int target ) {
int cell = Ballistica.cast( pos, target, true, true );
if (Actor.findChar( cell ) != null && Ballistica.distance > 1) {
cell = Ballistica.trace[Ballistica.distance - 2];
}
Ballistica route = new Ballistica( pos, target, Ballistica.PROJECTILE);
int cell = route.collisionPos;
//can't occupy the same cell as another char, so move back one.
if (Actor.findChar( cell ) != null && cell != this.pos)
cell = route.path.get(route.dist-1);
WandOfBlink.appear( this, cell );
@@ -115,7 +115,7 @@ public class Tengu extends Mob {
@Override
protected boolean canAttack( Char enemy ) {
return Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos;
return new Ballistica( pos, enemy.pos, Ballistica.PROJECTILE).collisionPos == enemy.pos;
}
@Override
@@ -74,7 +74,7 @@ public class Warlock extends Mob implements Callback {
@Override
protected boolean canAttack( Char enemy ) {
return Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos;
return new Ballistica( pos, enemy.pos, Ballistica.MAGIC_BOLT).collisionPos == enemy.pos;
}
protected boolean doAttack( Char enemy ) {
@@ -326,7 +326,7 @@ public class Yog extends Mob {
@Override
protected boolean canAttack( Char enemy ) {
return Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos;
return new Ballistica( pos, enemy.pos, Ballistica.MAGIC_BOLT).collisionPos == enemy.pos;
}
@Override
@@ -467,7 +467,8 @@ public class Ghost extends NPC {
@Override
protected boolean canAttack( Char enemy ) {
if (!Level.adjacent(pos, enemy.pos) && Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos){
Ballistica attack = new Ballistica( pos, enemy.pos, Ballistica.PROJECTILE );
if (!Level.adjacent(pos, enemy.pos) && attack.collisionPos == enemy.pos){
combo++;
return true;
} else {