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


Java Level.avoid方法代码示例

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


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

示例1: defenseProc

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
@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,代码行数:23,代码来源:Yog.java

示例2: findPath

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
public static int findPath( Char ch, int from, int to, boolean pass[], boolean[] visible ) {
	
	if (Level.adjacent( from, to )) {
		return Actor.findChar( to ) == null && (pass[to] || Level.avoid[to]) ? to : -1;
	}
	
	if (ch.flying || ch.buff( Amok.class ) != null) {
		BArray.or( pass, Level.avoid, passable );
	} else {
		System.arraycopy( pass, 0, passable, 0, Level.LENGTH );
	}
	
	for (Actor actor : Actor.all()) {
		if (actor instanceof Char) {
			int pos = ((Char)actor).pos;
			if (visible[pos]) {
				passable[pos] = false;
			}
		}
	}
	
	return PathFinder.getStep( from, to, passable );
	
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:25,代码来源:Dungeon.java

示例3: move

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
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,代码行数:29,代码来源:Char.java

示例4: throwItem

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
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,代码行数:11,代码来源:NPC.java

示例5: onSelect

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
@Override
public void onSelect( Integer target ) {
	if (target != null) {

		if (!Level.fieldOfView[target] || 
			!(Level.passable[target] || Level.avoid[target]) || 
			Actor.findChar( target ) != null) {
			
			GLog.w( TXT_FOV );
			return;
		}

              curUser.HP -= (curUser.HP / 3);
		
		for (Mob mob : Dungeon.level.mobs) {
			if (Level.fieldOfView[mob.pos]) {
				Buff.prolong( mob, Blindness.class, 2 );
				mob.state = mob.WANDERING;
				mob.sprite.emitter().burst( Speck.factory( Speck.LIGHT ), 4 );
			}
		}
		
		WandOfBlink.appear( curUser, target );
		CellEmitter.get( target ).burst( Speck.factory( Speck.WOOL ), 10 );
		Sample.INSTANCE.play( Assets.SND_PUFF );
		Dungeon.level.press( target, curUser );
		Dungeon.observe();
		
		curUser.spendAndNext( Actor.TICK );
	}
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:32,代码来源:RogueArmor.java

示例6: proc

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
@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,代码行数:31,代码来源:Multiplicity.java

示例7: proc

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
@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,代码行数:33,代码来源:Bounce.java

示例8: doRead

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
@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,代码行数:35,代码来源:ScrollOfMirrorImage.java

示例9: cast

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
public static int cast( int from, int to, boolean magic, boolean hitChars ) {
	
	int w = Level.WIDTH;
	
	int x0 = from % w;
	int x1 = to % w;
	int y0 = from / w;
	int y1 = to / w;
	
	int dx = x1 - x0;
	int dy = y1 - y0;
	
	int stepX = dx > 0 ? +1 : -1;
	int stepY = dy > 0 ? +1 : -1;
	
	dx = Math.abs( dx );
	dy = Math.abs( dy );
	
	int stepA;
	int stepB;
	int dA;
	int dB;
	
	if (dx > dy) {
		
		stepA = stepX;
		stepB = stepY * w;
		dA = dx;
		dB = dy;

	} else {
		
		stepA = stepY * w;
		stepB = stepX;
		dA = dy;
		dB = dx;

	}

	distance = 1;
	trace[0] = from;
	
	int cell = from;
	
	int err = dA / 2;
	while (cell != to || magic) {
		
		cell += stepA;
		
		err += dB;
		if (err >= dA) {
			err = err - dA;
			cell = cell + stepB;
		}
		
		trace[distance++] = cell;
		
		if (!Level.passable[cell] && !Level.avoid[cell]) {
			return trace[--distance - 1];
		}
		
		if (Level.losBlocking[cell] || (hitChars && Actor.findChar( cell ) != null)) {
			return cell;
		}
	}
	
	trace[distance++] = cell;
	
	return to;
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:71,代码来源:Ballistica.java

示例10: trigger

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
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,代码行数:49,代码来源:SummoningTrap.java

示例11: execute

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
@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,代码行数:49,代码来源:DriedRose.java

示例12: affect

import com.shatteredpixel.shatteredpixeldungeon.levels.Level; //导入方法依赖的package包/类
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,代码行数:51,代码来源:WellWater.java


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