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


Java Level.NEIGHBOURS8属性代码示例

本文整理汇总了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);
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:22,代码来源:Yog.java

示例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];
		}
	}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:28,代码来源:Char.java

示例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 );
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:12,代码来源:Yog.java

示例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 );
    }
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:10,代码来源:NPC.java

示例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;
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:30,代码来源:Multiplicity.java

示例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;
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:32,代码来源:Bounce.java

示例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 );
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:34,代码来源:ScrollOfMirrorImage.java

示例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 );
	}
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:48,代码来源:SummoningTrap.java

示例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);
    }
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:48,代码来源:DriedRose.java

示例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 );
		
	}
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:58,代码来源:Pickaxe.java

示例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;
			
		}
	}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:50,代码来源:WellWater.java


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