Java Code Examples for com.watabou.noosa.Game

The following examples show how to use com.watabou.noosa.Game. These examples are extracted from open source projects. 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 Project: remixed-dungeon   Source File: Dungeon.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static String tip(Level _level) {
    if (_level instanceof DeadEndLevel) {

        return Game.getVar(R.string.Dungeon_DeadEnd);

    } else {
        String[] tips = Game.getVars(R.array.Dungeon_Tips);
        int index = depth - 1;

        if (index == -1) {
            return "Welcome to test level";
        }

        if (index < tips.length) {
            return tips[index];
        } else {
            return Game.getVar(R.string.Dungeon_NoTips);
        }
    }
}
 
Example 2
Source Project: remixed-dungeon   Source File: TitleScene.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update() {
	super.update();
	time += Game.elapsed;
	float cl = (float) Math.sin(time) * 0.5f + 0.5f;
	if(!donationAdded) {
		if (RemixedDungeon.canDonate()) {
			add(pleaseSupport);
			add(btnDonate);
		}
		donationAdded = true;
	} else {
		pleaseSupport.hardlight(cl, cl, cl);
	}

	if(changelogUpdated) {
		btnChangelog.brightness(cl + 1);
	}

}
 
Example 3
Source Project: pixel-dungeon   Source File: Archs.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update() {
	
	super.update();
	
	float shift = Game.elapsed * SCROLL_SPEED;
	if (reversed) {
		shift = -shift;
	}
	
	arcsBg.offset( 0, shift );
	arcsFg.offset( 0, shift * 2 );
	
	offsB = arcsBg.offsetY();
	offsF = arcsFg.offsetY();
}
 
Example 4
public static void showChapter( int id ) {
	
	if (Dungeon.chapters.contains( id )) {
		return;
	}
	
	String text = CHAPTERS.get( id );
	if (text != null) {
		WndStory wnd = new WndStory( text );
		if ((wnd.delay = 0.6f) > 0) {
			wnd.shadow.visible = wnd.chrome.visible = wnd.tf.visible = false;
		}
		
		Game.scene().add( wnd );
		
		Dungeon.chapters.add( id );
	}
}
 
Example 5
Source Project: remixed-dungeon   Source File: Chasm.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void heroJump( final Hero hero ) {
	GameScene.show( 
		new WndOptions( Game.getVar(R.string.Chasm_Chasm),
				Game.getVar(R.string.Chasm_Jump),
				Game.getVar(R.string.Chasm_Yes),
				Game.getVar(R.string.Chasm_No) ) {
			@Override
			public void onSelect(int index) {
				if (index == 0) {
					jumpConfirmed = true;
					hero.resume();
				}
			}
		}
	);
}
 
Example 6
Source Project: remixed-dungeon   Source File: Badges.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void unlockPlayGamesBadge(Badge badge) {
	if (playGamesList.contains(badge) && !ModdingMode.inMod()) {
		String achievementCode = StringsManager.getVar("achievement_" + badge.name().toLowerCase(Locale.ROOT));

		if(achievementCode.isEmpty()) {
			EventCollector.logException("empty achievement " + badge.name());
			return;
		}

		if(Preferences.INSTANCE.getBoolean(achievementCode,false)) {
			return;
		}

		Preferences.INSTANCE.put(achievementCode,true);

		Game.instance().playGames.unlockAchievement(achievementCode);
	}
}
 
Example 7
Source Project: remixed-dungeon   Source File: WndSadGhost.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void selectReward(Ghost ghost, @NotNull Item item, @NotNull Item reward ) {
	hide();

	item.removeItemFrom(Dungeon.hero);

	if (reward.doPickUp( Dungeon.hero )) {
		GLog.i( Hero.getHeroYouNowHave(), reward.name() );
	} else {
		reward.doDrop(ghost);
	}
	
	ghost.say( Game.getVar(R.string.WndSadGhost_Farewell) );
	ghost.die( null );
	
	Ghost.Quest.complete();
}
 
Example 8
public static void showChapter( int id ) {
	
	if (Dungeon.chapters.contains( id )) {
		return;
	}
	
	String text = CHAPTERS.get( id );
	if (text != null) {
		WndStory wnd = new WndStory( text );
		if ((wnd.delay = 0.6f) > 0) {
			wnd.shadow.visible = wnd.chrome.visible = wnd.tf.visible = false;
		}
		
		Game.scene().add( wnd );
		
		Dungeon.chapters.add( id );
	}
}
 
