本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.levels.Level.NEIGHBOURS8属性的典型用法代码示例。如果您正苦于以下问题:Java Level.NEIGHBOURS8属性的具体用法?Java Level.NEIGHBOURS8怎么用?Java Level.NEIGHBOURS8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.shatteredpixel.shatteredpixeldungeon.levels.Level
的用法示例。
在下文中一共展示了Level.NEIGHBOURS8属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defenseProc
@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);
}
示例2: move
public void move( int step ) {
if (buff( Vertigo.class ) != null) {
ArrayList<Integer> candidates = new ArrayList<Integer>();
for (int dir : Level.NEIGHBOURS8) {
int p = pos + dir;
if ((Level.passable[p] || Level.avoid[p]) && Actor.findChar( p ) == null) {
candidates.add( p );
}
}
step = Random.element( candidates );
}
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];
}
}
示例3: spawnFists
public void spawnFists() {
RottingFist fist1 = new RottingFist();
BurningFist fist2 = new BurningFist();
do {
fist1.pos = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
fist2.pos = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[fist1.pos] || !Level.passable[fist2.pos] || fist1.pos == fist2.pos);
GameScene.add( fist1 );
GameScene.add( fist2 );
}
示例4: throwItem
protected void throwItem() {
Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) {
int n;
do {
n = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[n] && !Level.avoid[n]);
Dungeon.level.drop( heap.pickUp(), n ).sprite.drop( pos );
}
}
示例5: proc
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level );
if (Random.Int( level / 2 + 6 ) >= 5) {
ArrayList<Integer> respawnPoints = new ArrayList<Integer>();
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
int p = defender.pos + Level.NEIGHBOURS8[i];
if (Actor.findChar( p ) == null && (Level.passable[p] || Level.avoid[p])) {
respawnPoints.add( p );
}
}
if (respawnPoints.size() > 0) {
MirrorImage mob = new MirrorImage();
mob.duplicate( (Hero)defender );
GameScene.add( mob );
WandOfBlink.appear( mob, Random.element( respawnPoints ) );
defender.damage( Random.IntRange( 1, defender.HT / 6 ), /*attacker*/ this );
checkOwner( defender );
}
}
return damage;
}
示例6: proc
@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;
}
示例7: doRead
@Override
protected void doRead() {
ArrayList<Integer> respawnPoints = new ArrayList<Integer>();
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
int p = curUser.pos + Level.NEIGHBOURS8[i];
if (Actor.findChar( p ) == null && (Level.passable[p] || Level.avoid[p])) {
respawnPoints.add( p );
}
}
int nImages = NIMAGES;
while (nImages > 0 && respawnPoints.size() > 0) {
int index = Random.index( respawnPoints );
MirrorImage mob = new MirrorImage();
mob.duplicate( curUser );
GameScene.add( mob );
WandOfBlink.appear( mob, respawnPoints.get( index ) );
respawnPoints.remove( index );
nImages--;
}
if (nImages < NIMAGES) {
setKnown();
}
Sample.INSTANCE.play( Assets.SND_READ );
Invisibility.dispel();
curUser.spendAndNext( TIME_TO_READ );
}
示例8: trigger
public static void trigger( int pos, Char c ) {
if (Dungeon.bossLevel()) {
return;
}
if (c != null) {
Actor.occupyCell( c );
}
int nMobs = 1;
if (Random.Int( 2 ) == 0) {
nMobs++;
if (Random.Int( 2 ) == 0) {
nMobs++;
}
}
// It's complicated here, because these traps can be activated in chain
ArrayList<Integer> candidates = 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])) {
candidates.add( p );
}
}
ArrayList<Integer> respawnPoints = new ArrayList<Integer>();
while (nMobs > 0 && candidates.size() > 0) {
int index = Random.index( candidates );
DUMMY.pos = candidates.get( index );
Actor.occupyCell( DUMMY );
respawnPoints.add( candidates.remove( index ) );
nMobs--;
}
for (Integer point : respawnPoints) {
Mob mob = Bestiary.mob( Dungeon.depth );
mob.state = mob.WANDERING;
GameScene.add( mob, DELAY );
WandOfBlink.appear( mob, point );
}
}
示例9: execute
@Override
public void execute( Hero hero, String action ) {
if (action.equals(AC_SUMMON)) {
if (spawned) GLog.n("sad ghost: \"I'm already here\"");
else if (!isEquipped( hero )) GLog.i("You need to equip your rose to do that.");
else if (charge != chargeCap) GLog.i("Your rose isn't fully charged yet.");
else if (cursed) GLog.i("You cannot use a cursed rose.");
else {
ArrayList<Integer> spawnPoints = new ArrayList<Integer>();
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
int p = hero.pos + Level.NEIGHBOURS8[i];
if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
spawnPoints.add(p);
}
}
if (spawnPoints.size() > 0) {
GhostHero ghost = new GhostHero( level );
ghost.pos = Random.element(spawnPoints);
GameScene.add(ghost, 1f);
CellEmitter.get(ghost.pos).start( ShaftParticle.FACTORY, 0.3f, 4 );
CellEmitter.get(ghost.pos).start( Speck.factory(Speck.LIGHT), 0.2f, 3 );
hero.spend(1f);
hero.busy();
hero.sprite.operate(hero.pos);
if (!firstSummon) {
ghost.yell(ghost.VOICE_HELLO + Dungeon.hero.givenName());
Sample.INSTANCE.play( Assets.SND_GHOST );
firstSummon = true;
} else
ghost.saySpawned();
spawned = true;
charge = 0;
updateQuickslot();
} else
GLog.i("There is no free space near you.");
}
} else{
super.execute(hero, action);
}
}
示例10: execute
@Override
public void execute( final Hero hero, String action ) {
if (action == AC_MINE) {
if (Dungeon.depth < 11 || Dungeon.depth > 15) {
GLog.w( TXT_NO_VEIN );
return;
}
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
final int pos = hero.pos + Level.NEIGHBOURS8[i];
if (Dungeon.level.map[pos] == Terrain.WALL_DECO) {
hero.spend( TIME_TO_MINE );
hero.busy();
hero.sprite.attack( pos, new Callback() {
@Override
public void call() {
CellEmitter.center( pos ).burst( Speck.factory( Speck.STAR ), 7 );
Sample.INSTANCE.play( Assets.SND_EVOKE );
Level.set( pos, Terrain.WALL );
GameScene.updateMap( pos );
DarkGold gold = new DarkGold();
if (gold.doPickUp( Dungeon.hero )) {
GLog.i( Hero.TXT_YOU_NOW_HAVE, gold.name() );
} else {
Dungeon.level.drop( gold, hero.pos ).sprite.drop();
}
Hunger hunger = hero.buff( Hunger.class );
if (hunger != null && !hunger.isStarving()) {
hunger.satisfy( -Hunger.STARVING / 10 );
BuffIndicator.refreshHero();
}
hero.onOperateComplete();
}
} );
return;
}
}
GLog.w( TXT_NO_VEIN );
} else {
super.execute( hero, action );
}
}
示例11: affect
protected boolean affect() {
Heap heap;
if (pos == Dungeon.hero.pos && affectHero( Dungeon.hero )) {
volume = off[pos] = cur[pos] = 0;
return true;
} else if ((heap = Dungeon.level.heaps.get( pos )) != null) {
Item oldItem = heap.peek();
Item newItem = affectItem( oldItem );
if (newItem != null) {
if (newItem == oldItem) {
} else if (oldItem.quantity() > 1) {
oldItem.quantity( oldItem.quantity() - 1 );
heap.drop( newItem );
} else {
heap.replace( oldItem, newItem );
}
heap.sprite.link();
volume = off[pos] = cur[pos] = 0;
return true;
} else {
int newPlace;
do {
newPlace = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[newPlace] && !Level.avoid[newPlace]);
Dungeon.level.drop( heap.pickUp(), newPlace ).sprite.drop( pos );
return false;
}
} else {
return false;
}
}