本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.items.Generator.random方法的典型用法代码示例。如果您正苦于以下问题:Java Generator.random方法的具体用法?Java Generator.random怎么用?Java Generator.random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.shatteredpixel.shatteredpixeldungeon.items.Generator
的用法示例。
在下文中一共展示了Generator.random方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spawn
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public static void spawn( CityLevel level ) {
if (!spawned && Dungeon.depth > 16 && Random.Int( 20 - Dungeon.depth ) == 0) {
Imp npc = new Imp();
do {
npc.pos = level.randomRespawnCell();
} while (npc.pos == -1 || level.heaps.get( npc.pos ) != null);
level.mobs.add( npc );
Actor.occupyCell( npc );
spawned = true;
alternative = Random.Int( 2 ) == 0;
given = false;
do {
reward = (Ring)Generator.random( Generator.Category.RING );
} while (reward.cursed);
reward.upgrade( 2 );
reward.cursed = true;
}
}
示例2: spawnWandmaker
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public static void spawnWandmaker( Level level, Room room ) {
if (questRoomSpawned) {
questRoomSpawned = false;
Wandmaker npc = new Wandmaker();
do {
npc.pos = level.pointToCell(room.random());
} while (npc.pos == level.entrance);
level.mobs.add( npc );
spawned = true;
given = false;
wand1 = (Wand) Generator.random(Generator.Category.WAND);
wand1.cursed = false;
wand1.upgrade();
do {
wand2 = (Wand) Generator.random(Generator.Category.WAND);
} while (wand2.getClass().equals(wand1.getClass()));
wand2.cursed = false;
wand2.upgrade();
}
}
示例3: Statue
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public Statue() {
super();
do {
weapon = (Weapon)Generator.random( Generator.Category.WEAPON );
} while (!(weapon instanceof MeleeWeapon) || weapon.level < 0);
weapon.identify();
weapon.enchant( Enchantment.random() );
HP = HT = 15 + Dungeon.depth * 5;
defenseSkill = 4 + Dungeon.depth;
}
示例4: createLoot
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
@Override
protected Item createLoot() {
Item loot = Generator.random( Generator.Category.WEAPON );
for (int i=0; i < 2; i++) {
Item l = Generator.random( Generator.Category.WEAPON );
if (l.level < loot.level) {
loot = l;
}
}
return loot;
}
示例5: prize
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
private static Item prize( Level level ) {
return Generator.random( Random.oneOf(
Generator.Category.WAND,
Generator.Category.RING,
Generator.Category.ARTIFACT
) );
}
示例6: wither
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public void wither() {
Dungeon.level.uproot( pos );
sprite.kill();
if (Dungeon.visible[pos]) {
CellEmitter.get( pos ).burst( LeafParticle.GENERAL, 6 );
}
if (Dungeon.hero.subClass == HeroSubClass.WARDEN) {
int naturalismLevel = 0;
SandalsOfNature.Naturalism naturalism = Dungeon.hero.buff( SandalsOfNature.Naturalism.class );
if (naturalism != null) {
naturalismLevel = naturalism.level()+1;
}
if (Random.Int( 5 - (naturalismLevel/2) ) == 0) {
Item seed = Generator.random(Generator.Category.SEED);
if (seed instanceof BlandfruitBush.Seed) {
if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
Dungeon.level.drop(seed, pos).sprite.drop();
Dungeon.limitedDrops.blandfruitSeed.count++;
}
} else
Dungeon.level.drop(seed, pos).sprite.drop();
}
if (Random.Int( 5 - naturalismLevel ) == 0) {
Dungeon.level.drop( new Dewdrop(), pos ).sprite.drop();
}
}
}
示例7: placePlants
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
private void placePlants(float numPlants, float numDews, float numPods, float numStars){
Iterator<Integer> cells = affectedCells.iterator();
Level floor = Dungeon.level;
while(cells.hasNext() && Random.Float() <= numPlants){
Plant.Seed seed = (Plant.Seed) Generator.random(Generator.Category.SEED);
if (seed instanceof BlandfruitBush.Seed) {
if (Random.Int(5) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
floor.plant(seed, cells.next());
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
}
} else
floor.plant(seed, cells.next());
numPlants --;
}
while (cells.hasNext() && Random.Float() <= numDews){
floor.plant(new Dewcatcher.Seed(), cells.next());
numDews --;
}
while (cells.hasNext() && Random.Float() <= numPods){
floor.plant(new Seedpod.Seed(), cells.next());
numPods --;
}
while (cells.hasNext() && Random.Float() <= numStars){
floor.plant(new Starflower.Seed(), cells.next());
numStars --;
}
}
示例8: wither
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public void wither() {
Dungeon.level.uproot( pos );
if (Dungeon.level.heroFOV[pos]) {
CellEmitter.get( pos ).burst( LeafParticle.GENERAL, 6 );
}
if (Dungeon.hero.subClass == HeroSubClass.WARDEN) {
int naturalismLevel = 0;
SandalsOfNature.Naturalism naturalism = Dungeon.hero.buff( SandalsOfNature.Naturalism.class );
if (naturalism != null) {
naturalismLevel = naturalism.itemLevel()+1;
}
if (Random.Int( 5 - (naturalismLevel/2) ) == 0) {
Item seed = Generator.random(Generator.Category.SEED);
if (seed instanceof BlandfruitBush.Seed) {
if (Random.Int(5) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
Dungeon.level.drop(seed, pos).sprite.drop();
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
}
} else
Dungeon.level.drop(seed, pos).sprite.drop();
}
if (Random.Int( 5 - naturalismLevel ) == 0) {
Dungeon.level.drop( new Dewdrop(), pos ).sprite.drop();
}
}
}
示例9: Statue
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public Statue() {
super();
do {
weapon = (Weapon)Generator.random( Generator.Category.WEAPON );
} while (!(weapon instanceof MeleeWeapon) || weapon.cursed);
weapon.enchant( Enchantment.random() );
HP = HT = 15 + Dungeon.depth * 5;
defenseSkill = 4 + Dungeon.depth;
}
示例10: createLoot
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
@Override
protected Item createLoot() {
Item loot;
do {
loot = Generator.random(Generator.Category.WEAPON);
//50% chance of re-rolling tier 4 or 5 items
} while (loot instanceof MeleeWeapon && ((MeleeWeapon) loot).tier >= 4 && Random.Int(2) == 0);
loot.level(0);
return loot;
}
示例11: spawn
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public static void spawn( CityLevel level ) {
if (!spawned && Dungeon.depth > 16 && Random.Int( 20 - Dungeon.depth ) == 0) {
Imp npc = new Imp();
do {
npc.pos = level.randomRespawnCell();
} while (
npc.pos == -1 ||
level.heaps.get( npc.pos ) != null ||
level.findMob( npc.pos ) != null ||
//The imp doesn't move, so he cannot obstruct a passageway
!(level.passable[npc.pos + PathFinder.CIRCLE4[0]] && level.passable[npc.pos + PathFinder.CIRCLE4[2]]) ||
!(level.passable[npc.pos + PathFinder.CIRCLE4[1]] && level.passable[npc.pos + PathFinder.CIRCLE4[3]]));
level.mobs.add( npc );
spawned = true;
alternative = Random.Int( 2 ) == 0;
given = false;
do {
reward = (Ring)Generator.random( Generator.Category.RING );
} while (reward.cursed);
reward.upgrade( 2 );
reward.cursed = true;
}
}
示例12: prize
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
private static Item prize( Level level ) {
return Random.Int( 6 ) == 0 ?
new Bomb().random() :
Generator.random( Random.oneOf(
Generator.Category.ARMOR,
Generator.Category.WEAPON
) );
}
示例13: prize
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
private static Item prize( Level level ) {
return Generator.random( Random.oneOf(
Generator.Category.ARMOR,
Generator.Category.WEAPON
) );
}
示例14: combine
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
private void combine(){
ArrayList<Plant.Seed> seeds = filterInput(Plant.Seed.class);
ArrayList<Blandfruit> fruits = filterInput(Blandfruit.class);
Item result = null;
//potion creation
if (seeds.size() == 3){
if (Random.Int( 3 ) == 0) {
result = Generator.random( Generator.Category.POTION );
} else {
Class<? extends Item> itemClass = Random.element(seeds).alchemyClass;
try {
result = itemClass.newInstance();
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
result = Generator.random( Generator.Category.POTION );
}
}
while (result instanceof PotionOfHealing
&& Random.Int(10) < Dungeon.LimitedDrops.COOKING_HP.count) {
result = Generator.random(Generator.Category.POTION);
}
if (result instanceof PotionOfHealing) {
Dungeon.LimitedDrops.COOKING_HP.count++;
}
Statistics.potionsCooked++;
Badges.validatePotionsCooked();
//blandfruit cooking
} else if (fruits.size() == 1 && seeds.size() == 1) {
result = fruits.get(0);
((Blandfruit)result).cook(seeds.get(0));
}
if (result != null){
bubbleEmitter.start(Speck.factory( Speck.BUBBLE ), 0.2f, 10 );
smokeEmitter.burst(Speck.factory( Speck.WOOL ), 10 );
Sample.INSTANCE.play( Assets.SND_PUFF );
output.item(result);
if (!result.collect()){
Dungeon.level.drop(result, Dungeon.hero.pos);
}
for (int i = 0; i < inputs.length; i++){
inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
inputs[i].item = null;
}
btnCombine.enable(false);
}
}
示例15: trample
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; //导入方法依赖的package包/类
public static void trample( Level level, int pos, Char ch ) {
Level.set( pos, Terrain.GRASS );
GameScene.updateMap( pos );
if (!Dungeon.isChallenged( Challenges.NO_HERBALISM )) {
int naturalismLevel = 0;
if (ch != null) {
SandalsOfNature.Naturalism naturalism = ch.buff( SandalsOfNature.Naturalism.class );
if (naturalism != null) {
if (!naturalism.isCursed()) {
naturalismLevel = naturalism.itemLevel() + 1;
naturalism.charge();
} else {
naturalismLevel = -1;
}
}
}
if (naturalismLevel >= 0) {
// Seed, scales from 1/16 to 1/4
if (Random.Int(16 - ((int) (naturalismLevel * 3))) == 0) {
Item seed = Generator.random(Generator.Category.SEED);
if (seed instanceof BlandfruitBush.Seed) {
if (Random.Int(5) - Dungeon.LimitedDrops.BLANDFRUIT_SEED.count >= 0) {
level.drop(seed, pos).sprite.drop();
Dungeon.LimitedDrops.BLANDFRUIT_SEED.count++;
}
} else
level.drop(seed, pos).sprite.drop();
}
// Dew, scales from 1/6 to 1/3
if (Random.Int(24 - naturalismLevel*3) <= 3) {
level.drop(new Dewdrop(), pos).sprite.drop();
}
}
}
int leaves = 4;
if (ch instanceof Hero) {
Hero hero = (Hero)ch;
// Barkskin
if (hero.subClass == HeroSubClass.WARDEN) {
Buff.affect(ch, Barkskin.class).level(ch.HT / 3);
leaves += 4;
}
//Camouflage
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Camouflage.class)){
Buff.affect(hero, Camouflage.Camo.class).set(3 + hero.belongings.armor.level());
leaves += 4;
}
}
CellEmitter.get( pos ).burst( LeafParticle.LEVEL_SPECIFIC, leaves );
if (Dungeon.level.heroFOV[pos]) Dungeon.observe();
}