v0.3.0: added support for callbacks in pushing, used in ethereal chains
This commit is contained in:
parent
f16865aade
commit
7aab6a8452
|
@ -22,6 +22,7 @@ import com.watabou.noosa.Visual;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.watabou.utils.Callback;
|
||||
import com.watabou.utils.PointF;
|
||||
|
||||
public class Pushing extends Actor {
|
||||
|
@ -32,6 +33,8 @@ public class Pushing extends Actor {
|
|||
|
||||
private Effect effect;
|
||||
|
||||
private Callback callback;
|
||||
|
||||
{
|
||||
actPriority = Integer.MIN_VALUE; //it's a visual effect, gets priority no matter what
|
||||
}
|
||||
|
@ -40,6 +43,12 @@ public class Pushing extends Actor {
|
|||
sprite = ch.sprite;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.callback = null;
|
||||
}
|
||||
|
||||
public Pushing( Char ch, int from, int to, Callback callback ) {
|
||||
this(ch, from, to);
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,10 +105,11 @@ public class Pushing extends Actor {
|
|||
|
||||
} else {
|
||||
|
||||
sprite.point( end );
|
||||
sprite.point(end);
|
||||
|
||||
killAndErase();
|
||||
Actor.remove( Pushing.this );
|
||||
Actor.remove(Pushing.this);
|
||||
if (callback != null) callback.call();
|
||||
|
||||
next();
|
||||
}
|
||||
|
|
|
@ -126,11 +126,14 @@ public class EtherealChains extends Artifact {
|
|||
curUser.busy();
|
||||
curUser.sprite.parent.add(new Chains(curUser.pos, target, new Callback() {
|
||||
public void call() {
|
||||
Actor.add(new Pushing(curUser, curUser.pos, newHeroPos));
|
||||
Actor.add(new Pushing(curUser, curUser.pos, newHeroPos, new Callback() {
|
||||
public void call() {
|
||||
Dungeon.level.press(newHeroPos, curUser);
|
||||
}
|
||||
}));
|
||||
curUser.spendAndNext(1f);
|
||||
curUser.pos = newHeroPos;
|
||||
Dungeon.observe();
|
||||
curUser.spendAndNext(1f);
|
||||
Dungeon.level.press(newHeroPos, curUser);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user