本文整理匯總了Java中com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation類的典型用法代碼示例。如果您正苦於以下問題:Java ScrollOfTeleportation類的具體用法?Java ScrollOfTeleportation怎麽用?Java ScrollOfTeleportation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ScrollOfTeleportation類屬於com.shatteredpixel.shatteredpixeldungeon.items.scrolls包,在下文中一共展示了ScrollOfTeleportation類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: activate
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
@Override
public void activate( Char ch ) {
super.activate( ch );
if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero( (Hero)ch );
((Hero)ch).curAction = null;
} else if (ch instanceof Mob) {
// Why do I try to choose a new position 10 times?
// I don't remember...
int count = 10;
int newPos;
do {
newPos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (newPos == -1);
if (newPos != -1) {
ch.pos = newPos;
ch.sprite.place( ch.pos );
ch.sprite.visible = Dungeon.visible[pos];
}
}
if (Dungeon.visible[pos]) {
CellEmitter.get( pos ).start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
}
}
示例2: blink
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
private void blink( int target ) {
Ballistica route = new Ballistica( pos, target, Ballistica.PROJECTILE);
int cell = route.collisionPos;
//can't occupy the same cell as another char, so move back one.
if (Actor.findChar( cell ) != null && cell != this.pos)
cell = route.path.get(route.dist-1);
if (Dungeon.level.avoid[ cell ]){
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
cell = route.collisionPos + n;
if (Dungeon.level.passable[cell] && Actor.findChar( cell ) == null) {
candidates.add( cell );
}
}
if (candidates.size() > 0)
cell = Random.element(candidates);
else {
delay = BLINK_DELAY;
return;
}
}
ScrollOfTeleportation.appear( this, cell );
delay = BLINK_DELAY;
}
示例3: activate
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
@Override
public void activate() {
Char ch = Actor.findChar(pos);
if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero( (Hero)ch );
((Hero)ch).curAction = null;
} else if (ch instanceof Mob && !ch.properties().contains(Char.Property.IMMOVABLE)) {
int count = 10;
int newPos;
do {
newPos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (newPos == -1);
if (newPos != -1 && !Dungeon.bossLevel()) {
ch.pos = newPos;
if (((Mob) ch).state == ((Mob) ch).HUNTING) ((Mob) ch).state = ((Mob) ch).WANDERING;
ch.sprite.place( ch.pos );
ch.sprite.visible = Dungeon.level.heroFOV[ch.pos];
}
}
if (Dungeon.level.heroFOV[pos]) {
CellEmitter.get( pos ).start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
}
}
示例4: onSelect
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
@Override
public void onSelect( Integer target ) {
if (target != null) {
if (!Dungeon.level.heroFOV[target] ||
!(Dungeon.level.passable[target] || Dungeon.level.avoid[target]) ||
Actor.findChar( target ) != null) {
GLog.w( Messages.get(RogueArmor.class, "fov") );
return;
}
curUser.HP -= (curUser.HP / 3);
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[Dungeon.level.mobs.size()])) {
if (Dungeon.level.heroFOV[mob.pos]) {
Buff.prolong( mob, Blindness.class, 2 );
if (mob.state == mob.HUNTING) mob.state = mob.WANDERING;
mob.sprite.emitter().burst( Speck.factory( Speck.LIGHT ), 4 );
}
}
ScrollOfTeleportation.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();
GameScene.updateFog();
curUser.spendAndNext( Actor.TICK );
}
}
示例5: proc
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage ) {
if (defender == Dungeon.hero && Random.Int(20) == 0){
ScrollOfTeleportation.teleportHero(Dungeon.hero);
return 0;
}
return damage;
}
示例6: summon
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
private void summon() {
nextPedestal = !nextPedestal;
sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.4f, 2 );
Sample.INSTANCE.play( Assets.SND_CHALLENGE );
boolean[] passable = Dungeon.level.passable.clone();
for (Char c : Actor.chars()) {
passable[c.pos] = false;
}
int undeadsToSummon = maxArmySize() - Undead.count;
PathFinder.buildDistanceMap( pos, passable, undeadsToSummon );
PathFinder.distance[pos] = Integer.MAX_VALUE;
int dist = 1;
undeadLabel:
for (int i=0; i < undeadsToSummon; i++) {
do {
for (int j=0; j < Dungeon.level.length(); j++) {
if (PathFinder.distance[j] == dist) {
Undead undead = new Undead();
undead.pos = j;
GameScene.add( undead );
ScrollOfTeleportation.appear( undead, j );
new Flare( 3, 32 ).color( 0x000000, false ).show( undead.sprite, 2f ) ;
PathFinder.distance[j] = Integer.MAX_VALUE;
continue undeadLabel;
}
}
dist++;
} while (dist < undeadsToSummon);
}
yell( Messages.get(this, "arise") );
}
示例7: execute
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
@Override
public void execute( Hero hero, String action ) {
super.execute( hero, action );
if (action == AC_SET || action == AC_RETURN) {
if (Dungeon.bossLevel()) {
hero.spend( LloydsBeacon.TIME_TO_USE );
GLog.w( Messages.get(this, "preventing") );
return;
}
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
Char ch = Actor.findChar(hero.pos + PathFinder.NEIGHBOURS8[i]);
if (ch != null && ch.alignment == Char.Alignment.ENEMY) {
GLog.w( Messages.get(this, "creatures") );
return;
}
}
}
if (action == AC_ZAP ){
curUser = hero;
int chargesToUse = Dungeon.depth > 20 ? 2 : 1;
if (!isEquipped( hero )) {
GLog.i( Messages.get(Artifact.class, "need_to_equip") );
QuickSlotButton.cancel();
} else if (charge < chargesToUse) {
GLog.i( Messages.get(this, "no_charge") );
QuickSlotButton.cancel();
} else {
GameScene.selectCell(zapper);
}
} else if (action == AC_SET) {
returnDepth = Dungeon.depth;
returnPos = hero.pos;
hero.spend( LloydsBeacon.TIME_TO_USE );
hero.busy();
hero.sprite.operate( hero.pos );
Sample.INSTANCE.play( Assets.SND_BEACON );
GLog.i( Messages.get(this, "return") );
} else if (action == AC_RETURN) {
if (returnDepth == Dungeon.depth) {
ScrollOfTeleportation.appear( hero, returnPos );
Dungeon.level.press( returnPos, hero );
Dungeon.observe();
GameScene.updateFog();
} else {
Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
if (buff != null) buff.detach();
InterlevelScene.mode = InterlevelScene.Mode.RETURN;
InterlevelScene.returnDepth = returnDepth;
InterlevelScene.returnPos = returnPos;
Game.switchScene( InterlevelScene.class );
}
}
}
示例8: onZap
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; //導入依賴的package包/類
@Override
protected void onZap( int cell ) {
Char ch = Actor.findChar( cell );
if (ch == curUser) {
setKnown();
ScrollOfTeleportation.teleportHero( curUser );
} else if (ch != null && !(ch instanceof NPC)) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1) {
GLog.w( ScrollOfTeleportation.TXT_NO_TELEPORT );
} else {
ch.pos = pos;
ch.sprite.place( ch.pos );
ch.sprite.visible = Dungeon.visible[pos];
GLog.i( curUser.name + " teleported " + ch.name + " to somewhere" );
}
} else {
GLog.i( "nothing happened" );
}
}