本文整理汇总了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);
}
示例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);
}