Example 9
@Override
public void storeInBundle( Bundle bundle ) {
	bundle.put( VERSION, Game.versionCode );
	bundle.put( WIDTH, width );
	bundle.put( HEIGHT, height );
	bundle.put( MAP, map );
	bundle.put( VISITED, visited );
	bundle.put( MAPPED, mapped );
	bundle.put( ENTRANCE, entrance );
	bundle.put( EXIT, exit );
	bundle.put( LOCKED, locked );
	bundle.put( HEAPS, heaps.valueList() );
	bundle.put( PLANTS, plants.valueList() );
	bundle.put( TRAPS, traps.valueList() );
	bundle.put( CUSTOM_TILES, customTiles );
	bundle.put( CUSTOM_WALLS, customWalls );
	bundle.put( MOBS, mobs );
	bundle.put( BLOBS, blobs.values() );
	bundle.put( FEELING, feeling );
	bundle.put( "mobs_to_spawn", mobsToSpawn.toArray(new Class[0]));
}
 
Example 10
public static void showChapter( int id ) {
	
	if (Dungeon.chapters.contains( id )) {
		return;
	}
	
	String text = Messages.get(WndStory.class, CHAPTERS.get( id ));
	if (text != null) {
		WndStory wnd = new WndStory( text );
		if ((wnd.delay = 0.6f) > 0) {
			wnd.shadow.visible = wnd.chrome.visible = wnd.tf.visible = false;
		}
		
		Game.scene().add( wnd );
		
		Dungeon.chapters.add( id );
	}
}
 
Example 11
@Override
public synchronized void update() {
	super.update();

	if (!bg.visible){
		enable(false);
		if (delay > 0f) delay -= Game.elapsed;
		if (delay <= 0f) active = false;
	} else {
		delay = 0.75f;
		active = true;
	
		if (Dungeon.hero.isAlive()) {

			enable(Dungeon.hero.ready);

		} else {
			visible( false );
			enable( false );
		}
	}
}
 
Example 12
@Override
protected void onClick() {
    if (Badges.isUnlocked(Badges.Badge.VICTORY) || BuildConfig.DEBUG) {
        parentScene.add(new WndChallenges(
                RemixedDungeon.challenges(), true) {
            public void onBackPressed() {
                super.onBackPressed();
                image.copy(Icons.get(RemixedDungeon.challenges() > 0 ? Icons.CHALLENGE_ON
                        : Icons.CHALLENGE_OFF));
            }
        });
    } else {
        parentScene.add(new WndMessage(Game
                .getVar(R.string.StartScene_WinGame)));
    }
}
 
Example 13
Source Project: pixel-dungeon   Source File: Toolbar.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update() {
	super.update();
	
	if ((left -= Game.elapsed) <= 0) {
		
		visible = 
		active = 
			false;
		
	} else {
		float p = left / DURATION; 
		scale.set( (float)Math.sqrt( p ) );
		float offset = DISTANCE * p;
		x = dstX - offset;
		y = dstY - offset;
	}
}
 
Example 14
Source Project: remixed-dungeon   Source File: WndWandmaker.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void selectReward( WandMaker wandmaker, Item item, Wand reward ) {
	hide();

	item.removeItemFrom(Dungeon.hero);

	reward.identify();
	if (reward.doPickUp( Dungeon.hero )) {
		GLog.i( Hero.getHeroYouNowHave(), reward.name() );
	} else {
		reward.doDrop(wandmaker);
	}
	
	wandmaker.say(Utils.format( Game.getVar(R.string.WndWandmaker_Farawell), Dungeon.hero.className() ) );
	wandmaker.destroy();
	
	wandmaker.getSprite().die();
	
	WandMaker.Quest.complete();
}
 
Example 15
@Override
public void update() {
	super.update();
	
	float p = timeLeft / duration;
	alpha( p );
	scale.set( scale.x, p );
	
	if ((timeLeft -= Game.elapsed) <= 0) {
		killAndErase();
	}
}
 
Example 16
Source Project: pixel-dungeon   Source File: Hero.java    License: GNU General Public License v3.0 5 votes vote down vote up
private boolean actAscend( HeroAction.Ascend action ) {
	int stairs = action.dst;
	if (pos == stairs && pos == Dungeon.level.entrance) {
		
		if (Dungeon.depth == 1) {
			
			if (belongings.getItem( Amulet.class ) == null) {
				GameScene.show( new WndMessage( TXT_LEAVE ) );
				ready();
			} else {
				Dungeon.win( ResultDescriptions.WIN );
				Dungeon.deleteGame( Dungeon.hero.heroClass, true );
				Game.switchScene( SurfaceScene.class );
			}
			
		} else {
			
			curAction = null;
			
			Hunger hunger = buff( Hunger.class );
			if (hunger != null && !hunger.isStarving()) {
				hunger.satisfy( -Hunger.STARVING / 10 );
			}
			
			InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
			Game.switchScene( InterlevelScene.class );
		}
		
		return false;
		
	} else if (getCloser( stairs )) {
		
		return true;
		
	} else {
		ready();
		return false;
	}
}
 
Example 17
@Override
public void update() {
    super.update();

    time += Game.elapsed;
    scale.set( 0.95f + (float)Math.sin( time ) * 0.05f );

}
 
