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


Java PathFinder类代码示例

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


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

示例1: activate

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public void activate() {

	int nSeeds = Random.NormalIntRange(1, 5);

	ArrayList<Integer> candidates = new ArrayList<Integer>();
	for (int i : PathFinder.NEIGHBOURS8){
		if (Level.passable[pos+i]){
			candidates.add(pos+i);
		}
	}

	for (int i = 0; i < nSeeds && !candidates.isEmpty(); i++){
		Integer c = Random.element(candidates);
		Dungeon.level.drop(Generator.random(Generator.Category.SEED), c).sprite.drop(pos);
		candidates.remove(c);
	}

}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:20,代码来源:WandOfRegrowth.java

示例2: canAttack

import com.watabou.utils.PathFinder; //导入依赖的package包/类
public boolean canAttack(Char enemy){
	if (enemy == null || pos == enemy.pos)
		return false;

	//can always attack adjacent enemies
	if (Dungeon.level.adjacent(pos, enemy.pos))
		return true;

	KindOfWeapon wep = Dungeon.hero.belongings.weapon;

	if (wep != null && Dungeon.level.distance( pos, enemy.pos ) <= wep.reachFactor(this)){

		boolean[] passable = BArray.not(Level.solid, null);
		for (Mob m : Dungeon.level.mobs)
			passable[m.pos] = false;

		PathFinder.buildDistanceMap(enemy.pos, passable, wep.reachFactor(this));

		return PathFinder.distance[pos] <= wep.reachFactor(this);

	} else {
		return false;
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:25,代码来源:Hero.java

示例3: die

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public void die(Object cause) {
	ClusterBomb cbomb = new ClusterBomb();
	for (int n : PathFinder.NEIGHBOURS8DIST2) {
		int c = pos + n;
		if (Random.Int(3) == 0) {
			cbomb.explode(c);
			//spend(2f);
		}
	}

	yell("KA-BOOM!!! KA-BOOM!!! KA-BOOM!!!");


	super.die(cause);
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:17,代码来源:SeekingClusterBombNPC.java

示例4: findPath

import com.watabou.utils.PathFinder; //导入依赖的package包/类
public static int findPath( Char ch, int from, int to, boolean pass[], boolean[] visible ) {
	
	if (Level.adjacent( from, to )) {
		return Actor.findChar( to ) == null && (pass[to] || Level.avoid[to]) ? to : -1;
	}
	
	if (ch.flying || ch.buff( Amok.class ) != null || ch.buff( Rage.class ) != null) {
		BArray.or( pass, Level.avoid, passable );
	} else {
		System.arraycopy( pass, 0, passable, 0, Level.LENGTH );
	}
	
	for (Actor actor : Actor.all()) {
		if (actor instanceof Char) {
			int pos = ((Char)actor).pos;
			if (visible[pos]) {
				passable[pos] = false;
			}
		}
	}
	
	return PathFinder.getStep( from, to, passable );
	
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:25,代码来源:Dungeon.java

示例5: attackProc

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public int attackProc(Char enemy, int damage) {
	int dmg = super.attackProc(enemy, damage);

	ClusterBomb cbomb = new ClusterBomb();
	for (int n : PathFinder.NEIGHBOURS8DIST2) {
		int c = pos + n;
		if (Random.Int(3) == 0) {
			cbomb.explode(c);
			//spend(2f);
		}
	}

	yell(Messages.get(this, "atk"));

	destroy();
	sprite.die();

	return dmg;
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:21,代码来源:SeekingClusterBomb.java

示例6: flee

import com.watabou.utils.PathFinder; //导入依赖的package包/类
public static int flee( Char ch, int cur, int from, boolean pass[], boolean[] visible ) {
	
	if (ch.flying) {
		BArray.or( pass, Level.avoid, passable );
	} else {
		System.arraycopy( pass, 0, passable, 0, Level.LENGTH );
	}
	
	for (Actor actor : Actor.all()) {
		if (actor instanceof Char) {
			int pos = ((Char)actor).pos;
			if (visible[pos]) {
				passable[pos] = false;
			}
		}
	}
	passable[cur] = true;
	
	return PathFinder.getStepBack( cur, from, passable );
	
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:22,代码来源:Dungeon.java

示例7: arc

import com.watabou.utils.PathFinder; //导入依赖的package包/类
private void arc( Char ch ) {
	
	affected.add( ch );

	int dist;
	if (Level.water[ch.pos] && !ch.flying)
		dist = 2;
	else
		dist = 1;

		PathFinder.buildDistanceMap( ch.pos, BArray.not( Level.solid, null ), dist );
		for (int i = 0; i < PathFinder.distance.length; i++) {
			if (PathFinder.distance[i] < Integer.MAX_VALUE){
				Char n = Actor.findChar( i );
				if (n == Dungeon.hero && PathFinder.distance[i] > 1)
					//the hero is only zapped if they are adjacent
					continue;
				else if (n != null && !affected.contains( n )) {
					arcs.add(new Lightning.Arc(ch.pos, n.pos));
					arc(n);
				}
			}
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:25,代码来源:WandOfLightning.java

示例8: flee

import com.watabou.utils.PathFinder; //导入依赖的package包/类
public static int flee(Char ch, int cur, int from, boolean pass[], boolean[] visible) {

		setupPassable();
		if (ch.flying) {
			BArray.or(pass, Level.avoid, passable);
		} else {
			System.arraycopy(pass, 0, passable, 0, Dungeon.level.getLength());
		}

		for (Char c : Actor.chars()) {
			if (visible[c.pos]) {
				passable[c.pos] = false;
			}
		}
		passable[cur] = true;

		return PathFinder.getStepBack(cur, from, passable);

	}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:20,代码来源:Dungeon.java

示例9: shatter

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public void shatter( int cell ) {
	
	PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE );
	
	Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );

	boolean visible = false;
	for (int i=0; i < Dungeon.level.length(); i++) {
		if (PathFinder.distance[i] < Integer.MAX_VALUE) {
			visible = Freezing.affect( i, fire ) || visible;
		}
	}

	if (visible) {
		splash( cell );
		Sample.INSTANCE.play( Assets.SND_SHATTER );

		setKnown();
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:22,代码来源:PotionOfFrost.java

示例10: placeShopkeeper

import com.watabou.utils.PathFinder; //导入依赖的package包/类
private static void placeShopkeeper( Level level, Room room ) {
	
	int pos;
	do {
		pos = level.pointToCell(room.random());
	} while (level.heaps.get( pos ) != null);
	
	Mob shopkeeper = level instanceof LastShopLevel ? new ImpShopkeeper() : new Shopkeeper();
	shopkeeper.pos = pos;
	level.mobs.add( shopkeeper );
	
	if (level instanceof LastShopLevel) {
		for (int i = 0; i < PathFinder.NEIGHBOURS9.length; i++) {
			int p = shopkeeper.pos + PathFinder.NEIGHBOURS9[i];
			if (level.map[p] == Terrain.EMPTY_SP) {
				level.map[p] = Terrain.WATER;
			}
		}
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:21,代码来源:ShopPainter.java

示例11: shatter

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public void shatter( int cell ) {
	
	PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE );
	
	Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
	
	boolean visible = false;
	for (int i=0; i < Level.LENGTH; i++) {
		if (PathFinder.distance[i] < Integer.MAX_VALUE) {
			visible = Freezing.affect( i, fire ) || visible;
		}
	}
	
	if (visible) {
		splash( cell );
		Sample.INSTANCE.play( Assets.SND_SHATTER );
		
		setKnown();
	}
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:22,代码来源:PotionOfFrost.java

示例12: damageRoll

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public int damageRoll() {
	int min = 1;
	int max = (HP*2 <= HT) ? 15 : 10;
	if (pumpedUp > 0) {
		pumpedUp = 0;
		PathFinder.buildDistanceMap( pos, BArray.not( Level.solid, null ), 2 );
		for (int i = 0; i < PathFinder.distance.length; i++) {
			if (PathFinder.distance[i] < Integer.MAX_VALUE)
				CellEmitter.get(i).burst(ElmoParticle.FACTORY, 10);
		}
		Sample.INSTANCE.play( Assets.SND_BURNING );
		return Random.NormalIntRange( min*3, max*3 );
	} else {
		return Random.NormalIntRange( min, max );
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:18,代码来源:Goo.java

示例13: shatter

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
public void shatter( int cell ) {

	if (Dungeon.visible[cell]) {
		setKnown();

		splash( cell );
		Sample.INSTANCE.play( Assets.SND_SHATTER );
	}

	for (int offset : PathFinder.NEIGHBOURS9){
		if (Level.flamable[cell+offset]
				|| Actor.findChar(cell+offset) != null
				|| Dungeon.level.heaps.get(cell+offset) != null) {

			GameScene.add(Blob.seed(cell + offset, 2, Fire.class));

		} else {

			CellEmitter.get(cell+offset).burst(FlameParticle.FACTORY, 2);

		}
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:25,代码来源:PotionOfLiquidFlame.java

示例14: getSpawnPos

import com.watabou.utils.PathFinder; //导入依赖的package包/类
public int getSpawnPos() {
	int newPos = -1;
	int pos = Dungeon.hero.pos;
	ArrayList<Integer> candidates = new ArrayList<Integer>();
	boolean[] passable = Level.passable;

	for (int n : PathFinder.NEIGHBOURS8) {
		int c = pos + n;
		if (passable[c] && Actor.findChar(c) == null) {
			candidates.add(c);
		}
	}

	newPos = candidates.size() > 0 ? Random.element(candidates) : -1;

	return newPos;
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:18,代码来源:Whistle.java

示例15: onThrow

import com.watabou.utils.PathFinder; //导入依赖的package包/类
@Override
protected void onThrow(int cell) {

	if (Actor.findChar(cell) != null) {
		ArrayList<Integer> candidates = new ArrayList<>();
		for (int i : PathFinder.NEIGHBOURS8)
			if (Level.passable[cell + i])
				candidates.add(cell + i);
		int newCell = candidates.isEmpty() ? cell : Random
				.element(candidates);

		if (!Level.pit[newCell] && activate) {
			MrDestructo.spawnAt(newCell);
		} else {
			Dungeon.level.drop(this, newCell).sprite.drop(cell);
		}

	} else if (!Level.pit[cell] && activate) {
		MrDestructo.spawnAt(cell);
	} else {

		super.onThrow(cell);
	}

}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:26,代码来源:ActiveMrDestructo.java


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