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


Java Generator.randomWeapon方法代码示例

本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.items.Generator.randomWeapon方法的典型用法代码示例。如果您正苦于以下问题:Java Generator.randomWeapon方法的具体用法?Java Generator.randomWeapon怎么用?Java Generator.randomWeapon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.shatteredpixel.shatteredpixeldungeon.items.Generator的用法示例。


在下文中一共展示了Generator.randomWeapon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
	super.paint(level);
	
	Painter.fill(level, this, Terrain.WALL);
	Painter.fill(level, this, 1, Terrain.EMPTY_SP);
	
	Painter.set(level, center(), Terrain.STATUE_SP);
	
	for (int i = 0; i < 4; i++){
		int itemPos;
		do{
			itemPos = level.pointToCell(random());
		} while ( level.map[itemPos] != Terrain.EMPTY_SP
				|| level.heaps.get(itemPos) != null);
		
		Item item;
		do{
			item = Generator.randomWeapon();
		} while (!(item instanceof MissileWeapon));
		
		level.drop(item, itemPos);
	}
	
	entrance().set(Door.Type.HIDDEN);
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:27,代码来源:SecretArtilleryRoom.java

示例2: paint

import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
	super.paint(level);
	
	Painter.fill(level, this, Terrain.WALL);
	Painter.fill(level, this, 1, Terrain.EMPTY);
	
	//true = space, false = wall
	boolean[][] maze = Maze.generate(this);
	boolean[] passable = new boolean[width()*height()];
	
	Painter.fill(level, this, 1, Terrain.EMPTY);
	for (int x = 0; x < maze.length; x++) {
		for (int y = 0; y < maze[0].length; y++) {
			if (maze[x][y] == Maze.FILLED) {
				Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL);
			}
			passable[x + width()*y] = maze[x][y] == Maze.EMPTY;
		}
	}
	
	PathFinder.setMapSize(width(), height());
	Point entrance = entrance();
	int entrancePos = (entrance.x - left) + width()*(entrance.y - top);
	
	PathFinder.buildDistanceMap( entrancePos, passable );
	
	int bestDist = 0;
	Point bestDistP = new Point();
	for (int i = 0; i < PathFinder.distance.length; i++){
		if (PathFinder.distance[i] != Integer.MAX_VALUE
				&& PathFinder.distance[i] > bestDist){
			bestDist = PathFinder.distance[i];
			bestDistP.x = (i % width()) + left;
			bestDistP.y = (i / width()) + top;
		}
	}
	
	Item prize;
	//1 floor set higher in probability, never cursed
	do {
		if (Random.Int(2) == 0) {
			prize = Generator.randomWeapon((Dungeon.depth / 5) + 1);
		} else {
			prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
		}
	} while (prize.cursed || prize instanceof MissileWeapon);
	
	//33% chance for an extra update.
	if (Random.Int(3) == 0){
		prize.upgrade();
	}
	
	level.drop(prize, level.pointToCell(bestDistP)).type = Heap.Type.CHEST;
	
	PathFinder.setMapSize(level.width(), level.height());
	
	entrance().set(Door.Type.HIDDEN);
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:60,代码来源:SecretMazeRoom.java


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