Example 18
Source Project: remixed-dungeon   Source File: PlayGames.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void showLeaderboard() {
	if (isConnected()) {
		Games.getLeaderboardsClient(Game.instance(),signedInAccount)
				.getAllLeaderboardsIntent()
				.addOnSuccessListener(
						intent -> Game.instance().startActivityForResult(intent, RC_SHOW_LEADERBOARD)
				);
	}
}
 
Example 19
@Override
public void update() {
	super.update();

	if ((left -= Game.elapsed) <= 0) {
		kill();
	}
}
 
Example 20
Source Project: remixed-dungeon   Source File: NecroLevel.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public String tileDesc(int tile) {
	switch (tile) {
		case Terrain.EMPTY_DECO:
			return Game.getVar(R.string.Prison_TileDescDeco);
		case Terrain.BOOKSHELF:
			return Game.getVar(R.string.Halls_TileDescBookshelf);
		default:
			return super.tileDesc( tile );
	}
}
 
Example 21
private void startNewGame() {

		Dungeon.hero = null;
		InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
		
		if (YetAnotherPixelDungeon.intro()) {
			YetAnotherPixelDungeon.intro(false);
			Game.switchScene( IntroScene.class );
		} else {
			Game.switchScene( InterlevelScene.class );
		}	
	}
 
Example 22
@Override
public String desc() {
	if(!activated) {
		return Game.getVar(R.string.CandleOfMindVision_Info);
	} else {
		if(charges>0) {
			return Game.getVar(R.string.CandleOfMindVision_Info_Lighted);
		} else {
			return Game.getVar(R.string.CandleOfMindVision_Info_Exhausted);
		}
	}
}
 
Example 23
public void put( String key, Class[] array ){
	try {
		JSONArray jsonArray = new JSONArray();
		for (int i=0; i < array.length; i++) {
			jsonArray.put( i, array[i] );
		}
		data.put( key, jsonArray );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 24
Source Project: pixel-dungeon   Source File: WndStory.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void update() {
	super.update();
	
	if (delay > 0 && (delay -= Game.elapsed) <= 0) {
		shadow.visible = chrome.visible = tf.visible = true;
	}
}
 
Example 25
public void put( String key, String value ) {
	try {
		data.put( key, value );
	} catch (JSONException e) {
		Game.reportException(e);
	}
}
 
Example 26
@Override
public boolean doEquip(Char hero) {
    if (hero.getSubClass() == HeroSubClass.BATTLEMAGE) {
        return super.doEquip(hero);
    } else {
        GLog.w(Game.getVar(R.string.MageArmor_NotMage));
        return false;
    }
}
 
Example 27
@Override
protected void doRead(@NotNull Char reader) {
	Level level = Dungeon.level;

	if(level.isBossLevel() || !level.cellValid(level.randomRespawnCell())) {
		GLog.w( Utils.format(R.string.Using_Failed_Because_Magic, this.name()) );
		return;
	}

	int cell = level.getEmptyCellNextTo(reader.getPos());

	if(level.cellValid(cell)){
		Mob mob = Bestiary.mob( level );
		GLog.i(Game.getVar(R.string.ScrollOfSummoning_Info_2));
		if(mob.canBePet()){
			Mob.makePet(mob, reader.getId());
		} else {
			GLog.w( Utils.format(R.string.Mob_Cannot_Be_Pet, mob.getName()));
		}
		WandOfBlink.appear( mob, cell );
	} else {
		GLog.w(Game.getVar(R.string.No_Valid_Cell));
	}

	setKnown();

	SpellSprite.show( reader, SpellSprite.SUMMON );
	Sample.INSTANCE.play( Assets.SND_READ );
	Invisibility.dispel(reader);

	reader.spendAndNext( TIME_TO_READ );
}
 
Example 28
Source Project: remixed-dungeon   Source File: Util.java    License: GNU General Public License v3.0 5 votes vote down vote up
static public boolean isConnectedToInternet() {
	boolean connectionStatus;

	ConnectivityManager connectivityManager
			= (ConnectivityManager) Game.instance().getSystemService(Context.CONNECTIVITY_SERVICE);
	NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
	connectionStatus = activeNetworkInfo != null && activeNetworkInfo.isConnected();
	return connectionStatus;
}
 
Example 29
Source Project: remixed-dungeon   Source File: ExitButton.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onClick() {
	if (Game.scene() instanceof TitleScene) {
		Game.shutdown();
	} else {
		RemixedDungeon.switchNoFade( TitleScene.class );
	}
}
 
Example 30
public static void saveLevel() throws IOException {
	Bundle bundle = new Bundle();
	bundle.put(LEVEL, level);

	OutputStream output = Game.instance.openFileOutput(
		Utils.format( depthFile( hero.heroClass ), depth ), Game.MODE_PRIVATE );
	Bundle.write( bundle, output );
	output.close();
}