当前位置: 首页>>代码示例>>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;未经允许,请勿转载。