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


Java PathFinder.buildDistanceMap方法代码示例

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


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

示例1: 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

示例2: 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.getLength(); 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:G2159687,项目名称:ESPD,代码行数:23,代码来源:PotionOfFrost.java

示例3: 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

示例4: autoAim

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
public static int autoAim(Char target, Item item){

		//first try to directly target
		if (item.throwPos(Dungeon.hero, target.pos) == target.pos) {
			return target.pos;
		}

		//Otherwise pick nearby tiles to try and 'angle' the shot, auto-aim basically.
		PathFinder.buildDistanceMap( target.pos, BArray.not( new boolean[Dungeon.level.length()], null ), 2 );
		for (int i = 0; i < PathFinder.distance.length; i++) {
			if (PathFinder.distance[i] < Integer.MAX_VALUE
					&& item.throwPos(Dungeon.hero, i) == target.pos)
				return i;
		}

		//couldn't find a cell, give up.
		return -1;
	}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:19,代码来源:QuickSlotButton.java

示例5: 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

示例6: 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

示例7: activate

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

	PathFinder
			.buildDistanceMap(pos, BArray.not(Level.losBlocking, null), 1);

	Fire fire = (Fire) Dungeon.level.blobs.get(Fire.class);

	for (int i = 0; i < Dungeon.level.getLength(); i++) {
		if (PathFinder.distance[i] < Integer.MAX_VALUE) {
			Freezing.affect(i, fire);
		}
	}
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:16,代码来源:Icecap.java

示例8: activate

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
@Override
public void activate() {
	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) {
			if (Level.pit[i] || Level.water[i])
				GameScene.add(Blob.seed(i, 1, Fire.class));
			else
				GameScene.add(Blob.seed(i, 5, Fire.class));
			CellEmitter.get(i).burst(FlameParticle.FACTORY, 5);
		}
	}
	Sample.INSTANCE.play(Assets.SND_BURNING);
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:15,代码来源:BlazingTrap.java

