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


Java Generator.random方法代码示例

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

示例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();
		
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:27,代码来源:Wandmaker.java

示例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;
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:14,代码来源:Statue.java

示例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;
   }
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:12,代码来源:Skeleton.java

示例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
	) );
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:8,代码来源:VaultPainter.java

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

示例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 --;
	}

}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon-gdx,代码行数:35,代码来源:WandOfRegrowth.java

示例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();
		}
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon-gdx,代码行数:32,代码来源:Plant.java

示例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;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:13,代码来源:Statue.java

示例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;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:11,代码来源:Skeleton.java

示例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;
	}
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:28,代码来源:Imp.java

示例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
			) );
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:9,代码来源:ArmoryRoom.java

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

示例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);
	}
	
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:63,代码来源:WndAlchemy.java

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


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