Java Code Examples for com.watabou.noosa.Game#runOnRenderThread()
The following examples show how to use
com.watabou.noosa.Game#runOnRenderThread() .
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: DriedRose.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public boolean interact() { updateRose(); if (rose != null && !rose.talkedTo){ rose.talkedTo = true; Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show(new WndQuest(GhostHero.this, Messages.get(GhostHero.this, "introduce") )); } }); return false; } else { return super.interact(); } }
Example 2
Source File: WandOfWarding.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public boolean interact() { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show(new WndOptions( Messages.get(Ward.this, "dismiss_title"), Messages.get(Ward.this, "dismiss_body"), Messages.get(Ward.this, "dismiss_confirm"), Messages.get(Ward.this, "dismiss_cancel") ){ @Override protected void onSelect(int index) { if (index == 0){ die(null); } } }); } }); return true; }
Example 3
Source File: WandOfWarding.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public boolean interact( Char c ) { if (c != Dungeon.hero){ return true; } Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show(new WndOptions( Messages.get(Ward.this, "dismiss_title"), Messages.get(Ward.this, "dismiss_body"), Messages.get(Ward.this, "dismiss_confirm"), Messages.get(Ward.this, "dismiss_cancel") ){ @Override protected void onSelect(int index) { if (index == 0){ die(null); } } }); } }); return true; }
Example 4
Source File: DriedRose.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public boolean interact(Char c) { updateRose(); if (c == Dungeon.hero && rose != null && !rose.talkedTo){ rose.talkedTo = true; Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show(new WndQuest(GhostHero.this, Messages.get(GhostHero.this, "introduce") )); } }); return true; } else { return super.interact(c); } }
Example 5
Source File: Chasm.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public static void heroJump( final Hero hero ) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndOptions( Messages.get(Chasm.class, "chasm"), Messages.get(Chasm.class, "jump"), Messages.get(Chasm.class, "yes"), Messages.get(Chasm.class, "no") ) { @Override protected void onSelect( int index ) { if (index == 0) { jumpConfirmed = true; hero.resume(); } } } ); } }); }
Example 6
Source File: FloatingText.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public static void show( float x, float y, String text, int color ) { Game.runOnRenderThread(new Callback() { @Override public void call() { FloatingText txt = GameScene.status(); if (txt != null){ txt.reset(x, y, text, color); } } }); }
Example 7
Source File: Imp.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public boolean interact() { sprite.turnTo( pos, Dungeon.hero.pos ); if (Quest.given) { DwarfToken tokens = Dungeon.hero.belongings.getItem( DwarfToken.class ); if (tokens != null && (tokens.quantity() >= 8 || (!Quest.alternative && tokens.quantity() >= 6))) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndImp( Imp.this, tokens ) ); } }); } else { tell( Quest.alternative ? Messages.get(this, "monks_2", Dungeon.hero.givenName()) : Messages.get(this, "golems_2", Dungeon.hero.givenName()) ); } } else { tell( Quest.alternative ? Messages.get(this, "monks_1") : Messages.get(this, "golems_1") ); Quest.given = true; Quest.completed = false; Notes.add( Notes.Landmark.IMP ); } return false; }
Example 8
Source File: UnstableSpellbook.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public boolean act() { curUser = Dungeon.hero; curItem = scroll; scroll.anonymize(); Game.runOnRenderThread(new Callback() { @Override public void call() { scroll.doRead(); } }); detach(); return true; }
Example 9
Source File: FloatingText.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public static void show( float x, float y, int key, String text, int color ) { Game.runOnRenderThread(new Callback() { @Override public void call() { FloatingText txt = GameScene.status(); if (txt != null){ txt.reset(x, y, text, color); push(txt, key); } } }); }
Example 10
Source File: Blacksmith.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
private void tell( String text ) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndQuest( Blacksmith.this, text ) ); } }); }
Example 11
Source File: Shopkeeper.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override public boolean interact() { Game.runOnRenderThread(new Callback() { @Override public void call() { sell(); } }); return false; }
Example 12
Source File: FloatingText.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public static void show( float x, float y, String text, int color ) { Game.runOnRenderThread(new Callback() { @Override public void call() { FloatingText txt = GameScene.status(); if (txt != null){ txt.reset(x, y, text, color); } } }); }
Example 13
Source File: Blacksmith.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private void tell( String text ) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndQuest( Blacksmith.this, text ) ); } }); }
Example 14
Source File: Imp.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private void tell( String text ) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndQuest( Imp.this, text )); } }); }
Example 15
Source File: UpdateNotification.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
private void updateMessage(){ Game.runOnRenderThread(new Callback() { @Override public void call() { if (latestVersion == -1){ updateMessage.text("Connection Failed"); updateMessage.hardlight( 0xFFCC66 ); alpha = 1f; } else if (latestVersion == 0){ updateMessage.text("Checking Updates"); updateMessage.hardlight( 0xFFFFFF ); alpha = 0.8f; } else if (!updateAvailable){ updateMessage.text("Up to Date!"); updateMessage.hardlight( 0xFFFFFF ); alpha = 0.8f; } else { if (!latestIsUpdate){ updateMessage.text("Patch!"); } else { updateMessage.text("Update!"); } updateMessage.hardlight( Window.SHPX_COLOR ); alpha = 1f; } layout(); } }); }
Example 16
Source File: Hero.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private boolean actBuy( HeroAction.Buy action ) { int dst = action.dst; if (pos == dst) { ready(); Heap heap = Dungeon.level.heaps.get( dst ); if (heap != null && heap.type == Type.FOR_SALE && heap.size() == 1) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndTradeItem( heap ) ); } }); } return false; } else if (getCloser( dst )) { return true; } else { ready(); return false; } }
Example 17
Source File: Ghost.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public boolean interact() { sprite.turnTo( pos, Dungeon.hero.pos ); Sample.INSTANCE.play( Assets.SND_GHOST ); if (Quest.given) { if (Quest.weapon != null) { if (Quest.processed) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show(new WndSadGhost(Ghost.this, Quest.type)); } }); } else { Game.runOnRenderThread(new Callback() { @Override public void call() { switch (Quest.type) { case 1: default: GameScene.show(new WndQuest(Ghost.this, Messages.get(Ghost.this, "rat_2"))); break; case 2: GameScene.show(new WndQuest(Ghost.this, Messages.get(Ghost.this, "gnoll_2"))); break; case 3: GameScene.show(new WndQuest(Ghost.this, Messages.get(Ghost.this, "crab_2"))); break; } } }); int newPos = -1; for (int i = 0; i < 10; i++) { newPos = Dungeon.level.randomRespawnCell(); if (newPos != -1) { break; } } if (newPos != -1) { CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); pos = newPos; sprite.place(pos); sprite.visible = Dungeon.level.heroFOV[pos]; } } } } else { Mob questBoss; String txt_quest; switch (Quest.type){ case 1: default: questBoss = new FetidRat(); txt_quest = Messages.get(this, "rat_1", Dungeon.hero.givenName()); break; case 2: questBoss = new GnollTrickster(); txt_quest = Messages.get(this, "gnoll_1", Dungeon.hero.givenName()); break; case 3: questBoss = new GreatCrab(); txt_quest = Messages.get(this, "crab_1", Dungeon.hero.givenName()); break; } questBoss.pos = Dungeon.level.randomRespawnCell(); if (questBoss.pos != -1) { GameScene.add(questBoss); Quest.given = true; Notes.add( Notes.Landmark.GHOST ); Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndQuest( Ghost.this, txt_quest ) ); } }); } } return false; }
Example 18
Source File: Hero.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
private boolean actAscend( HeroAction.Ascend action ) { int stairs = action.dst; if (pos == stairs) { if (Dungeon.depth == 1) { if (belongings.getItem( Amulet.class ) == null) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndMessage( Messages.get(Hero.this, "leave") ) ); } }); ready(); } else { Badges.silentValidateHappyEnd(); Dungeon.win( Amulet.class ); Dungeon.deleteGame( GamesInProgress.curSlot, true ); Game.switchScene( SurfaceScene.class ); } } else { curAction = null; Buff buff = buff(TimekeepersHourglass.timeFreeze.class); if (buff != null) buff.detach(); buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); if (buff != null) buff.detach(); InterlevelScene.mode = InterlevelScene.Mode.ASCEND; Game.switchScene( InterlevelScene.class ); } return false; } else if (getCloser( stairs )) { return true; } else { ready(); return false; } }
Example 19
Source File: Hero.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void die( Object cause ) { curAction = null; Ankh ankh = null; //look for ankhs in player inventory, prioritize ones which are blessed. for (Item item : belongings){ if (item instanceof Ankh) { if (ankh == null || ((Ankh) item).isBlessed()) { ankh = (Ankh) item; } } } if (ankh != null && ankh.isBlessed()) { this.HP = HT/4; //ensures that you'll get to act first in almost any case, to prevent reviving and then instantly dieing again. PotionOfHealing.cure(this); Buff.detach(this, Paralysis.class); spend(-cooldown()); new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f); CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); ankh.detach(belongings.backpack); Sample.INSTANCE.play( Assets.SND_TELEPORT ); GLog.w( Messages.get(this, "revive") ); Statistics.ankhsUsed++; for (Char ch : Actor.chars()){ if (ch instanceof DriedRose.GhostHero){ ((DriedRose.GhostHero) ch).sayAnhk(); return; } } return; } Actor.fixTime(); super.die( cause ); if (ankh == null) { reallyDie( cause ); } else { Dungeon.deleteGame( GamesInProgress.curSlot, false ); final Ankh finalAnkh = ankh; Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndResurrect( finalAnkh, cause ) ); } }); } }
Example 20
Source File: Hero.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
private boolean actAscend( HeroAction.Ascend action ) { int stairs = action.dst; if (rooted){ Camera.main.shake( 1, 1f ); ready(); return false; //there can be multiple entrance tiles, so descend on any of them //TODO this is slightly brittle, it assumes there are no disjointed sets of entrance tiles } else if (Dungeon.level.map[pos] == Terrain.ENTRANCE) { if (Dungeon.depth == 1) { if (belongings.getItem( Amulet.class ) == null) { Game.runOnRenderThread(new Callback() { @Override public void call() { GameScene.show( new WndMessage( Messages.get(Hero.this, "leave") ) ); } }); ready(); } else { Badges.silentValidateHappyEnd(); Dungeon.win( Amulet.class ); Dungeon.deleteGame( GamesInProgress.curSlot, true ); Game.switchScene( SurfaceScene.class ); } } else { curAction = null; Buff buff = buff(TimekeepersHourglass.timeFreeze.class); if (buff != null) buff.detach(); buff = Dungeon.hero.buff(Swiftthistle.TimeBubble.class); if (buff != null) buff.detach(); InterlevelScene.mode = InterlevelScene.Mode.ASCEND; Game.switchScene( InterlevelScene.class ); } return false; } else if (getCloser( stairs )) { return true; } else { ready(); return false; } }