當前位置: 首頁>>代碼示例>>Java>>正文


Java Dungeon.hero方法代碼示例

本文整理匯總了Java中com.shatteredpixel.shatteredpixeldungeon.Dungeon.hero方法的典型用法代碼示例。如果您正苦於以下問題:Java Dungeon.hero方法的具體用法?Java Dungeon.hero怎麽用?Java Dungeon.hero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.shatteredpixel.shatteredpixeldungeon.Dungeon的用法示例。


在下文中一共展示了Dungeon.hero方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSelect

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void onSelect(Item item) {
    if (item != null && item instanceof Scroll && item.isIdentified()){
        String scroll = convertName(item.getClass().getSimpleName());
        Hero hero = Dungeon.hero;
        for (int i = 0; ( i <= 1 && i < scrolls.size() ); i++){
            if (scrolls.get(i).equals(scroll)){
                hero.sprite.operate( hero.pos );
                hero.busy();
                hero.spend( 2f );
                Sample.INSTANCE.play(Assets.SND_BURNING);
                hero.sprite.emitter().burst( ElmoParticle.FACTORY, 12 );

                scrolls.remove(i);
                item.detach(hero.belongings.backpack);

                upgrade();
                GLog.i("You infuse the scroll's energy into the book.");
                return;
            }
        }
        if (item != null)
            GLog.w("You are unable to add this scroll to the book.");
    } else if (item instanceof Scroll && !item.isIdentified())
        GLog.w("You're not sure what type of scroll this is yet.");
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:27,代碼來源:UnstableSpellbook.java

示例2: restoreFromBundle

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void restoreFromBundle( Bundle bundle ) {
	quantity	= bundle.getInt( QUANTITY );
	levelKnown	= bundle.getBoolean( LEVEL_KNOWN );
	cursedKnown	= bundle.getBoolean( CURSED_KNOWN );
	
	int level = bundle.getInt( LEVEL );
	if (level > 0) {
		upgrade( level );
	} else if (level < 0) {
		degrade( -level );
	}
	
	cursed	= bundle.getBoolean( CURSED );

	//only want to populate slot on first load.
	if (Dungeon.hero == null) {
		//support for pre-0.2.3 saves and rankings
		if (bundle.contains(OLDSLOT)) {
			Dungeon.quickslot.setSlot(0, this);
		} else if (bundle.contains(QUICKSLOT)) {
			Dungeon.quickslot.setSlot(bundle.getInt(QUICKSLOT), this);
		}
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:26,代碼來源:Item.java

示例3: onZap

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
protected void onZap( int cell ) {
	Char ch = Actor.findChar( cell );
	if (ch != null) {

           if (ch == Dungeon.hero) {
               Buff.affect( ch, Vertigo.class, Vertigo.duration(ch) );
           } else {
               Buff.affect( ch, Amok.class, 3f + level() );
           }

	} else {
		
		GLog.i( "nothing happened" );
		
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:18,代碼來源:WandOfAmok.java

示例4: die

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void die( Object cause ) {
	
	super.die( cause );
	
	boolean heroKilled = false;
	for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
		Char ch = findChar( pos + Level.NEIGHBOURS8[i] );
		if (ch != null && ch.isAlive()) {
			int damage = Math.max( 0,  damageRoll() - Random.IntRange( 0, ch.dr() / 2 ) );
			ch.damage( damage, this );
			if (ch == Dungeon.hero && !ch.isAlive()) {
				heroKilled = true;
			}
		}
	}
	
	if (Dungeon.visible[pos]) {
		Sample.INSTANCE.play( Assets.SND_BONES );
	}
	
	if (heroKilled) {
		Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
		GLog.n( TXT_HERO_KILLED );
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:27,代碼來源:Skeleton.java

示例5: zap

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
private void zap() {
	spend( TIME_TO_ZAP );
	
	if (hit( this, enemy, true )) {
		if (enemy == Dungeon.hero && Random.Int( 2 ) == 0) {
			Buff.prolong( enemy, Weakness.class, Weakness.duration( enemy ) );
		}
		
		int dmg = Random.Int( 12, 18 );
		enemy.damage( dmg, this );
		
		if (!enemy.isAlive() && enemy == Dungeon.hero) {
			Dungeon.fail( Utils.format( ResultDescriptions.MOB, Utils.indefinite( name ) ) );
			GLog.n( TXT_SHADOWBOLT_KILLED, name );
		}
	} else {
		enemy.sprite.showStatus( CharSprite.NEUTRAL,  enemy.defenseVerb() );
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:20,代碼來源:Warlock.java

示例6: onSelect

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void onSelect( Item item ) {
    if (item != null && item instanceof Food) {
        if (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null){
            GLog.w("your horn rejects the unprepared blandfruit.");
        } else {
            Hero hero = Dungeon.hero;
            hero.sprite.operate( hero.pos );
            hero.busy();
            hero.spend( TIME_TO_EAT );

            curItem.upgrade(((Food)item).hornValue);
            if (curItem.level >= 30){
                curItem.level = 30;
                GLog.p("your horn has consumed all the food it can!");
            } else
                GLog.p("the horn consumes your food offering and grows in strength!");
            item.detach(hero.belongings.backpack);
        }

    }
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:23,代碼來源:HornOfPlenty.java

示例7: proc

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) {
	// lvl 0 - 20%
	// lvl 1 - 33%
	// lvl 2 - 43%
	int level = Math.max( 0, weapon.level );
	
	if (Random.Int( level + 5 ) >= 4) {

           if (defender == Dungeon.hero) {
               Buff.affect( defender, Vertigo.class, Vertigo.duration(defender) );
           } else {
               Buff.affect( defender, Terror.class, Terror.DURATION ).source = attacker;
           }
		
		return true;
	} else {
		return false;
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:21,代碼來源:Horror.java

示例8: onSelect

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void onSelect(Item item) {
    if (item != null && item instanceof Potion && item.isIdentified()){
        if (!curGuess.contains(convertName(item.getClass().getSimpleName()))) {

            Hero hero = Dungeon.hero;
            hero.sprite.operate( hero.pos );
            hero.busy();
            hero.spend( 2f );
            Sample.INSTANCE.play(Assets.SND_DRINK);

            item.detach(hero.belongings.backpack);

            curGuess.add(convertName(item.getClass().getSimpleName()));
            if (curGuess.size() == 3){
                guessBrew();
            } else {
                GLog.i("You mix the " + item.name() + " into your current brew.");
            }
        } else {
            GLog.w("Your current brew already contains that potion.");
        }
    } else if (item != null) {
        GLog.w("You need to select an identified potion.");
    }
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:27,代碼來源:AlchemistsToolkit.java

示例9: heroLand

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
public static void heroLand() {
	
	Hero hero = Dungeon.hero;
	
	hero.sprite.burst( hero.sprite.blood(), 10 );
	Camera.main.shake( 4, 0.2f );
	
	Buff.prolong( hero, Cripple.class, Cripple.DURATION );
	hero.damage( Random.IntRange( hero.HT / 3, hero.HT / 2 ), new Hero.Doom() {
		@Override
		public void onDeath() {
			Badges.validateDeathFromFalling();
			
			Dungeon.fail( ResultDescriptions.FALL );
			GLog.n( "You fell to death..." );
		}
	} );
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:19,代碼來源:Chasm.java

示例10: press

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void press( int cell, Char hero ) {
	
	super.press( cell, hero );
	
	if (!enteredArena && hero == Dungeon.hero && cell != entrance) {
		
		enteredArena = true;
           locked = true;
		
		for (int i=ROOM_LEFT-1; i <= ROOM_RIGHT + 1; i++) {
			doMagic( (ROOM_TOP - 1) * WIDTH + i );
			doMagic( (ROOM_BOTTOM + 1) * WIDTH + i );
		}
		for (int i=ROOM_TOP; i < ROOM_BOTTOM + 1; i++) {
			doMagic( i * WIDTH + ROOM_LEFT - 1 );
			doMagic( i * WIDTH + ROOM_RIGHT + 1 );
		}
		doMagic( entrance );
		GameScene.updateMap();

		Dungeon.observe();
		
		Yog boss = new Yog();
		do {
			boss.pos = Random.Int( LENGTH );
		} while (
			!passable[boss.pos] ||
			Dungeon.visible[boss.pos]);
		GameScene.add( boss );
		boss.spawnFists();
		
		stairs = entrance;
		entrance = -1;
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:37,代碼來源:HallsBossLevel.java

示例11: collect

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public boolean collect( Bag bag ) {
	boolean result = super.collect( bag );
	if (result && depth == Dungeon.depth && Dungeon.hero != null) {
		Dungeon.hero.belongings.countIronKeys();
	}
	return result;
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:9,代碼來源:IronKey.java

示例12: trigger

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
public static void trigger( int pos, Char ch ) {
	
	if (ch != null) {
		ch.damage( Math.max( 1, Random.Int( ch.HP / 3, 2 * ch.HP / 3 ) ), LIGHTNING );
		if (ch == Dungeon.hero) {
			
			Camera.main.shake( 2, 0.3f );
			
			if (!ch.isAlive()) {
				Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name ) );
				GLog.n( "You were killed by a discharge of a lightning trap..." );
			} else {
				((Hero)ch).belongings.charge( false );
			}
		}
		
		int[] points = new int[2];
		
		points[0] = pos - Level.WIDTH;
		points[1] = pos + Level.WIDTH;
		ch.sprite.parent.add( new Lightning( points, 2, null ) );
		
		points[0] = pos - 1;
		points[1] = pos + 1;
		ch.sprite.parent.add( new Lightning( points, 2, null ) );
	}
	
	CellEmitter.center( pos ).burst( SparkParticle.FACTORY, Random.IntRange( 3, 4 ) );
	
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:31,代碼來源:LightningTrap.java

示例13: act

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public boolean act() {
	if (target.isAlive()) {
		
		target.damage( 1, this );
		if (target == Dungeon.hero && !target.isAlive()) {
			// FIXME
			Glyph glyph = new Viscosity();
			Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, glyph.name() ) );
			GLog.n( "%s killed you...", glyph.name() );
			
			Badges.validateDeathFromGlyph();
		}
		spend( TICK );
		
		if (--damage <= 0) {
			detach();
		}
		
	} else {
		
		detach();
		
	}
	
	return true;
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:28,代碼來源:Viscosity.java

示例14: press

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public void press( int cell, Char hero ) {
	
	super.press( cell, hero );
	
	if (!enteredArena && outsideEntraceRoom( cell ) && hero == Dungeon.hero) {
		
		enteredArena = true;
           locked = true;
		
		Mob boss = Bestiary.mob( Dungeon.depth );
		boss.state = boss.HUNTING;
		do {
			boss.pos = Random.Int( LENGTH );
		} while (
			!passable[boss.pos] ||
			!outsideEntraceRoom( boss.pos ) ||
			Dungeon.visible[boss.pos]);
		GameScene.add( boss );
		
		set( arenaDoor, Terrain.WALL );
		GameScene.updateMap( arenaDoor );
		Dungeon.observe();
		
		CellEmitter.get( arenaDoor ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 );
		Camera.main.shake( 3, 0.7f );
		Sample.INSTANCE.play( Assets.SND_ROCKS );
	}
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:30,代碼來源:CavesBossLevel.java

示例15: act

import com.shatteredpixel.shatteredpixeldungeon.Dungeon; //導入方法依賴的package包/類
@Override
public boolean act() {
	if (target.isAlive()) {
		
		if ((level = Random.Int( level / 2, level )) > 0) {
			
			target.damage( level, this );
			if (target.sprite.visible) {
				Splash.at( target.sprite.center(), -PointF.PI / 2, PointF.PI / 6, 
						target.sprite.blood(), Math.min( 10 * level / target.HT, 10 ) );
			}
			
			if (target == Dungeon.hero && !target.isAlive()) {
				Dungeon.fail( ResultDescriptions.BLEEDING );
				GLog.n( "You bled to death..." );
			}
			
			spend( TICK );
		} else {
			detach();
		}
		
	} else {
		
		detach();
		
	}
	
	return true;
}
 
開發者ID:wolispace,項目名稱:soft-pixel-dungeon,代碼行數:31,代碼來源:Bleeding.java


注:本文中的com.shatteredpixel.shatteredpixeldungeon.Dungeon.hero方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。