当前位置: 首页>>代码示例>>Java>>正文


Java Actor.add方法代码示例

本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.actors.Actor.add方法的典型用法代码示例。如果您正苦于以下问题:Java Actor.add方法的具体用法?Java Actor.add怎么用?Java Actor.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.shatteredpixel.shatteredpixeldungeon.actors.Actor的用法示例。


在下文中一共展示了Actor.add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shatter

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
protected void shatter( int cell ) {
	
	setKnown();
	
	splash( cell );
	Sample.INSTANCE.play( Assets.SND_SHATTER );
	
	ToxicGas gas = Blob.seed( cell, 1000, ToxicGas.class );
	Actor.add( gas );
	GameScene.add( gas );
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:13,代码来源:PotionOfToxicGas.java

示例2: switchLevel

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void switchLevel( final Level level, int pos ) {
	
	if (pos < 0 || pos >= level.length()){
		pos = level.exit;
	}
	
	PathFinder.setMapSize(level.width(), level.height());
	
	Dungeon.level = level;
	DriedRose.restoreGhostHero( level, pos );
	Actor.init();
	
	Actor respawner = level.respawner();
	if (respawner != null) {
		Actor.add( level.respawner() );
	}

	hero.pos = pos;
	
	Light light = hero.buff( Light.class );
	hero.viewDistance = light == null ? level.viewDistance : Math.max( Light.DISTANCE, level.viewDistance );
	
	hero.curAction = hero.lastAction = null;
	
	observe();
	try {
		saveAll();
	} catch (IOException e) {
		ShatteredPixelDungeon.reportException(e);
		/*This only catches IO errors. Yes, this means things can go wrong, and they can go wrong catastrophically.
		But when they do the user will get a nice 'report this issue' dialogue, and I can fix the bug.*/
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:35,代码来源:Dungeon.java

示例3: activate

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public void activate() {
	//use an actor as we want to put this on a slight delay so all chars get a chance to act this turn first.
	Actor.add(new Actor() {

		{ actPriority = 3; }

		protected boolean act() {
			PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 );
			for (int i = 0; i < PathFinder.distance.length; i++) {
				if (PathFinder.distance[i] < Integer.MAX_VALUE) {
					if (Dungeon.level.insideMap(i)
							&& Actor.findChar(i) == null
							&& !(Dungeon.level.pit[i])) {
						Sheep sheep = new Sheep();
						sheep.lifespan = Random.NormalIntRange(3 + Dungeon.depth/4, 6 + Dungeon.depth/2 );
						sheep.pos = i;
						Dungeon.level.mobPress(sheep);
						GameScene.add(sheep);
						CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
					}
				}
			}
			Sample.INSTANCE.play(Assets.SND_PUFF);
			Actor.remove(this);
			return true;
		}
	});

}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:31,代码来源:FlockTrap.java

示例4: add

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
public static void add( Blob gas ) {
	Actor.add( gas );
	if (scene != null) {
		scene.addBlobSprite( gas );
	}
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:7,代码来源:GameScene.java

示例5: switchLevel

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void switchLevel( final Level level, int pos ) {
	
	Dungeon.level = level;
	Actor.init();
	
	Actor respawner = level.respawner();
	if (respawner != null) {
		Actor.add( level.respawner() );
	}

       for (Potion potion : level.fallingPotions){

           int cell = level.randomRespawnCell();
           while (cell == -1)
               cell = level.randomRespawnCell();

           if (potion instanceof PotionOfLiquidFlame)
               GameScene.add( Blob.seed( cell, 2, Fire.class));
           else if (potion instanceof PotionOfToxicGas)
               GameScene.add( Blob.seed( cell, 1000, ToxicGas.class ) );
           else if (potion instanceof PotionOfParalyticGas)
               GameScene.add( Blob.seed( cell, 1000, ParalyticGas.class ) );
           else if (potion instanceof PotionOfLevitation)
               GameScene.add( Blob.seed( cell, 1000, ConfusionGas.class ) );

       }
       level.fallingPotions.clear();
	
	hero.pos = pos != -1 ? pos : level.exit;
	
	Light light = hero.buff( Light.class );
	hero.viewDistance = light == null ? level.viewDistance : Math.max( Light.DISTANCE, level.viewDistance );
	
	observe();
       try {
           saveAll();
       } catch (IOException e) {
		/*This only catches IO errors. Yes, this means things can do wrong, and they can go wrong catastrophically.
		But when they do the user will get a nice 'report this issue' dialogue, and I can fix the bug.*/
       }
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:43,代码来源:Dungeon.java

示例6: activate

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public void activate() {
	Char target = Actor.findChar(pos);
	
	//find the closest char that can be aimed at
	if (target == null){
		for (Char ch : Actor.chars()){
			Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
			if (bolt.collisionPos == ch.pos &&
					(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
				target = ch;
			}
		}
	}
	if (target != null) {
		final Char finalTarget = target;
		final PoisonDartTrap trap = this;
		if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
			Actor.add(new Actor() {
				
				{
					//it's a visual effect, gets priority no matter what
					actPriority = Integer.MIN_VALUE;
				}
				
				@Override
				protected boolean act() {
					final Actor toRemove = this;
					((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)).
						reset(pos, finalTarget.sprite, new Dart(), new Callback() {
							@Override
							public void call() {
								int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
								finalTarget.damage(dmg, trap);
								if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){
									Dungeon.fail( trap.getClass() );
								}
								Buff.affect( finalTarget, Poison.class )
										.set( Poison.durationFactor( finalTarget ) * (4 + Dungeon.depth) );
								Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
								finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
								finalTarget.sprite.flash();
								Actor.remove(toRemove);
								next();
							}
						});
					return false;
				}
			});
		} else {
			finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
			Buff.affect( finalTarget, Poison.class )
					.set( Poison.durationFactor( finalTarget ) * (4 + Dungeon.depth) );
		}
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:57,代码来源:PoisonDartTrap.java

示例7: activate

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public void activate() {
	Char target = Actor.findChar(pos);
	
	//find the closest char that can be aimed at
	if (target == null){
		for (Char ch : Actor.chars()){
			Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
			if (bolt.collisionPos == ch.pos &&
					(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
				target = ch;
			}
		}
	}
	if (target != null) {
		final Char finalTarget = target;
		final WornDartTrap trap = this;
		if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
			Actor.add(new Actor() {
				
				{
					//it's a visual effect, gets priority no matter what
					actPriority = Integer.MIN_VALUE;
				}
				
				@Override
				protected boolean act() {
					final Actor toRemove = this;
					((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)).
						reset(pos, finalTarget.sprite, new Dart(), new Callback() {
							@Override
							public void call() {
							int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
							finalTarget.damage(dmg, trap);
							if (finalTarget == Dungeon.hero && !finalTarget.isAlive()){
								Dungeon.fail( trap.getClass()  );
							}
							Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
							finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
							finalTarget.sprite.flash();
							Actor.remove(toRemove);
							next();
							}
						});
					return false;
				}
			});
		} else {
			finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
		}
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:53,代码来源:WornDartTrap.java

示例8: activate

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public void activate() {
	Char target = Actor.findChar(pos);

	//find the closest char that can be aimed at
	if (target == null){
		for (Char ch : Actor.chars()){
			Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
			if (bolt.collisionPos == ch.pos &&
					(target == null || Dungeon.level.distNoDiag(pos, ch.pos) < Dungeon.level.distNoDiag(pos, target.pos))){
				target = ch;
			}
		}
	}

	if (target != null){
		final Char finalTarget = target;
		final GrimTrap trap = this;
		int damage;
		
		//almost kill the player
		if (finalTarget == Dungeon.hero && ((float)finalTarget.HP/finalTarget.HT) >= 0.9f){
			damage = finalTarget.HP-1;
		//kill 'em
		} else {
			damage = finalTarget.HP;
		}
		
		final int finalDmg = damage;
		
		Actor.add(new Actor() {
			
			{
				//it's a visual effect, gets priority no matter what
				actPriority = Integer.MIN_VALUE;
			}
			
			@Override
			protected boolean act() {
				final Actor toRemove = this;
				((MagicMissile)finalTarget.sprite.parent.recycle(MagicMissile.class)).reset(
						MagicMissile.SHADOW,
						DungeonTilemap.tileCenterToWorld(pos),
						finalTarget.sprite.center(),
						new Callback() {
							@Override
							public void call() {
								finalTarget.damage(finalDmg, trap);
								if (finalTarget == Dungeon.hero) {
									Sample.INSTANCE.play(Assets.SND_CURSED);
									if (!finalTarget.isAlive()) {
										Dungeon.fail( GrimTrap.class );
										GLog.n( Messages.get(GrimTrap.class, "ondeath") );
									}
								} else {
									Sample.INSTANCE.play(Assets.SND_BURNING);
								}
								finalTarget.sprite.emitter().burst(ShadowParticle.UP, 10);
								Actor.remove(toRemove);
								next();
							}
						});
				return false;
			}
		});
	} else {
		CellEmitter.get(pos).burst(ShadowParticle.UP, 10);
		Sample.INSTANCE.play(Assets.SND_BURNING);
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:71,代码来源:GrimTrap.java

示例9: restoreFromBundle

import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public void restoreFromBundle(Bundle bundle) {
	super.restoreFromBundle(bundle);
	if (bundle.contains( FUSE ))
		Actor.add( fuse = ((Fuse)bundle.get(FUSE)).ignite(this) );
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:7,代码来源:Bomb.java


注:本文中的com.shatteredpixel.shatteredpixeldungeon.actors.Actor.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。