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


Java Pushing类代码示例

本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.effects.Pushing的典型用法代码示例。如果您正苦于以下问题:Java Pushing类的具体用法?Java Pushing怎么用?Java Pushing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: defenseProc

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {

	ArrayList<Integer> spawnPoints = new ArrayList<Integer>();
	
	for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
		int p = pos + Level.NEIGHBOURS8[i];
		if (Actor.findChar( p ) == null && (Level.passable[p] || Level.avoid[p])) {
			spawnPoints.add( p );
		}
	}
	
	if (spawnPoints.size() > 0) {
		Larva larva = new Larva();
		larva.pos = Random.element( spawnPoints );
		
		GameScene.add( larva );
		Actor.addDelayed( new Pushing( larva, pos, larva.pos ), -1 );
	}

	return super.defenseProc(enemy, damage);
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:23,代码来源:Yog.java

示例2: defenseProc

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {

	if (HP >= damage + 2) {
		ArrayList<Integer> candidates = new ArrayList<Integer>();
		boolean[] passable = Level.passable;
		
		int[] neighbours = {pos + 1, pos - 1, pos + Level.WIDTH, pos - Level.WIDTH};
		for (int n : neighbours) {
			if (passable[n] && Actor.findChar( n ) == null) {
				candidates.add( n );
			}
		}

		if (candidates.size() > 0) {
			
			Swarm clone = split();
			clone.HP = (HP - damage) / 2;
			clone.pos = Random.element( candidates );
			clone.state = clone.HUNTING;
			
			if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
				Door.enter( clone.pos );
			}
			
			GameScene.add( clone, SPLIT_DELAY );
			Actor.addDelayed( new Pushing( clone, pos, clone.pos ), -1 );
			
			HP -= clone.HP;
		}
	}
	
	return damage;
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:35,代码来源:Swarm.java

示例3: proc

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {

	int level = Math.max( 0, armor.level );
	
	if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level + 5) >= 4) {
		
		for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
			int ofs = Level.NEIGHBOURS8[i];
			if (attacker.pos - defender.pos == ofs) {
				int newPos = attacker.pos + ofs;
				if ((Level.passable[newPos] || Level.avoid[newPos]) && Actor.findChar( newPos ) == null) {
					
					Actor.addDelayed( new Pushing( attacker, attacker.pos, newPos ), -1 );
					
					attacker.pos = newPos;
					// FIXME
					if (attacker instanceof Mob) {
						Dungeon.level.mobPress( (Mob)attacker );
					} else {
						Dungeon.level.press( newPos, attacker );
					}
					
				}
				break;
			}
		}

	}
	
	return damage;
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:33,代码来源:Bounce.java

示例4: defenseProc

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {

	ArrayList<Integer> spawnPoints = new ArrayList<>();
	
	for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
		int p = pos + PathFinder.NEIGHBOURS8[i];
		if (Actor.findChar( p ) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
			spawnPoints.add( p );
		}
	}
	
	if (spawnPoints.size() > 0) {
		Larva larva = new Larva();
		larva.pos = Random.element( spawnPoints );
		
		GameScene.add( larva );
		Actor.addDelayed( new Pushing( larva, pos, larva.pos ), -1 );
	}

	for (Mob mob : Dungeon.level.mobs) {
		if (mob instanceof BurningFist || mob instanceof RottingFist || mob instanceof Larva) {
			mob.aggro( enemy );
		}
	}

	return super.defenseProc(enemy, damage);
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:29,代码来源:Yog.java

示例5: defenseProc

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {

	if (HP >= damage + 2) {
		ArrayList<Integer> candidates = new ArrayList<>();
		boolean[] solid = Dungeon.level.solid;
		
		int[] neighbours = {pos + 1, pos - 1, pos + Dungeon.level.width(), pos - Dungeon.level.width()};
		for (int n : neighbours) {
			if (!solid[n] && Actor.findChar( n ) == null) {
				candidates.add( n );
			}
		}

		if (candidates.size() > 0) {
			
			Swarm clone = split();
			clone.HP = (HP - damage) / 2;
			clone.pos = Random.element( candidates );
			clone.state = clone.HUNTING;
			
			if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
				Door.enter( clone.pos );
			}
			
			GameScene.add( clone, SPLIT_DELAY );
			Actor.addDelayed( new Pushing( clone, pos, clone.pos ), -1 );
			
			HP -= clone.HP;
		}
	}
	
	return super.defenseProc(enemy, damage);
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:35,代码来源:Swarm.java

