本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.actors.Actor.addDelayed方法的典型用法代码示例。如果您正苦于以下问题:Java Actor.addDelayed方法的具体用法?Java Actor.addDelayed怎么用?Java Actor.addDelayed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.shatteredpixel.shatteredpixeldungeon.actors.Actor
的用法示例。
在下文中一共展示了Actor.addDelayed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defenseProc
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的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);
}
示例2: doPickUp
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public boolean doPickUp( Hero hero ) {
if (super.doPickUp( hero )) {
if (!Statistics.amuletObtained) {
Statistics.amuletObtained = true;
Badges.validateVictory();
hero.spend(-TIME_TO_PICK_UP);
//add a delayed actor here so pickup behaviour can fully process.
Actor.addDelayed(new Actor(){
@Override
protected boolean act() {
Actor.remove(this);
showAmuletScene( true );
return false;
}
}, -5);
}
return true;
} else {
return false;
}
}
示例3: defenseProc
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {
if (HP >= damage + 2) {
ArrayList<Integer> candidates = new ArrayList<Integer>();
boolean[] passable = Level.passable;
int[] neighbours = {pos + 1, pos - 1, pos + Level.WIDTH, pos - Level.WIDTH};
for (int n : neighbours) {
if (passable[n] && Actor.findChar( n ) == null) {
candidates.add( n );
}
}
if (candidates.size() > 0) {
Swarm clone = split();
clone.HP = (HP - damage) / 2;
clone.pos = Random.element( candidates );
clone.state = clone.HUNTING;
if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
Door.enter( clone.pos );
}
GameScene.add( clone, SPLIT_DELAY );
Actor.addDelayed( new Pushing( clone, pos, clone.pos ), -1 );
HP -= clone.HP;
}
}
return damage;
}
示例4: proc
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的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;
}
示例5: defenseProc
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {
ArrayList<Integer> spawnPoints = new ArrayList<>();
for (int i=0; i < PathFinder.NEIGHBOURS8.length; i++) {
int p = pos + PathFinder.NEIGHBOURS8[i];
if (Actor.findChar( p ) == null && (Dungeon.level.passable[p] || Dungeon.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 );
}
for (Mob mob : Dungeon.level.mobs) {
if (mob instanceof BurningFist || mob instanceof RottingFist || mob instanceof Larva) {
mob.aggro( enemy );
}
}
return super.defenseProc(enemy, damage);
}
示例6: defenseProc
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
public int defenseProc( Char enemy, int damage ) {
if (HP >= damage + 2) {
ArrayList<Integer> candidates = new ArrayList<>();
boolean[] solid = Dungeon.level.solid;
int[] neighbours = {pos + 1, pos - 1, pos + Dungeon.level.width(), pos - Dungeon.level.width()};
for (int n : neighbours) {
if (!solid[n] && Actor.findChar( n ) == null) {
candidates.add( n );
}
}
if (candidates.size() > 0) {
Swarm clone = split();
clone.HP = (HP - damage) / 2;
clone.pos = Random.element( candidates );
clone.state = clone.HUNTING;
if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
Door.enter( clone.pos );
}
GameScene.add( clone, SPLIT_DELAY );
Actor.addDelayed( new Pushing( clone, pos, clone.pos ), -1 );
HP -= clone.HP;
}
}
return super.defenseProc(enemy, damage);
}
示例7: onThrow
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
@Override
protected void onThrow( int cell ) {
if (!Dungeon.level.pit[ cell ] && lightingFuse) {
Actor.addDelayed(fuse = new Fuse().ignite(this), 2);
}
if (Actor.findChar( cell ) != null && !(Actor.findChar( cell ) instanceof Hero) ){
ArrayList<Integer> candidates = new ArrayList<>();
for (int i : PathFinder.NEIGHBOURS8)
if (Dungeon.level.passable[cell + i])
candidates.add(cell + i);
int newCell = candidates.isEmpty() ? cell : Random.element(candidates);
Dungeon.level.drop( this, newCell ).sprite.drop( cell );
} else
super.onThrow( cell );
}
示例8: throwChar
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
public static void throwChar(final Char ch, final Ballistica trajectory, int power){
int dist = Math.min(trajectory.dist, power);
if (ch.properties().contains(Char.Property.BOSS))
dist /= 2;
if (dist == 0 || ch.properties().contains(Char.Property.IMMOVABLE)) return;
if (Actor.findChar(trajectory.path.get(dist)) != null){
dist--;
}
final int newPos = trajectory.path.get(dist);
if (newPos == ch.pos) return;
final int finalDist = dist;
final int initialpos = ch.pos;
Actor.addDelayed(new Pushing(ch, ch.pos, newPos, new Callback() {
public void call() {
if (initialpos != ch.pos) {
//something cased movement before pushing resolved, cancel to be safe.
ch.sprite.place(ch.pos);
return;
}
ch.pos = newPos;
if (ch.pos == trajectory.collisionPos) {
ch.damage(Random.NormalIntRange((finalDist + 1) / 2, finalDist), this);
Paralysis.prolong(ch, Paralysis.class, Random.NormalIntRange((finalDist + 1) / 2, finalDist));
}
Dungeon.level.press(ch.pos, ch);
if (ch == Dungeon.hero){
Dungeon.observe();
}
}
}), -1);
}
示例9: add
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
public static void add( Mob mob, float delay ) {
Dungeon.level.mobs.add( mob );
Actor.addDelayed( mob, delay );
Actor.occupyCell( mob );
scene.addMobSprite( mob );
}
示例10: spawnAt
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
public static Mimic spawnAt( int pos, List<Item> items ) {
if (Dungeon.level.pit[pos]) return null;
Char ch = Actor.findChar( pos );
if (ch != null) {
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
int cell = pos + n;
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar( cell ) == null) {
candidates.add( cell );
}
}
if (candidates.size() > 0) {
int newPos = Random.element( candidates );
Actor.addDelayed( new Pushing( ch, ch.pos, newPos ), -1 );
ch.pos = newPos;
// FIXME
if (ch instanceof Mob) {
Dungeon.level.mobPress( (Mob)ch );
} else {
Dungeon.level.press( newPos, ch );
}
} else {
return null;
}
}
Mimic m = new Mimic();
m.items = new ArrayList<>( items );
m.adjustStats( Dungeon.depth );
m.pos = pos;
m.state = m.HUNTING;
GameScene.add( m, 1 );
m.sprite.turnTo( pos, Dungeon.hero.pos );
if (Dungeon.level.heroFOV[m.pos]) {
CellEmitter.get( pos ).burst( Speck.factory( Speck.STAR ), 10 );
Sample.INSTANCE.play( Assets.SND_MIMIC );
}
//generate an extra reward for killing the mimic
switch(Random.Int(5)){
case 0: case 1:
m.items.add(new Gold().random()); break;
case 2:
m.items.add(Generator.randomArmor().identify()); break;
case 3:
m.items.add(Generator.randomWeapon().identify()); break;
case 4:
m.items.add(Generator.random(Generator.Category.RING).identify()); break;
}
return m;
}
示例11: add
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
public static void add( Mob mob, float delay ) {
Dungeon.level.mobs.add( mob );
Actor.addDelayed( mob, delay );
scene.addMobSprite( mob );
}
示例12: shatter
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; //导入方法依赖的package包/类
public Item shatter( Char owner, int pos ) {
if (Dungeon.level.heroFOV[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 = Dungeon.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;
}
}