Java Code Examples for com.watabou.utils.PathFinder#NEIGHBOURS9
The following examples show how to use
com.watabou.utils.PathFinder#NEIGHBOURS9 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PotionOfSnapFreeze.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void shatter(int cell) { if (Dungeon.level.heroFOV[cell]) { setKnown(); splash( cell ); Sample.INSTANCE.play( Assets.Sounds.SHATTER ); } Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class ); for (int offset : PathFinder.NEIGHBOURS9){ if (!Dungeon.level.solid[cell+offset]) { Freezing.affect( cell + offset, fire ); Char ch = Actor.findChar( cell + offset); if (ch != null){ Buff.affect(ch, Roots.class, Roots.DURATION*2f); } } } }
Example 2
Source File: PotionOfLiquidFlame.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public void shatter( int cell ) { if (Dungeon.level.heroFOV[cell]) { setKnown(); splash( cell ); Sample.INSTANCE.play( Assets.SND_SHATTER ); } for (int offset : PathFinder.NEIGHBOURS9){ if (!Dungeon.level.solid[cell+offset]) { GameScene.add(Blob.seed(cell + offset, 2, Fire.class)); } } }
Example 3
Source File: PotionOfLiquidFlame.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void shatter( int cell ) { if (Dungeon.level.heroFOV[cell]) { setKnown(); splash( cell ); Sample.INSTANCE.play( Assets.Sounds.SHATTER ); Sample.INSTANCE.play( Assets.Sounds.BURNING ); } for (int offset : PathFinder.NEIGHBOURS9){ if (!Dungeon.level.solid[cell+offset]) { GameScene.add(Blob.seed(cell + offset, 2, Fire.class)); } } }
Example 4
Source File: WandOfCorrosion.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onZap(Ballistica bolt) { CorrosiveGas gas = Blob.seed(bolt.collisionPos, 50 + 10 * buffedLvl(), CorrosiveGas.class); CellEmitter.get(bolt.collisionPos).burst(Speck.factory(Speck.CORROSION), 10 ); gas.setStrength(2 + buffedLvl()); GameScene.add(gas); Sample.INSTANCE.play(Assets.Sounds.GAS); for (int i : PathFinder.NEIGHBOURS9) { Char ch = Actor.findChar(bolt.collisionPos + i); if (ch != null) { processSoulMark(ch, chargesPerCast()); } } if (Actor.findChar(bolt.collisionPos) == null){ Dungeon.level.pressCell(bolt.collisionPos); } }
Example 5
Source File: PitfallTrap.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void activate() { if( Dungeon.bossLevel() || Dungeon.depth > 25){ GLog.w(Messages.get(this, "no_pit")); return; } DelayedPit p = Buff.affect(Dungeon.hero, DelayedPit.class, 1); p.depth = Dungeon.depth; p.pos = pos; for (int i : PathFinder.NEIGHBOURS9){ if (!Dungeon.level.solid[pos+i] || Dungeon.level.passable[pos+i]){ CellEmitter.floor(pos+i).burst(PitfallParticle.FACTORY4, 8); } } if (pos == Dungeon.hero.pos){ GLog.n(Messages.get(this, "triggered_hero")); } else if (Dungeon.level.heroFOV[pos]){ GLog.n(Messages.get(this, "triggered")); } }
Example 6
Source File: RotGardenRoom.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private static boolean validPlantPos(Level level, int pos){ if (level.map[pos] != Terrain.GRASS){ return false; } for (int i : PathFinder.NEIGHBOURS9){ if (level.findMob(pos+i) != null){ return false; } } return true; }
Example 7
Source File: ShockingTrap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public void activate() { if (Dungeon.level.heroFOV[pos]){ Sample.INSTANCE.play( Assets.SND_LIGHTNING ); } for( int i : PathFinder.NEIGHBOURS9) { if (!Dungeon.level.solid[pos + i]) { GameScene.add(Blob.seed(pos + i, 10, Electricity.class)); } } }
Example 8
Source File: Corrosion.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public int proc(Armor armor, Char attacker, Char defender, int damage) { if (Random.Int(10) == 0){ int pos = defender.pos; for (int i : PathFinder.NEIGHBOURS9){ Splash.at(pos+i, 0x000000, 5); if (Actor.findChar(pos+i) != null) Buff.affect(Actor.findChar(pos+i), Ooze.class).set( 20f ); } } return damage; }
Example 9
Source File: Corrosion.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public int proc(Armor armor, Char attacker, Char defender, int damage) { if (Random.Int(10) == 0){ int pos = defender.pos; for (int i : PathFinder.NEIGHBOURS9){ Splash.at(pos+i, 0x000000, 5); if (Actor.findChar(pos+i) != null) Buff.affect(Actor.findChar(pos+i), Ooze.class).set( Ooze.DURATION ); } } return damage; }
Example 10
Source File: Level.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public static void set( int cell, int terrain, Level level ) { Painter.set( level, cell, terrain ); if (terrain != Terrain.TRAP && terrain != Terrain.SECRET_TRAP && terrain != Terrain.INACTIVE_TRAP){ level.traps.remove( cell ); } int flags = Terrain.flags[terrain]; level.passable[cell] = (flags & Terrain.PASSABLE) != 0; level.losBlocking[cell] = (flags & Terrain.LOS_BLOCKING) != 0; level.flamable[cell] = (flags & Terrain.FLAMABLE) != 0; level.secret[cell] = (flags & Terrain.SECRET) != 0; level.solid[cell] = (flags & Terrain.SOLID) != 0; level.avoid[cell] = (flags & Terrain.AVOID) != 0; level.pit[cell] = (flags & Terrain.PIT) != 0; level.water[cell] = terrain == Terrain.WATER; SmokeScreen s = (SmokeScreen)level.blobs.get(SmokeScreen.class); if (s != null && s.volume > 0){ level.losBlocking[cell] = level.losBlocking[cell] || s.cur[cell] > 0; } for (int i : PathFinder.NEIGHBOURS9){ i = cell + i; if (level.solid[i]){ level.openSpace[i] = false; } else { for (int j = 1; j < PathFinder.CIRCLE8.length; j += 2){ if (level.solid[i+PathFinder.CIRCLE8[j]]) { level.openSpace[i] = false; } else if (!level.solid[i+PathFinder.CIRCLE8[(j+1)%8]] && !level.solid[i+PathFinder.CIRCLE8[(j+2)%8]]){ level.openSpace[i] = true; break; } } } } }
Example 11
Source File: DungeonTilemap.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public synchronized void updateMapCell(int cell) { //update in a 3x3 grid to account for neighbours which might also be affected if (Dungeon.level.insideMap(cell)) { super.updateMapCell(cell - mapWidth - 1); super.updateMapCell(cell + mapWidth + 1); for (int i : PathFinder.NEIGHBOURS9) data[cell + i] = getTileVisual(cell + i, map[cell + i], false); //unless we're at the level's edge, then just do the one tile. } else { super.updateMapCell(cell); data[cell] = getTileVisual(cell, map[cell], false); } }
Example 12
Source File: RotGardenRoom.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
private static boolean validPlantPos(Level level, int pos){ if (level.map[pos] != Terrain.GRASS){ return false; } for (int i : PathFinder.NEIGHBOURS9){ if (level.findMob(pos+i) != null){ return false; } } return true; }
Example 13
Source File: WandOfPrismaticLight.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
private void affectMap(Ballistica beam){ boolean noticed = false; for (int c: beam.subPath(0, beam.dist)){ for (int n : PathFinder.NEIGHBOURS9){ int cell = c+n; if (Dungeon.level.discoverable[cell]) Dungeon.level.mapped[cell] = true; int terr = Dungeon.level.map[cell]; if ((Terrain.flags[terr] & Terrain.SECRET) != 0) { Dungeon.level.discover( cell ); GameScene.discoverTile( cell, terr ); ScrollOfMagicMapping.discover(cell); noticed = true; } } CellEmitter.center(c).burst( RainbowParticle.BURST, Random.IntRange( 1, 2 ) ); } if (noticed) Sample.INSTANCE.play( Assets.SND_SECRET ); GameScene.updateFog(); }
Example 14
Source File: DungeonTilemap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public synchronized void updateMapCell(int cell) { //update in a 3x3 grid to account for neighbours which might also be affected if (Dungeon.level.insideMap(cell)) { super.updateMapCell(cell - mapWidth - 1); super.updateMapCell(cell + mapWidth + 1); for (int i : PathFinder.NEIGHBOURS9) data[cell + i] = getTileVisual(cell + i, map[cell + i], false); //unless we're at the level's edge, then just do the one tile. } else { super.updateMapCell(cell); data[cell] = getTileVisual(cell, map[cell], false); } }
Example 15
Source File: YogFist.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void zap() { spend( 1f ); if (hit( this, enemy, true )) { Buff.affect( enemy, Roots.class, 3f ); } else { enemy.sprite.showStatus( CharSprite.NEUTRAL, enemy.defenseVerb() ); } for (int i : PathFinder.NEIGHBOURS9){ int cell = enemy.pos + i; if (canSpreadGrass(cell)){ if (Random.Int(5) == 0){ Level.set(cell, Terrain.FURROWED_GRASS); GameScene.updateMap( cell ); } else { Level.set(cell, Terrain.GRASS); GameScene.updateMap( cell ); } CellEmitter.get( cell ).burst( LeafParticle.GENERAL, 10 ); } } Dungeon.observe(); }
Example 16
Source File: Goo.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected boolean doAttack( Char enemy ) { if (pumpedUp == 1) { ((GooSprite)sprite).pumpUp(); PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 ); for (int i = 0; i < PathFinder.distance.length; i++) { if (PathFinder.distance[i] < Integer.MAX_VALUE) GameScene.add(Blob.seed(i, 1, GooWarn.class)); } pumpedUp++; Sample.INSTANCE.play( Assets.Sounds.CHARGEUP ); spend( attackDelay() ); return true; } else if (pumpedUp >= 2 || Random.Int( (HP*2 <= HT) ? 2 : 5 ) > 0) { boolean visible = Dungeon.level.heroFOV[pos]; if (visible) { if (pumpedUp >= 2) { ((GooSprite) sprite).pumpAttack(); } else sprite.attack( enemy.pos ); } else { attack( enemy ); } spend( attackDelay() ); return !visible; } else { pumpedUp++; ((GooSprite)sprite).pumpUp(); for (int i=0; i < PathFinder.NEIGHBOURS9.length; i++) { int j = pos + PathFinder.NEIGHBOURS9[i]; if (!Dungeon.level.solid[j]) { GameScene.add(Blob.seed(j, 1, GooWarn.class)); } } if (Dungeon.level.heroFOV[pos]) { sprite.showStatus( CharSprite.NEGATIVE, Messages.get(this, "!!!") ); GLog.n( Messages.get(this, "pumpup") ); Sample.INSTANCE.play( Assets.Sounds.CHARGEUP, 1f, 0.8f ); } spend( attackDelay() ); return true; } }
Example 17
Source File: CeremonialCandle.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
private static void checkCandles(){ Heap heapTop = Dungeon.level.heaps.get(ritualPos - Dungeon.level.width()); Heap heapRight = Dungeon.level.heaps.get(ritualPos + 1); Heap heapBottom = Dungeon.level.heaps.get(ritualPos + Dungeon.level.width()); Heap heapLeft = Dungeon.level.heaps.get(ritualPos - 1); if (heapTop != null && heapRight != null && heapBottom != null && heapLeft != null){ if (heapTop.peek() instanceof CeremonialCandle && heapRight.peek() instanceof CeremonialCandle && heapBottom.peek() instanceof CeremonialCandle && heapLeft.peek() instanceof CeremonialCandle){ heapTop.pickUp(); heapRight.pickUp(); heapBottom.pickUp(); heapLeft.pickUp(); Elemental.NewbornFireElemental elemental = new Elemental.NewbornFireElemental(); Char ch = Actor.findChar( ritualPos ); if (ch != null) { ArrayList<Integer> candidates = new ArrayList<>(); for (int n : PathFinder.NEIGHBOURS8) { int cell = ritualPos + n; if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar( cell ) == null) { candidates.add( cell ); } } if (candidates.size() > 0) { elemental.pos = Random.element( candidates ); } else { elemental.pos = ritualPos; } } else { elemental.pos = ritualPos; } elemental.state = elemental.HUNTING; GameScene.add(elemental, 1); for (int i : PathFinder.NEIGHBOURS9){ CellEmitter.get(ritualPos+i).burst(ElmoParticle.FACTORY, 10); } Sample.INSTANCE.play(Assets.Sounds.BURNING); } } }
Example 18
Source File: StoneOfAffection.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void activate(int cell) { for (int i : PathFinder.NEIGHBOURS9){ CellEmitter.center(cell + i).start( Speck.factory( Speck.HEART ), 0.2f, 5 ); Char ch = Actor.findChar( cell + i ); if (ch != null && ch.alignment == Char.Alignment.ENEMY){ Buff.prolong(ch, Charm.class, Charm.DURATION).object = curUser.id(); } } Sample.INSTANCE.play( Assets.Sounds.CHARMS ); }
Example 19
Source File: CeremonialCandle.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
private static void checkCandles(){ Heap heapTop = Dungeon.level.heaps.get(ritualPos - Dungeon.level.width()); Heap heapRight = Dungeon.level.heaps.get(ritualPos + 1); Heap heapBottom = Dungeon.level.heaps.get(ritualPos + Dungeon.level.width()); Heap heapLeft = Dungeon.level.heaps.get(ritualPos - 1); if (heapTop != null && heapRight != null && heapBottom != null && heapLeft != null){ if (heapTop.peek() instanceof CeremonialCandle && heapRight.peek() instanceof CeremonialCandle && heapBottom.peek() instanceof CeremonialCandle && heapLeft.peek() instanceof CeremonialCandle){ heapTop.pickUp(); heapRight.pickUp(); heapBottom.pickUp(); heapLeft.pickUp(); NewbornElemental elemental = new NewbornElemental(); Char ch = Actor.findChar( ritualPos ); if (ch != null) { ArrayList<Integer> candidates = new ArrayList<>(); for (int n : PathFinder.NEIGHBOURS8) { int cell = ritualPos + n; if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar( cell ) == null) { candidates.add( cell ); } } if (candidates.size() > 0) { elemental.pos = Random.element( candidates ); } else { elemental.pos = ritualPos; } } else { elemental.pos = ritualPos; } elemental.state = elemental.HUNTING; GameScene.add(elemental, 1); for (int i : PathFinder.NEIGHBOURS9){ CellEmitter.get(ritualPos+i).burst(ElmoParticle.FACTORY, 10); } Sample.INSTANCE.play(Assets.SND_BURNING); } } }
Example 20
Source File: StoneOfAffection.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override protected void activate(int cell) { for (int i : PathFinder.NEIGHBOURS9){ CellEmitter.center(cell + i).start( Speck.factory( Speck.HEART ), 0.2f, 5 ); Char ch = Actor.findChar( cell + i ); if (ch != null && ch.alignment == Char.Alignment.ENEMY){ Buff.prolong(ch, Charm.class, 10f).object = curUser.id(); } } Sample.INSTANCE.play( Assets.SND_CHARMS ); }