Java Code Examples for com.watabou.utils.PathFinder#NEIGHBOURS4
The following examples show how to use
com.watabou.utils.PathFinder#NEIGHBOURS4 .
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: Electricity.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private void spreadFromCell( int cell, int power ){ if (cur[cell] == 0) { area.union(cell % Dungeon.level.width(), cell / Dungeon.level.width()); } cur[cell] = Math.max(cur[cell], power); for (int c : PathFinder.NEIGHBOURS4){ if (water[cell + c] && cur[cell + c] < power){ spreadFromCell(cell + c, power); } } }
Example 2
Source File: Wraith.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public static void spawnAround( int pos ) { for (int n : PathFinder.NEIGHBOURS4) { int cell = pos + n; if (Dungeon.level.passable[cell] && Actor.findChar( cell ) == null) { spawnAt( cell ); } } }
Example 3
Source File: Electricity.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
private void spreadFromCell( int cell, int power ){ if (cur[cell] == 0) { area.union(cell % Dungeon.level.width(), cell / Dungeon.level.width()); } cur[cell] = Math.max(cur[cell], power); for (int c : PathFinder.NEIGHBOURS4){ if (water[cell + c] && cur[cell + c] < power){ spreadFromCell(cell + c, power); } } }
Example 4
Source File: Wraith.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public static void spawnAround( int pos ) { for (int n : PathFinder.NEIGHBOURS4) { int cell = pos + n; if (Dungeon.level.passable[cell] && Actor.findChar( cell ) == null) { spawnAt( cell ); } } }
Example 5
Source File: Honeypot.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public Item shatter( Char owner, int pos ) { if (Dungeon.level.heroFOV[pos]) { Sample.INSTANCE.play( Assets.Sounds.SHATTER ); Splash.at( pos, 0xffd500, 5 ); } int newPos = pos; if (Actor.findChar( pos ) != null) { ArrayList<Integer> candidates = new ArrayList<>(); boolean[] passable = Dungeon.level.passable; for (int n : PathFinder.NEIGHBOURS4) { int c = pos + n; if (passable[c] && Actor.findChar( c ) == null) { candidates.add( c ); } } newPos = candidates.size() > 0 ? Random.element( candidates ) : -1; } if (newPos != -1) { Bee bee = new Bee(); bee.spawn( Dungeon.depth ); bee.setPotInfo( pos, owner ); bee.HP = bee.HT; bee.pos = newPos; GameScene.add( bee ); Actor.addDelayed( new Pushing( bee, pos, newPos ), -1f ); bee.sprite.alpha( 0 ); bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) ); Sample.INSTANCE.play( Assets.Sounds.BEE ); return new ShatteredPot(); } else { return this; } }
Example 6
Source File: Honeypot.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
public Item shatter( Char owner, int pos ) { if (Dungeon.level.heroFOV[pos]) { Sample.INSTANCE.play( Assets.SND_SHATTER ); Splash.at( pos, 0xffd500, 5 ); } int newPos = pos; if (Actor.findChar( pos ) != null) { ArrayList<Integer> candidates = new ArrayList<>(); boolean[] passable = Dungeon.level.passable; for (int n : PathFinder.NEIGHBOURS4) { int c = pos + n; if (passable[c] && Actor.findChar( c ) == null) { candidates.add( c ); } } newPos = candidates.size() > 0 ? Random.element( candidates ) : -1; } if (newPos != -1) { Bee bee = new Bee(); bee.spawn( Dungeon.depth ); bee.setPotInfo( pos, owner ); bee.HP = bee.HT; bee.pos = newPos; GameScene.add( bee ); Actor.addDelayed( new Pushing( bee, pos, newPos ), -1f ); bee.sprite.alpha( 0 ); bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) ); Sample.INSTANCE.play( Assets.SND_BEE ); return new ShatteredPot(); } else { return this; } }