当前位置: 首页>>代码示例>>Java>>正文


Java Terrain.LOCKED_DOOR属性代码示例

本文整理汇总了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;
	}
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:31,代码来源:Hero.java

示例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();
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:57,代码来源:Hero.java

示例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();
}
 
开发者ID:skynet67,项目名称:pixel-dungeon-rebirth,代码行数:57,代码来源:Hero.java

示例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();
	}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:64,代码来源:Hero.java

示例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();
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:44,代码来源:Hero.java

示例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;
	}
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:40,代码来源:Hero.java


注:本文中的com.watabou.pixeldungeon.levels.Terrain.LOCKED_DOOR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。