本文整理汇总了Java中com.watabou.utils.PathFinder.NEIGHBOURS8属性的典型用法代码示例。如果您正苦于以下问题:Java PathFinder.NEIGHBOURS8属性的具体用法?Java PathFinder.NEIGHBOURS8怎么用?Java PathFinder.NEIGHBOURS8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.watabou.utils.PathFinder
的用法示例。
在下文中一共展示了PathFinder.NEIGHBOURS8属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onThrow
@Override
protected void onThrow(int cell) {
if (!Level.pit[cell] && lightingFuse) {
Actor.addDelayed(fuse = new Fuse().ignite(this), 2);
}
if (Actor.findChar(cell) != null
&& !(Actor.findChar(cell) instanceof Hero)) {
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);
Dungeon.level.drop(this, newCell).sprite.drop(cell);
} else
super.onThrow(cell);
}
示例2: activate
@Override
public void activate() {
int nDrops = Random.NormalIntRange(2, 8);
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 < nDrops && !candidates.isEmpty(); i++){
Integer c = Random.element(candidates);
Dungeon.level.drop(new Dewdrop(), c).sprite.drop(pos);
candidates.remove(c);
}
}
示例3: onThrow
@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) {
OrbOfZotMob.spawnAt(newCell);
} else {
Dungeon.level.drop(this, newCell).sprite.drop(cell);
}
} else if (!Level.pit[cell] && activate) {
OrbOfZotMob.spawnAt(cell);
} else {
super.onThrow(cell);
}
}
示例4: onThrow
@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] && seek) {
SeekingClusterBombNPC.spawnAt(newCell);
} else {
Dungeon.level.drop(this, newCell).sprite.drop(cell);
}
} else if (!Level.pit[cell] && seek) {
SeekingClusterBombNPC.spawnAt(cell);
} else {
super.onThrow(cell);
}
}
示例5: onThrow
@Override
protected void onThrow(int cell) {
if (!Level.pit[cell] && lightingFuse) {
Actor.addDelayed(fuse = new Fuse().ignite(this), 2);
}
if (Actor.findChar(cell) != null
&& !(Actor.findChar(cell) instanceof Hero)) {
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);
Dungeon.level.drop(this, newCell).sprite.drop(cell);
} else
super.onThrow(cell);
}
示例6: getSpawnPos
public int getSpawnPos() {
int newPos;
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;
}
示例7: move
public void move(int step) {
if (Dungeon.level.adjacent(step, pos) && buff(Vertigo.class) != null) {
sprite.interruptMotion();
int newPos = pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
if (!(Level.passable[newPos] || Level.avoid[newPos]) || Actor.findChar(newPos) != null)
return;
else {
sprite.move(pos, newPos);
step = newPos;
}
}
if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) {
Door.leave(pos);
}
pos = step;
if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
Door.enter(pos);
}
if (this != Dungeon.hero) {
sprite.visible = Dungeon.visible[pos];
}
}
示例8: checkpetNear
private boolean checkpetNear() {
for (int n : PathFinder.NEIGHBOURS8) {
int c = pos + n;
if (Actor.findChar(c) instanceof PET) {
return true;
}
}
return false;
}
示例9: randomRespawnCell
@Override
public int randomRespawnCell() {
int cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
while (!passable[cell]){
cell = entrance + PathFinder.NEIGHBOURS8[Random.Int(8)];
}
return cell;
}
示例10: checkpetNear
private boolean checkpetNear() {
Hero hero = Dungeon.hero;
for (int n : PathFinder.NEIGHBOURS8) {
int c = hero.pos + n;
if (Actor.findChar(c) instanceof PET) {
return true;
}
}
return false;
}
示例11: placePlant
private static void placePlant(Level level, int pos, Mob plant){
plant.pos = pos;
level.mobs.add( plant );
for(int i : PathFinder.NEIGHBOURS8) {
if (level.map[pos + i] == Terrain.GRASS){
set(level, pos + i, Terrain.HIGH_GRASS);
}
}
}
示例12: spawnFists
public void spawnFists() {
RottingFist fist1 = new RottingFist();
BurningFist fist2 = new BurningFist();
do {
fist1.pos = pos + PathFinder.NEIGHBOURS8[Random.Int( 8 )];
fist2.pos = pos + PathFinder.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[fist1.pos] || !Level.passable[fist2.pos] || fist1.pos == fist2.pos);
GameScene.add( fist1 );
GameScene.add( fist2 );
notice();
}
示例13: checkpetNear
private boolean checkpetNear() {
for (int n : PathFinder.NEIGHBOURS8) {
int c = Dungeon.hero.pos + n;
if (Actor.findChar(c) instanceof PET) {
return true;
}
}
return false;
}
示例14: throwItem
protected void throwItem() {
Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) {
int n;
do {
n = pos + PathFinder.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[n] && !Level.avoid[n]);
Dungeon.level.drop( heap.pickUp(), n ).sprite.drop( pos );
}
}
示例15: blink
private void blink( int target ) {
Ballistica route = new Ballistica( pos, target, Ballistica.PROJECTILE);
int cell = route.collisionPos;
//can't occupy the same cell as another char, so move back one.
if (Actor.findChar( cell ) != null && cell != this.pos)
cell = route.path.get(route.dist-1);
if (Level.avoid[ cell ]){
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
cell = route.collisionPos + n;
if (Level.passable[cell] && Actor.findChar( cell ) == null) {
candidates.add( cell );
}
}
if (candidates.size() > 0)
cell = Random.element(candidates);
else {
delay = BLINK_DELAY;
return;
}
}
ScrollOfTeleportation.appear( this, cell );
delay = BLINK_DELAY;
}