Java Code Examples for com.watabou.utils.Callback#call()
The following examples show how to use
com.watabou.utils.Callback#call() .
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: CharSprite.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public void onComplete( Animation anim ) { if (animCallback != null) { Callback executing = animCallback; animCallback = null; executing.call(); } else { if (anim == attack) { idle(); ch.onAttackComplete(); } else if (anim == operate) { idle(); ch.onOperateComplete(); } } }
Example 2
Source File: WandOfLightning.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void fx( Ballistica bolt, Callback callback ) { affected.clear(); arcs.clear(); arcs.add( new Lightning.Arc(bolt.sourcePos, bolt.collisionPos)); int cell = bolt.collisionPos; Char ch = Actor.findChar( cell ); if (ch != null) { arc(ch); } else { CellEmitter.center( cell ).burst( SparkParticle.FACTORY, 3 ); } //don't want to wait for the effect before processing damage. curUser.sprite.parent.add( new Lightning( arcs, null ) ); callback.call(); }
Example 3
Source File: WandOfLightning.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override protected void fx( Ballistica bolt, Callback callback ) { affected.clear(); arcs.clear(); int cell = bolt.collisionPos; Char ch = Actor.findChar( cell ); if (ch != null) { affected.add( ch ); arcs.add( new Lightning.Arc(curUser.sprite.center(), ch.sprite.center())); arc(ch); } else { arcs.add( new Lightning.Arc(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(bolt.collisionPos))); CellEmitter.center( cell ).burst( SparkParticle.FACTORY, 3 ); } //don't want to wait for the effect before processing damage. curUser.sprite.parent.addToFront( new Lightning( arcs, null ) ); Sample.INSTANCE.play( Assets.SND_LIGHTNING ); callback.call(); }
Example 4
Source File: CharSprite.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void onComplete( Animation anim ) { if (animCallback != null) { Callback executing = animCallback; animCallback = null; executing.call(); } else { if (anim == attack) { idle(); ch.onAttackComplete(); } else if (anim == operate) { idle(); ch.onOperateComplete(); } } }
Example 5
Source File: WandOfAcidSpray.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
private void onCast( final HashSet<Integer> targets, final Callback callback ) { // start missile animations if( !targets.isEmpty() ){ for( final int target : targets ){ // damage is increased by 50% in melee and decreased by 50% at 4-6 tiles of distance int distance = Level.distance( curUser.pos, target ); final int damage = distance < 2 ? damageRoll() * 3 / 2 : distance > 3 ? damageRoll() / 2 : damageRoll() ; MagicMissile.acid( curUser.sprite.parent, curUser.pos, target, new Callback() { @Override public void call(){ // damage targets and play splash animation on hit onHit( damage, target ); // remove missiles which finished their animation targets.remove( target ); // if there are no more missiles, resume the game if( targets.isEmpty() ){ callback.call(); } } } ); } } else { // just in case, we make sure that the game doesn't hangs up callback.call(); } }
Example 6
Source File: WandOfDisintegration.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void fx( Ballistica beam, Callback callback ) { int cell = beam.path.get(Math.min(beam.dist, distance())); curUser.sprite.parent.add(new Beam.DeathRay(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld( cell ))); callback.call(); }
Example 7
Source File: WandOfDisintegration.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void fx( Ballistica beam, Callback callback ) { int cell = beam.path.get(Math.min(beam.dist, distance())); curUser.sprite.parent.add(new Beam.DeathRay(curUser.sprite.center(), DungeonTilemap.tileCenterToWorld( cell ))); callback.call(); }
Example 8
Source File: WandOfDisintegration.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override protected void fx( Ballistica beam, Callback callback ) { int cell = beam.path.get(Math.min(beam.dist, distance())); curUser.sprite.parent.add(new Beam.DeathRay(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld( cell ))); callback.call(); }
Example 9
Source File: CursedWand.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
private static void uncommonEffect(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ switch(Random.Int(4)){ //Random plant case 0: cursedFX(user, bolt, new Callback() { public void call() { int pos = bolt.collisionPos; //place the plant infront of an enemy so they walk into it. if (Actor.findChar(pos) != null && bolt.dist > 1) { pos = bolt.path.get(bolt.dist - 1); } if (pos == Terrain.EMPTY || pos == Terrain.EMBERS || pos == Terrain.EMPTY_DECO || pos == Terrain.GRASS || pos == Terrain.HIGH_GRASS || pos == Terrain.FURROWED_GRASS) { Dungeon.level.plant((Plant.Seed) Generator.random(Generator.Category.SEED), pos); } afterZap.call(); } }); break; //Health transfer case 1: final Char target = Actor.findChar( bolt.collisionPos ); if (target != null) { cursedFX(user, bolt, new Callback() { public void call() { int damage = user.lvl * 2; switch (Random.Int(2)) { case 0: user.HP = Math.min(user.HT, user.HP + damage); user.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3); target.damage(damage, origin); target.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10); break; case 1: user.damage( damage, this ); user.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10); target.HP = Math.min(target.HT, target.HP + damage); target.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3); Sample.INSTANCE.play(Assets.SND_CURSED); if (!user.isAlive() && origin != null) { Dungeon.fail( origin.getClass() ); GLog.n(Messages.get(CursedWand.class, "ondeath", origin.name())); } break; } afterZap.call(); } }); } else { GLog.i(Messages.get(CursedWand.class, "nothing")); afterZap.call(); } break; //Bomb explosion case 2: cursedFX(user, bolt, new Callback() { public void call() { new Bomb().explode(bolt.collisionPos); afterZap.call(); } }); break; //shock and recharge case 3: new ShockingTrap().set( user.pos ).activate(); Buff.prolong(user, Recharging.class, 20f); ScrollOfRecharging.charge(user); SpellSprite.show(user, SpellSprite.CHARGE); afterZap.call(); break; } }
Example 10
Source File: WandOfDisintegration.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void fx( int cell, Callback callback ) { cell = Ballistica.trace[Math.min( Ballistica.distance, distance() ) - 1]; getOwner().getSprite().getParent().add( new DeathRay( getOwner().getPos(), cell ) ); callback.call(); }
Example 11
Source File: WandOfPrismaticLight.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void fx( Ballistica beam, Callback callback ) { curUser.sprite.parent.add( new Beam.LightRay(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(beam.collisionPos))); callback.call(); }
Example 12
Source File: WandOfTransfusion.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override protected void fx(Ballistica beam, Callback callback) { curUser.sprite.parent.add( new Beam.HealthRay(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(beam.collisionPos))); callback.call(); }
Example 13
Source File: CursedWand.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
private static void veryRareEffect(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ switch(Random.Int(4)){ //great forest fire! case 0: for (int i = 0; i < Dungeon.level.length(); i++){ GameScene.add( Blob.seed(i, 15, Regrowth.class)); } do { GameScene.add(Blob.seed(Dungeon.level.randomDestination(), 10, Fire.class)); } while (Random.Int(5) != 0); new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f); Sample.INSTANCE.play(Assets.SND_TELEPORT); GLog.p(Messages.get(CursedWand.class, "grass")); GLog.w(Messages.get(CursedWand.class, "fire")); afterZap.call(); break; //superpowered mimic case 1: cursedFX(user, bolt, new Callback() { public void call() { Mimic mimic = Mimic.spawnAt(bolt.collisionPos, new ArrayList<Item>()); if (mimic != null) { mimic.adjustStats(Dungeon.depth + 10); mimic.HP = mimic.HT; Item reward; do { reward = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, Generator.Category.RING, Generator.Category.WAND)); } while (reward.level() < 1); Sample.INSTANCE.play(Assets.SND_MIMIC, 1, 1, 0.5f); mimic.items.clear(); mimic.items.add(reward); } else { GLog.i(Messages.get(CursedWand.class, "nothing")); } afterZap.call(); } }); break; //crashes the game, yes, really. case 2: try { Dungeon.saveAll(); if(Messages.lang() != Languages.ENGLISH){ //Don't bother doing this joke to none-english speakers, I doubt it would translate. GLog.i(Messages.get(CursedWand.class, "nothing")); afterZap.call(); } else { GameScene.show( new WndOptions("CURSED WAND ERROR", "this application will now self-destruct", "abort", "retry", "fail") { @Override protected void onSelect(int index) { Game.instance.finish(); } @Override public void onBackPressed() { //do nothing } } ); } } catch(IOException e){ ShatteredPixelDungeon.reportException(e); //oookay maybe don't kill the game if the save failed. GLog.i(Messages.get(CursedWand.class, "nothing")); afterZap.call(); } break; //random transmogrification case 3: //skips this effect if there is no item to transmogrify if (origin == null || !Dungeon.hero.belongings.contains(origin)){ cursedZap(origin, user, bolt, afterZap); return; } origin.detach(user.belongings.backpack); Item result; do { result = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, Generator.Category.RING, Generator.Category.ARTIFACT)); } while (result.cursed); if (result.isUpgradable()) result.upgrade(); result.cursed = result.cursedKnown = true; if (origin instanceof Wand){ GLog.w( Messages.get(CursedWand.class, "transmogrify_wand") ); } else { GLog.w( Messages.get(CursedWand.class, "transmogrify_other") ); } Dungeon.level.drop(result, user.pos).sprite.drop(); afterZap.call(); break; } }
Example 14
Source File: CursedWand.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
private static void commonEffect(final Item origin, final Char user, final Ballistica bolt, final Callback afterZap){ switch(Random.Int(4)){ //anti-entropy case 0: cursedFX(user, bolt, new Callback() { public void call() { Char target = Actor.findChar(bolt.collisionPos); switch (Random.Int(2)){ case 0: if (target != null) Buff.affect(target, Burning.class).reignite(target); Buff.affect(user, Frost.class, Frost.DURATION); break; case 1: Buff.affect(user, Burning.class).reignite(user); if (target != null) Buff.affect(target, Frost.class, Frost.DURATION); break; } afterZap.call(); } }); break; //spawns some regrowth case 1: cursedFX(user, bolt, new Callback() { public void call() { GameScene.add( Blob.seed(bolt.collisionPos, 30, Regrowth.class)); afterZap.call(); } }); break; //random teleportation case 2: switch(Random.Int(2)){ case 0: ScrollOfTeleportation.teleportChar(user); afterZap.call(); break; case 1: cursedFX(user, bolt, new Callback() { public void call() { Char ch = Actor.findChar( bolt.collisionPos ); if (ch != null && !ch.properties().contains(Char.Property.IMMOVABLE)) { ScrollOfTeleportation.teleportChar(user); } afterZap.call(); } }); break; } break; //random gas at location case 3: cursedFX(user, bolt, new Callback() { public void call() { switch (Random.Int(3)) { case 0: GameScene.add( Blob.seed( bolt.collisionPos, 800, ConfusionGas.class ) ); break; case 1: GameScene.add( Blob.seed( bolt.collisionPos, 500, ToxicGas.class ) ); break; case 2: GameScene.add( Blob.seed( bolt.collisionPos, 200, ParalyticGas.class ) ); break; } Sample.INSTANCE.play( Assets.Sounds.GAS ); afterZap.call(); } }); break; } }
Example 15
Source File: Goo.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected boolean doAttack( final Char enemy ) { if (pumpedUp) { if (Level.adjacent( pos, enemy.pos )) { // Pumped up attack WITHOUT accuracy penalty jumped = false; return super.doAttack( enemy ); } else { // Pumped up attack WITH accuracy penalty jumped = true; if (Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos) { final int dest = Ballistica.trace[Ballistica.distance - 2]; Callback afterJump = new Callback() { @Override public void call() { move( dest ); Dungeon.level.mobPress( Goo.this ); Goo.super.doAttack( enemy ); } }; if (Dungeon.visible[pos] || Dungeon.visible[dest]) { sprite.jump( pos, dest, afterJump ); return false; } else { afterJump.call(); return true; } } else { sprite.idle(); pumpedUp = false; return true; } } } else if (Random.Int( 3 ) > 0) { // Normal attack return super.doAttack( enemy ); } else { // Pumping up pumpedUp = true; spend( PUMP_UP_DELAY ); ((GooSprite)sprite).pumpUp(); if (Dungeon.visible[pos]) { sprite.showStatus( CharSprite.NEGATIVE, "!!!" ); GLog.n( "Goo is pumping itself up!" ); } return true; } }
Example 16
Source File: WandOfPrismaticLight.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void fx( Ballistica beam, Callback callback ) { curUser.sprite.parent.add( new Beam.LightRay(curUser.sprite.center(), DungeonTilemap.tileCenterToWorld(beam.collisionPos))); callback.call(); }
Example 17
Source File: WandOfPrismaticLight.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override protected void fx( Ballistica beam, Callback callback ) { curUser.sprite.parent.add( new Beam.LightRay(curUser.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(beam.collisionPos))); callback.call(); }
Example 18
Source File: WandOfLifeDrain.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 3 votes |
@Override protected void fx( int cell, Callback callback ) { Char target = Actor.findChar( cell ); if (target != null && target != curUser ) { if( !target.isMagical() ) { curUser.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 5 ); curUser.sprite.parent.add( new DrainLife( curUser.pos, cell, null ) ); if( target.sprite.visible ){ new Flare( 6, 20 ).color( SpellSprite.COLOUR_DARK, true ).show( target.sprite, 0.5f ); } } else { // target.sprite.emitter().start( Speck.factory( Speck.CONTROL ), 0.5f, 5 ); curUser.sprite.parent.add( new DrainWill( curUser.pos, cell, null ) ); if( target.sprite.visible ){ new Flare( 6, 20 ).color( SpellSprite.COLOUR_WILD, true ).show( target.sprite, 0.5f ); } } } else { curUser.sprite.parent.add( new DrainLife( curUser.pos, cell, null ) ); } Sample.INSTANCE.play(Assets.SND_ZAP); callback.call(); }
Example 19
Source File: WandOfDisintegration.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 3 votes |
@Override protected void fx( int cell, Callback callback ) { cells = new ArrayList<>( ); int reflectFrom = Ballistica.trace[ Ballistica.distance ] ; curUser.sprite.parent.add( new DeathRay( curUser.pos, reflectFrom ) ); cells = getCellsFromTrace( cells ); if( Level.solid[ reflectFrom ] ){ int reflectTo = getReflectTo( curUser.pos, reflectFrom ); if( reflectFrom != reflectTo ){ Ballistica.cast( reflectFrom, reflectTo, true, false ); reflectTo = Ballistica.trace[ Ballistica.distance ] ; curUser.sprite.parent.add( new DeathRay( reflectFrom, reflectTo ) ); cells = getCellsFromTrace( cells ); } } callback.call(); }
Example 20
Source File: WandOfLightning.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 2 votes |
@Override protected void fx( int cell, Callback callback ) { targets = new HashSet<>(); Char ch = Actor.findChar( cell ); if( ch != null ){ //starting cell is always included targets.add( ch ); // ch.damage( damageRoll(), curUser, Element.SHOCK ); } if( Level.water[ cell ] && ( ch == null || !ch.flying ) ){ // check for other non-flying mobs in the same pool of water PathFinder.buildDistanceMap( cell, Level.water, MAX_DISTANCE ); for( int c = 0 ; c < Level.LENGTH ; c++ ){ if( PathFinder.distance[ c ] < Integer.MAX_VALUE ){ // highlight affected water tiles GameScene.electrify( c ); if( Dungeon.visible[ c ] ){ CellEmitter.get( c ).burst( SparkParticle.FACTORY, Random.IntRange( 2, 4 ) ); } if( ( ch = Actor.findChar( c ) ) != null && !ch.flying && !targets.contains( ch ) ){ targets.add( ch ); } } } } CellEmitter.center( cell ).burst( SparkParticle.FACTORY, Random.IntRange( 3, 5 ) ); curUser.sprite.parent.add( new Lightning( curUser.pos, cell ) ); callback.call(); }