示例9: activate

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
@Override
public void activate() {
	
	PathFinder.buildDistanceMap( pos, BArray.not( Level.losBlocking, null ), 1 );
	
	Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
	
	for (int i=0; i < PathFinder.distance.length; i++) {
		if (PathFinder.distance[i] < Integer.MAX_VALUE) {
			Freezing.affect( i, fire );
		}
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:14,代码来源:Icecap.java

示例10: activate

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
@Override
public void activate( Char ch ) {
	super.activate( ch );
	
	PathFinder.buildDistanceMap( pos, BArray.not( Level.losBlocking, null ), 1 );
	
	Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
	
	for (int i=0; i < Level.LENGTH; i++) {
		if (PathFinder.distance[i] < Integer.MAX_VALUE) {
			Freezing.affect( i, fire );
		}
	}
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:15,代码来源:Icecap.java

示例11: summon

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
private void summon() {

		nextPedestal = !nextPedestal;

		sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.4f, 2);
		Sample.INSTANCE.play(Assets.SND_CHALLENGE);

		boolean[] passable = Level.passable.clone();
		for (Char c : Actor.chars()) {
			passable[c.pos] = false;
		}

		int undeadsToSummon = maxArmySize() - Undead.count;

		PathFinder.buildDistanceMap(pos, passable, undeadsToSummon);
		PathFinder.distance[pos] = Integer.MAX_VALUE;
		int dist = 1;

		undeadLabel:
		for (int i = 0; i < undeadsToSummon; i++) {
			do {
				for (int j = 0; j < Dungeon.level.getLength(); j++) {
					if (PathFinder.distance[j] == dist) {

						Undead undead = new Undead();
						undead.pos = j;
						GameScene.add(undead);

						WandOfBlink.appear(undead, j);
						new Flare(3, 32).color(0x000000, false).show(
								undead.sprite, 2f);

						PathFinder.distance[j] = Integer.MAX_VALUE;

						continue undeadLabel;
					}
				}
				dist++;
			} while (dist < undeadsToSummon);
		}

		yell(Messages.get(this, "summon"));
		HP += Random.Int(1, HT - HP);
		sprite.emitter().burst(ElmoParticle.FACTORY, 5);
	}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:46,代码来源:King.java

示例12: setupPatch

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
protected void setupPatch(Level level, float fill, int clustering, boolean ensurePath){

		if (ensurePath){
			PathFinder.setMapSize(width()-2, height()-2);
			boolean valid;
			do {
				patch = Patch.generate(width()-2, height()-2, fill, clustering, true);
				int startPoint = 0;
				for (Door door : connected.values()) {
					if (door.x == left) {
						startPoint = xyToPatchCoords(door.x + 1, door.y);
						patch[xyToPatchCoords(door.x + 1, door.y)] = false;
						patch[xyToPatchCoords(door.x + 2, door.y)] = false;
					} else if (door.x == right) {
						startPoint = xyToPatchCoords(door.x - 1, door.y);
						patch[xyToPatchCoords(door.x - 1, door.y)] = false;
						patch[xyToPatchCoords(door.x - 2, door.y)] = false;
					} else if (door.y == top) {
						startPoint = xyToPatchCoords(door.x, door.y + 1);
						patch[xyToPatchCoords(door.x, door.y + 1)] = false;
						patch[xyToPatchCoords(door.x, door.y + 2)] = false;
					} else if (door.y == bottom) {
						startPoint = xyToPatchCoords(door.x, door.y - 1);
						patch[xyToPatchCoords(door.x, door.y - 1)] = false;
						patch[xyToPatchCoords(door.x, door.y - 2)] = false;
					}
				}

				PathFinder.buildDistanceMap(startPoint, BArray.not(patch, null));

				valid = true;
				for (int i = 0; i < patch.length; i++){
					if (!patch[i] && PathFinder.distance[i] == Integer.MAX_VALUE){
						valid = false;
						break;
					}
				}
			} while (!valid);
			PathFinder.setMapSize(level.getWidth(), level.getHeight());
		} else {
			patch = Patch.generate(width()-2, height()-2, fill, clustering, true);
		}
	}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:44,代码来源:PatchRoom.java

示例13: onZap

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

	Sample.INSTANCE.play( Assets.SND_ROCKS );

	int level = power();

	Ballistica.distance = Math.min( Ballistica.distance, 8 + level );

	int size = 1 + level / 3;
	PathFinder.buildDistanceMap( cell, BArray.not( Level.solid, null ), size );

	int shake = 0;
	for (int i=0; i < Level.LENGTH; i++) {

		int d = PathFinder.distance[i];

		if (d < Integer.MAX_VALUE) {

			Char ch = Actor.findChar( i );
			if (ch != null) {

				ch.sprite.flash();
				ch.damage( Random.Int( 2, 6 + (size - d) * 2 ), this );

				if (ch.isAlive() && Random.Int( 2 + d ) == 0) {
					Buff.prolong( ch, Paralysis.class, Random.IntRange( 2, 6 ) );
				}
			}

			if (ch != null && ch.isAlive()) {
				if (ch instanceof Mob) {
					Dungeon.level.mobPress( (Mob)ch );
				} else {
					Dungeon.level.press( i, ch );
				}
			} else {
				Dungeon.level.press( i, null );
			}

			if (Dungeon.visible[i]) {
				CellEmitter.get(i).start(Speck.factory(Speck.ROCK), 0.07f, 3 + (size - d));
				if (Level.water[i]) {
					GameScene.ripple( i );
				}
				if (shake < size - d) {
					shake = size - d;
				}
			}
		}

		Camera.main.shake( 3, 0.07f * (3 + shake) );
	}

	if (!curUser.isAlive()) {
		Dungeon.fail( Utils.format( ResultDescriptions.WAND, name, Dungeon.depth ) );
		GLog.n( "You killed yourself with your own Wand of Avalanche..." );
	}
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:60,代码来源:WandOfAvalanche.java

示例14: onZap

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
@Override
protected void onZap(Ballistica bolt) {

	int level = level();

	int n = level + 2;

	int cell = bolt.collisionPos;

	boolean[] passable = BArray.or(Level.passable, Level.avoid, null);
	for (Char c : Actor.chars()) {
		passable[c.pos] = false;
	}

	PathFinder.buildDistanceMap(cell, passable, n);
	int dist = 0;

	if (Actor.findChar(cell) != null) {
		PathFinder.distance[cell] = Integer.MAX_VALUE;
		dist = 1;
	}

	float lifespan = (level <= 17) ? level + 3 : 20;

	sheepLabel:
	for (int i = 0; i < n; i++) {
		do {
			for (int j = 0; j < Dungeon.level.getLength(); j++) {
				if (PathFinder.distance[j] == dist) {

					Sheep sheep = new Sheep();
					sheep.lifespan = lifespan;
					sheep.pos = j;
					GameScene.add(sheep);
					Dungeon.level.mobPress(sheep);

					CellEmitter.get(j).burst(Speck.factory(Speck.WOOL), 4);

					PathFinder.distance[j] = Integer.MAX_VALUE;

					continue sheepLabel;
				}
			}
			dist++;
		} while (dist < n);
	}

	if (Dungeon.depth > 50 && Dungeon.depth < 55) {
		int spawnCell = Dungeon.level.randomRespawnCellMob();
		if (spawnCell > 0) {
			FlyingProtector.spawnAt(spawnCell);
			GLog.w(Messages.get(this, "s1"));
			GLog.w(Messages.get(this, "s2"));
		}
	}
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:57,代码来源:WandOfFlock.java

示例15: summon

import com.watabou.utils.PathFinder; //导入方法依赖的package包/类
private void summon() {

		nextPedestal = !nextPedestal;
		
		sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.4f, 2 );
		Sample.INSTANCE.play( Assets.SND_CHALLENGE );
		
		boolean[] passable = Level.passable.clone();
		for (Char c : Actor.chars()) {
			passable[c.pos] = false;
		}
		
		int undeadsToSummon = maxArmySize() - Undead.count;

		PathFinder.buildDistanceMap( pos, passable, undeadsToSummon );
		PathFinder.distance[pos] = Integer.MAX_VALUE;
		int dist = 1;
		
	undeadLabel:
		for (int i=0; i < undeadsToSummon; i++) {
			do {
				for (int j=0; j < Dungeon.level.length(); j++) {
					if (PathFinder.distance[j] == dist) {
						
						Undead undead = new Undead();
						undead.pos = j;
						GameScene.add( undead );
						
						ScrollOfTeleportation.appear( undead, j );
						new Flare( 3, 32 ).color( 0x000000, false ).show( undead.sprite, 2f ) ;
						
						PathFinder.distance[j] = Integer.MAX_VALUE;
						
						continue undeadLabel;
					}
				}
				dist++;
			} while (dist < undeadsToSummon);
		}
		
		yell( Messages.get(this, "arise") );
	}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:43,代码来源:King.java


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