本文整理汇总了Java中com.watabou.utils.PathFinder.NEIGHBOURS4属性的典型用法代码示例。如果您正苦于以下问题:Java PathFinder.NEIGHBOURS4属性的具体用法?Java PathFinder.NEIGHBOURS4怎么用?Java PathFinder.NEIGHBOURS4使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.watabou.utils.PathFinder
的用法示例。
在下文中一共展示了PathFinder.NEIGHBOURS4属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spawnAround
public static void spawnAround(int pos) {
for (int n : PathFinder.NEIGHBOURS4) {
int cell = pos + n;
if (Level.passable[cell] && Actor.findChar(cell) == null) {
spawnAt(cell);
}
}
}
示例2: spawnAroundChance
public static void spawnAroundChance(int pos) {
for (int n : PathFinder.NEIGHBOURS4) {
int cell = pos + n;
if (Level.passable[cell] && Actor.findChar(cell) == null && Random.Float() < 0.75f) {
spawnAt(cell);
}
}
}
示例3: spawnAroundChance
public static void spawnAroundChance(int pos) {
for (int n : PathFinder.NEIGHBOURS4) {
int cell = pos + n;
if (Level.passable[cell] && Actor.findChar(cell) == null && Random.Float() < 0.25f) {
spawnAt(cell);
GLog.i(Messages.get(Lichen.class, "spawn"));
}
}
}
示例4: spawnAroundChance
public static void spawnAroundChance(int pos) {
for (int n : PathFinder.NEIGHBOURS4) {
int cell = pos + n;
if (Level.passable[cell] && Actor.findChar(cell) == null && Random.Float() < 0.50f) {
spawnAt(cell);
}
}
}
示例5: spawnAround
public static void spawnAround(int pos) {
for (int n : PathFinder.NEIGHBOURS4) {
GLog.n(Messages.get(PoisonGoo.class, "squeeze"));
int cell = pos + n;
if (Level.passable[cell] && Actor.findChar(cell) == null) {
spawnAt(cell);
GLog.n(Messages.get(PoisonGoo.class, "create"));
}
}
}
示例6: flood
private void flood(int distance, Hero hero) {
charge = 0;
ArrayList<Integer> affected = new ArrayList<Integer>();
int length = Dungeon.level.getLength();
int width = Dungeon.level.getWidth();
for (int i = width; i < length - width; i++) {
int dist = Dungeon.level.distance(hero.pos, i);
if (dist < distance) {
//GLog.i("TRI2 %s", dist);
if (checkFloodable(i)) {
affected.add(i);
Dungeon.level.map[i] = Terrain.WATER;
Level.water[i] = true;
}
}
}
//GLog.i("TRI1 %s", length);
for (int n : affected) {
int t = Terrain.WATER_TILES;
for (int j = 0; j < PathFinder.NEIGHBOURS4.length; j++) {
if ((Terrain.flags[Dungeon.level.map[n + PathFinder.NEIGHBOURS4[j]]] & Terrain.UNSTITCHABLE) != 0) {
t += 1 << j;
}
}
Char ch = Actor.findChar(n);
if (ch != null && ch != hero) {
Buff.affect(ch, Slow.class, Slow.duration(ch) / 3 + level);
}
Dungeon.level.map[n] = t;
//Level.water[i] = true;
GameScene.updateMap(n);
}
Dungeon.observe();
}
示例7: spawnAround
public static void spawnAround( int pos ) {
for (int n : PathFinder.NEIGHBOURS4) {
int cell = pos + n;
if (Level.passable[cell] && Actor.findChar( cell ) == null) {
spawnAt( cell );
}
}
}
示例8: destroy
public void destroy( int pos ) {
if (!DungeonTilemap.waterStitcheable.contains(map[pos])) {
for (int j = 0; j < PathFinder.NEIGHBOURS4.length; j++) {
if (water[pos + PathFinder.NEIGHBOURS4[j]]) {
set(pos, Terrain.WATER);
return;
}
}
}
set( pos, Terrain.EMBERS );
}
示例9: buildFlagMaps
protected void buildFlagMaps() {
for (int i = 0; i < getLength(); i++) {
int flags = Terrain.flags[map[i]];
passable[i] = (flags & Terrain.PASSABLE) != 0;
losBlocking[i] = (flags & Terrain.LOS_BLOCKING) != 0;
flamable[i] = (flags & Terrain.FLAMABLE) != 0;
secret[i] = (flags & Terrain.SECRET) != 0;
solid[i] = (flags & Terrain.SOLID) != 0;
avoid[i] = (flags & Terrain.AVOID) != 0;
water[i] = (flags & Terrain.LIQUID) != 0;
pit[i] = (flags & Terrain.PIT) != 0;
}
int lastRow = getLength() - getWidth();
for (int i = 0; i < getWidth(); i++) {
passable[i] = avoid[i] = false;
passable[lastRow + i] = avoid[lastRow + i] = false;
}
for (int i = getWidth(); i < lastRow; i += getWidth()) {
passable[i] = avoid[i] = false;
passable[i + getWidth() - 1] = avoid[i + getWidth() - 1] = false;
}
for (int i = getWidth(); i < getLength() - getWidth(); i++) {
if (water[i]) {
int t = Terrain.WATER_TILES;
for (int j = 0; j < PathFinder.NEIGHBOURS4.length; j++) {
if ((Terrain.flags[map[i + PathFinder.NEIGHBOURS4[j]]] & Terrain.UNSTITCHABLE) != 0) {
t += 1 << j;
}
}
map[i] = t;
}
if (pit[i]) {
if (!pit[i - getWidth()]) {
int c = map[i - getWidth()];
if (c == Terrain.EMPTY_SP || c == Terrain.STATUE_SP) {
map[i] = Terrain.CHASM_FLOOR_SP;
} else if (water[i - getWidth()]) {
map[i] = Terrain.CHASM_WATER;
} else if ((Terrain.flags[c] & Terrain.UNSTITCHABLE) != 0) {
map[i] = Terrain.CHASM_WALL;
} else {
map[i] = Terrain.CHASM_FLOOR;
}
}
}
}
}
示例10: shatter
public Item shatter(Char owner, int pos) {
if (Dungeon.visible[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 = 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 && !Dungeon.hero.haspet) {
bee bee = new bee();
bee.spawn(1);
bee.HP = bee.HT;
bee.pos = newPos;
bee.state = bee.HUNTING;
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);
Dungeon.hero.haspet = true;
GLog.p(Messages.get(SteelHoneypot.class, "str"));
return new PotionOfStrength();
} else {
return this;
}
}
示例11: shatter
public Item shatter(Char owner, int pos) {
if (Dungeon.visible[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 = 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;
}
}
示例12: shatter
public Item shatter( Char owner, int pos ) {
if (Dungeon.visible[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 = 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;
}
}