示例6: throwChar

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
public static void throwChar(final Char ch, final Ballistica trajectory, int power){
	int dist = Math.min(trajectory.dist, power);

	if (ch.properties().contains(Char.Property.BOSS))
		dist /= 2;

	if (dist == 0 || ch.properties().contains(Char.Property.IMMOVABLE)) return;

	if (Actor.findChar(trajectory.path.get(dist)) != null){
		dist--;
	}

	final int newPos = trajectory.path.get(dist);

	if (newPos == ch.pos) return;

	final int finalDist = dist;
	final int initialpos = ch.pos;

	Actor.addDelayed(new Pushing(ch, ch.pos, newPos, new Callback() {
		public void call() {
			if (initialpos != ch.pos) {
				//something cased movement before pushing resolved, cancel to be safe.
				ch.sprite.place(ch.pos);
				return;
			}
			ch.pos = newPos;
			if (ch.pos == trajectory.collisionPos) {
				ch.damage(Random.NormalIntRange((finalDist + 1) / 2, finalDist), this);
				Paralysis.prolong(ch, Paralysis.class, Random.NormalIntRange((finalDist + 1) / 2, finalDist));
			}
			Dungeon.level.press(ch.pos, ch);
			if (ch == Dungeon.hero){
				Dungeon.observe();
			}
		}
	}), -1);
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:39,代码来源:WandOfBlastWave.java

示例7: spawnAt

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
public static Mimic spawnAt( int pos, List<Item> items ) {
	if (Dungeon.level.pit[pos]) return null;
	Char ch = Actor.findChar( pos );
	if (ch != null) {
		ArrayList<Integer> candidates = new ArrayList<>();
		for (int n : PathFinder.NEIGHBOURS8) {
			int cell = pos + n;
			if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar( cell ) == null) {
				candidates.add( cell );
			}
		}
		if (candidates.size() > 0) {
			int newPos = Random.element( candidates );
			Actor.addDelayed( new Pushing( ch, ch.pos, newPos ), -1 );
			
			ch.pos = newPos;
			// FIXME
			if (ch instanceof Mob) {
				Dungeon.level.mobPress( (Mob)ch );
			} else {
				Dungeon.level.press( newPos, ch );
			}
		} else {
			return null;
		}
	}
	
	Mimic m = new Mimic();
	m.items = new ArrayList<>( items );
	m.adjustStats( Dungeon.depth );
	m.pos = pos;
	m.state = m.HUNTING;
	GameScene.add( m, 1 );
	
	m.sprite.turnTo( pos, Dungeon.hero.pos );
	
	if (Dungeon.level.heroFOV[m.pos]) {
		CellEmitter.get( pos ).burst( Speck.factory( Speck.STAR ), 10 );
		Sample.INSTANCE.play( Assets.SND_MIMIC );
	}

	//generate an extra reward for killing the mimic
	switch(Random.Int(5)){
		case 0: case 1:
			m.items.add(new Gold().random()); break;
		case 2:
			m.items.add(Generator.randomArmor().identify()); break;
		case 3:
			m.items.add(Generator.randomWeapon().identify()); break;
		case 4:
			m.items.add(Generator.random(Generator.Category.RING).identify()); break;
	}
	
	return m;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:56,代码来源:Mimic.java

示例8: chainEnemy

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
private void chainEnemy( Ballistica chain, final Hero hero, final Char enemy ){
	
	if (enemy.properties().contains(Char.Property.IMMOVABLE)) {
		GLog.w( Messages.get(this, "cant_pull") );
		return;
	}
	
	int bestPos = -1;
	for (int i : chain.subPath(1, chain.dist)){
		//prefer to the earliest point on the path
		if (!Dungeon.level.solid[i] && Actor.findChar(i) == null){
			bestPos = i;
			break;
		}
	}
	
	if (bestPos == -1) {
		GLog.i(Messages.get(this, "does_nothing"));
		return;
	}
	
	final int pulledPos = bestPos;
	
	int chargeUse = Dungeon.level.distance(enemy.pos, pulledPos);
	if (chargeUse > charge) {
		GLog.w( Messages.get(this, "no_charge") );
		return;
	} else {
		charge -= chargeUse;
		updateQuickslot();
	}
	
	hero.busy();
	hero.sprite.parent.add(new Chains(hero.sprite.center(), enemy.sprite.center(), new Callback() {
		public void call() {
			Actor.add(new Pushing(enemy, enemy.pos, pulledPos, new Callback() {
				public void call() {
					Dungeon.level.press(pulledPos, enemy);
				}
			}));
			enemy.pos = pulledPos;
			Dungeon.observe();
			GameScene.updateFog();
			hero.spendAndNext(1f);
		}
	}));
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:48,代码来源:EtherealChains.java

示例9: shatter

import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; //导入依赖的package包/类
public Item shatter( Char owner, int pos ) {
	
	if (Dungeon.level.heroFOV[pos]) {
		Sample.INSTANCE.play( Assets.SND_SHATTER );
		Splash.at( pos, 0xffd500, 5 );
	}
	
	int newPos = pos;
	if (Actor.findChar( pos ) != null) {
		ArrayList<Integer> candidates = new ArrayList<Integer>();
		boolean[] passable = Dungeon.level.passable;
		
		for (int n : PathFinder.NEIGHBOURS4) {
			int c = pos + n;
			if (passable[c] && Actor.findChar( c ) == null) {
				candidates.add( c );
			}
		}

		newPos = candidates.size() > 0 ? Random.element( candidates ) : -1;
	}
	
	if (newPos != -1) {
		Bee bee = new Bee();
		bee.spawn( Dungeon.depth );
		bee.setPotInfo( pos, owner );
		bee.HP = bee.HT;
		bee.pos = newPos;
		
		GameScene.add( bee );
		Actor.addDelayed( new Pushing( bee, pos, newPos ), -1f );
		
		bee.sprite.alpha( 0 );
		bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) );
		
		Sample.INSTANCE.play( Assets.SND_BEE );
		return new ShatteredPot().setBee( bee );
	} else {
		return this;
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:42,代码来源:Honeypot.java


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