本文整理汇总了Java中com.watabou.pixeldungeon.levels.Terrain.LOCKED_DOOR属性的典型用法代码示例。如果您正苦于以下问题:Java Terrain.LOCKED_DOOR属性的具体用法?Java Terrain.LOCKED_DOOR怎么用?Java Terrain.LOCKED_DOOR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.watabou.pixeldungeon.levels.Terrain
的用法示例。
在下文中一共展示了Terrain.LOCKED_DOOR属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actUnlock
private boolean actUnlock(HeroAction.Unlock action) {
int doorCell = action.dst;
if (Dungeon.level.adjacent(getPos(), doorCell)) {
theKey = null;
int door = Dungeon.level.map[doorCell];
if (door == Terrain.LOCKED_DOOR) {
theKey = belongings.getKey(IronKey.class, Dungeon.depth, Dungeon.level.levelId);
} else if (door == Terrain.LOCKED_EXIT) {
theKey = belongings.getKey(SkeletonKey.class, Dungeon.depth, Dungeon.level.levelId);
}
if (theKey != null) {
spend(Key.TIME_TO_UNLOCK);
getSprite().operate(doorCell);
Sample.INSTANCE.play(Assets.SND_UNLOCK);
} else {
GLog.w(TXT_LOCKED_DOOR);
ready();
}
return false;
} else if (getCloser(doorCell)) {
return true;
} else {
ready();
return false;
}
}
示例2: handle
public boolean handle( int cell ) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Cook( cell );
} else if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact( (NPC)ch );
} else {
curAction = new HeroAction.Attack( ch );
}
} else if (Level.fieldOfView[cell] && (heap = Dungeon.level.heaps.get( cell )) != null && heap.type != Heap.Type.HIDDEN) {
switch (heap.type) {
case HEAP:
curAction = new HeroAction.PickUp( cell );
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ?
new HeroAction.Buy( cell ) :
new HeroAction.PickUp( cell );
break;
default:
curAction = new HeroAction.OpenChest( cell );
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock( cell );
} else if (cell == Dungeon.level.exit) {
curAction = new HeroAction.Descend( cell );
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend( cell );
} else {
curAction = new HeroAction.Move( cell );
lastAction = null;
}
return act();
}
示例3: handle
public boolean handle( int cell ) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Cook( cell );
} else if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact( (NPC)ch );
} else {
curAction = new HeroAction.Attack( ch );
}
} else if (Level.fieldOfView[cell] && (heap = Dungeon.level.heaps.get( cell )) != null) {
switch (heap.type) {
case HEAP:
curAction = new HeroAction.PickUp( cell );
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ?
new HeroAction.Buy( cell ) :
new HeroAction.PickUp( cell );
break;
default:
curAction = new HeroAction.OpenChest( cell );
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock( cell );
} else if (cell == Dungeon.level.exit) {
curAction = new HeroAction.Descend( cell );
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend( cell );
} else {
curAction = new HeroAction.Move( cell );
lastAction = null;
}
return act();
}
示例4: handle
public boolean handle(int cell) {
if (doOnNextAction != null) {
doOnNextAction.run();
doOnNextAction = null;
return false;
}
if (!Dungeon.level.cellValid(cell)) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != getPos()) {
curAction = new HeroAction.Cook(cell);
} else if (Dungeon.level.fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) {
Mob mob = (Mob) ch;
if (mob.friendly(this)) {
curAction = new HeroAction.Interact(mob);
} else {
curAction = new HeroAction.Attack(ch);
}
} else if ((heap = Dungeon.level.getHeap(cell)) != null) {
switch (heap.type) {
case HEAP:
curAction = new HeroAction.PickUp(cell);
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell)
: new HeroAction.PickUp(cell);
break;
default:
curAction = new HeroAction.OpenChest(cell);
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock(cell);
} else if (Dungeon.level.isExit(cell)) {
curAction = new HeroAction.Descend(cell);
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend(cell);
} else {
curAction = new HeroAction.Move(cell);
lastAction = null;
}
return act();
}
示例5: onOperateComplete
@Override
public void onOperateComplete() {
if (curAction instanceof HeroAction.Unlock) {
if (theKey != null) {
theKey.detach(belongings.backpack);
theKey = null;
}
int doorCell = ((HeroAction.Unlock) curAction).dst;
int door = Dungeon.level.map[doorCell];
switch (door) {
case Terrain.LOCKED_DOOR:
Dungeon.level.set(doorCell, Terrain.DOOR);
break;
case Terrain.LOCKED_EXIT:
Dungeon.level.set(doorCell, Terrain.UNLOCKED_EXIT);
break;
default:
EventCollector.logException(new Exception("trying to unlock tile:" + door));
}
GameScene.updateMap(doorCell);
} else if (curAction instanceof HeroAction.OpenChest) {
if (theKey != null) {
theKey.detach(belongings.backpack);
theKey = null;
}
Heap heap = Dungeon.level.getHeap(((HeroAction.OpenChest) curAction).dst);
if (heap != null) {
if (heap.type == Type.SKELETON) {
Sample.INSTANCE.play(Assets.SND_BONES);
}
heap.open(this);
}
}
curAction = null;
super.onOperateComplete();
}
示例6: actUnlock
private boolean actUnlock( HeroAction.Unlock action ) {
int doorCell = action.dst;
if (Level.adjacent( pos, doorCell )) {
theKey = null;
int door = Dungeon.level.map[doorCell];
if (door == Terrain.LOCKED_DOOR) {
theKey = belongings.getKey( IronKey.class, Dungeon.depth );
} else if (door == Terrain.LOCKED_EXIT) {
theKey = belongings.getKey( SkeletonKey.class, Dungeon.depth );
}
if (theKey != null) {
spend( Key.TIME_TO_UNLOCK );
sprite.operate( doorCell );
Sample.INSTANCE.play( Assets.SND_UNLOCK );
} else {
GLog.w( TXT_LOCKED_DOOR );
ready();
}
return false;
} else if (getCloser( doorCell )) {
return true;
} else {
ready();
return false;
}
}