本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.actors.Actor.findById方法的典型用法代码示例。如果您正苦于以下问题:Java Actor.findById方法的具体用法?Java Actor.findById怎么用?Java Actor.findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.shatteredpixel.shatteredpixeldungeon.actors.Actor
的用法示例。
在下文中一共展示了Actor.findById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCloser
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
protected boolean getCloser(int target) {
if (enemy != null && Actor.findById(potHolder) == enemy) {
target = enemy.pos;
} else if (potPos != -1 && (state == WANDERING || Dungeon.level.distance(target, potPos) > 3))
this.target = target = potPos;
return super.getCloser( target );
}
示例2: updateBee
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
private void updateBee( int cell, Char holder){
//important, as ids are not unique between depths.
if (Dungeon.depth != beeDepth)
return;
Bee bee = (Bee)Actor.findById( myBee );
if (bee != null)
bee.setPotInfo( cell, holder );
}
示例3: chooseEnemy
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
protected Char chooseEnemy() {
//if the pot is no longer present, default to regular AI behaviour
if (potHolder == -1 && potPos == -1)
return super.chooseEnemy();
//if something is holding the pot, target that
else if (Actor.findById(potHolder) != null)
return (Char)Actor.findById(potHolder);
//if the pot is on the ground
else {
//try to find a new enemy in these circumstances
if (enemy == null || !enemy.isAlive() || state == WANDERING
|| Dungeon.level.distance(enemy.pos, potPos) > 3
|| (alignment == Alignment.ALLY && enemy.alignment == Alignment.ALLY)){
//find all mobs near the pot
HashSet<Char> enemies = new HashSet<>();
for (Mob mob : Dungeon.level.mobs) {
if (!(mob instanceof Bee)
&& Dungeon.level.distance(mob.pos, potPos) <= 3
&& mob.alignment != Alignment.NEUTRAL
&& !(alignment == Alignment.ALLY && mob.alignment == Alignment.ALLY)) {
enemies.add(mob);
}
}
if (!enemies.isEmpty()){
return Random.element(enemies);
} else {
if (alignment != Alignment.ALLY && Dungeon.level.distance(Dungeon.hero.pos, potPos) <= 3){
return Dungeon.hero;
} else {
return null;
}
}
} else {
return enemy;
}
}
}