本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion类的典型用法代码示例。如果您正苦于以下问题:Java Potion类的具体用法?Java Potion怎么用?Java Potion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Potion类属于com.shatteredpixel.shatteredpixeldungeon.items.potions包,在下文中一共展示了Potion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSelect
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
@Override
public void onSelect(Item item) {
if (item != null && item instanceof Potion && item.isIdentified()){
if (!curGuess.contains(convertName(item.getClass().getSimpleName()))) {
Hero hero = Dungeon.hero;
hero.sprite.operate( hero.pos );
hero.busy();
hero.spend( 2f );
Sample.INSTANCE.play(Assets.SND_DRINK);
item.detach(hero.belongings.backpack);
curGuess.add(convertName(item.getClass().getSimpleName()));
if (curGuess.size() == 3){
guessBrew();
} else {
GLog.i("You mix the " + item.name() + " into your current brew.");
}
} else {
GLog.w("Your current brew already contains that potion.");
}
} else if (item != null) {
GLog.w("You need to select an identified potion.");
}
}
示例2: onSelect
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
@Override
public void onSelect(Item item) {
if (item != null && item instanceof Potion && item.isIdentified()){
if (!curGuess.contains(convertName(item.getClass().getSimpleName()))) {
Hero hero = Dungeon.hero;
hero.sprite.operate( hero.pos );
hero.busy();
hero.spend( 2f );
Sample.INSTANCE.play(Assets.SND_DRINK);
item.detach(hero.belongings.backpack);
curGuess.add(convertName(item.getClass().getSimpleName()));
if (curGuess.size() == 3){
guessBrew();
} else {
GLog.i("You mix the " + item.name() + " into your current brew.");
}
} else {
GLog.w("Your current brew already contains that potion.");
}
} else if (item != null) {
GLog.w("You need to select an identified potion.");
}
}
示例3: fall
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
private void fall() throws IOException {
Level level = Dungeon.level;
ArrayList<Item> fallingItems = level.fallingItems;
level.fallingItems = new ArrayList<Item>();
Actor.fixTime();
Dungeon.saveLevel();
if (Dungeon.depth >= Statistics.deepestFloor) {
level = Dungeon.newLevel();
} else {
Dungeon.depth++;
level = Dungeon.loadLevel( Dungeon.hero.heroClass );
}
for (Item item : fallingItems){
int cell = level.randomRespawnCell();
while (cell == -1)
cell = level.randomRespawnCell();
if (!(item instanceof Potion))
level.drop(item, cell);
else
level.fallingPotions.add((Potion)item);
}
Dungeon.switchLevel( level, fallIntoPit ? level.pitCell() : level.randomRespawnCell() );
}
示例4: validateAllPotionsIdentified
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
public static void validateAllPotionsIdentified() {
if (Dungeon.hero != null && Dungeon.hero.isAlive() &&
!local.contains( Badge.ALL_POTIONS_IDENTIFIED ) && Potion.allKnown()) {
Badge badge = Badge.ALL_POTIONS_IDENTIFIED;
local.add( badge );
displayBadge( badge );
validateAllItemsIdentified();
}
}
示例5: affectItem
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
@Override
protected Item affectItem( Item item ) {
if (item instanceof MagesStaff) {
item = changeStaff( (MagesStaff)item );
} else if (item instanceof MeleeWeapon) {
item = changeWeapon( (MeleeWeapon)item );
} else if (item instanceof Scroll) {
item = changeScroll( (Scroll)item );
} else if (item instanceof Potion) {
item = changePotion( (Potion)item );
} else if (item instanceof Ring) {
item = changeRing( (Ring)item );
} else if (item instanceof Wand) {
item = changeWand( (Wand)item );
} else if (item instanceof Plant.Seed) {
item = changeSeed( (Plant.Seed)item );
} else if (item instanceof Artifact) {
item = changeArtifact( (Artifact)item );
} else {
item = null;
}
//incase a never-seen item pops out
if (item != null&& item.isIdentified()){
Catalog.setSeen(item.getClass());
}
return item;
}
示例6: ChooseBag
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
protected static Bag ChooseBag(Belongings pack){
int seeds = 0, scrolls = 0, potions = 0, wands = 0;
//count up items in the main bag, for bags which haven't yet been dropped.
for (Item item : pack.backpack.items) {
if (!Dungeon.LimitedDrops.SEED_POUCH.dropped() && item instanceof Plant.Seed)
seeds++;
else if (!Dungeon.LimitedDrops.SCROLL_HOLDER.dropped() && item instanceof Scroll)
scrolls++;
else if (!Dungeon.LimitedDrops.POTION_BANDOLIER.dropped() && item instanceof Potion)
potions++;
else if (!Dungeon.LimitedDrops.WAND_HOLSTER.dropped() && item instanceof Wand)
wands++;
}
//then pick whichever valid bag has the most items available to put into it.
//note that the order here gives a perference if counts are otherwise equal
if (seeds >= scrolls && seeds >= potions && seeds >= wands && !Dungeon.LimitedDrops.SEED_POUCH.dropped()) {
Dungeon.LimitedDrops.SEED_POUCH.drop();
return new SeedPouch();
} else if (scrolls >= potions && scrolls >= wands && !Dungeon.LimitedDrops.SCROLL_HOLDER.dropped()) {
Dungeon.LimitedDrops.SCROLL_HOLDER.drop();
return new ScrollHolder();
} else if (potions >= wands && !Dungeon.LimitedDrops.POTION_BANDOLIER.dropped()) {
Dungeon.LimitedDrops.POTION_BANDOLIER.drop();
return new PotionBandolier();
} else if (!Dungeon.LimitedDrops.WAND_HOLSTER.dropped()) {
Dungeon.LimitedDrops.WAND_HOLSTER.drop();
return new WandHolster();
}
return null;
}
示例7: paint
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
public void paint( Level level ) {
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
entrance().set( Door.Type.HIDDEN );
Point pot = center();
Painter.set( level, pot, Terrain.ALCHEMY );
Alchemy alchemy = new Alchemy();
alchemy.seed( level, pot.x + level.width() * pot.y, Random.IntRange(30, 60) );
level.blobs.put( Alchemy.class, alchemy );
int n = Random.IntRange( 2, 3 );
HashMap<Class<? extends Potion>, Float> chances = new HashMap<>(potionChances);
for (int i=0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get( pos ) != null);
try{
Class<?extends Potion> potionCls = Random.chances(chances);
chances.put(potionCls, 0f);
level.drop( potionCls.newInstance(), pos );
} catch (Exception e){
ShatteredPixelDungeon.reportException(e);
}
}
}
示例8: freeze
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
public void freeze() {
if (type == Type.MIMIC) {
Mimic m = Mimic.spawnAt( pos, items );
if (m != null) {
Buff.prolong( m, Frost.class, Frost.duration( m ) * Random.Float( 1.0f, 1.5f ) );
destroy();
}
}
if (type != Type.HEAP) {
return;
}
boolean frozen = false;
for (Item item : items.toArray( new Item[0] )) {
if (item instanceof MysteryMeat) {
replace( item, FrozenCarpaccio.cook( (MysteryMeat)item ) );
frozen = true;
} else if (item instanceof Potion
&& !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
items.remove(item);
((Potion) item).shatter(pos);
frozen = true;
} else if (item instanceof Bomb){
((Bomb) item).fuse = null;
frozen = true;
}
}
if (frozen) {
if (isEmpty()) {
destroy();
} else if (sprite != null) {
sprite.view( items.peek() );
}
}
}
示例9: cook
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
public Item cook(Seed seed){
try {
return imbuePotion((Potion)seed.alchemyClass.newInstance());
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
return null;
}
}
示例10: restoreFromBundle
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
if (bundle.contains(POTIONATTRIB)) {
imbuePotion((Potion) bundle.get(POTIONATTRIB));
}
}
示例11: descend
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
private void descend() throws IOException {
Level level;
ArrayList<Item> fallingItems = new ArrayList<Item>();
Actor.fixTime();
if (Dungeon.hero == null) {
Dungeon.init();
if (noStory) {
Dungeon.chapters.add( WndStory.ID_SEWERS );
noStory = false;
}
} else {
level = Dungeon.level;
fallingItems = level.fallingItems;
level.fallingItems = new ArrayList<Item>();
Dungeon.saveLevel();
}
if (Dungeon.depth >= Statistics.deepestFloor) {
level = Dungeon.newLevel();
} else {
Dungeon.depth++;
level = Dungeon.loadLevel( Dungeon.hero.heroClass );
}
for (Item item : fallingItems){
int cell = level.randomRespawnCell();
while (cell == -1)
cell = level.randomRespawnCell();
if (!(item instanceof Potion))
level.drop(item, cell);
else
level.fallingPotions.add((Potion)item);
}
Dungeon.switchLevel( level, level.entrance );
}
示例12: switchLevel
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void switchLevel( final Level level, int pos ) {
Dungeon.level = level;
Actor.init();
Actor respawner = level.respawner();
if (respawner != null) {
Actor.add( level.respawner() );
}
for (Potion potion : level.fallingPotions){
int cell = level.randomRespawnCell();
while (cell == -1)
cell = level.randomRespawnCell();
if (potion instanceof PotionOfLiquidFlame)
GameScene.add( Blob.seed( cell, 2, Fire.class));
else if (potion instanceof PotionOfToxicGas)
GameScene.add( Blob.seed( cell, 1000, ToxicGas.class ) );
else if (potion instanceof PotionOfParalyticGas)
GameScene.add( Blob.seed( cell, 1000, ParalyticGas.class ) );
else if (potion instanceof PotionOfLevitation)
GameScene.add( Blob.seed( cell, 1000, ConfusionGas.class ) );
}
level.fallingPotions.clear();
hero.pos = pos != -1 ? pos : level.exit;
Light light = hero.buff( Light.class );
hero.viewDistance = light == null ? level.viewDistance : Math.max( Light.DISTANCE, level.viewDistance );
observe();
try {
saveAll();
} catch (IOException e) {
/*This only catches IO errors. Yes, this means things can do wrong, and they can go wrong catastrophically.
But when they do the user will get a nice 'report this issue' dialogue, and I can fix the bug.*/
}
}
示例13: actPickUp
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
private boolean actPickUp( HeroAction.PickUp action ) {
int dst = action.dst;
if (pos == dst) {
Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) {
Item item = heap.peek();
if (item.doPickUp( this )) {
heap.pickUp();
if (item instanceof Dewdrop
|| item instanceof TimekeepersHourglass.sandBag
|| item instanceof DriedRose.Petal
|| item instanceof Key) {
//Do Nothing
} else {
boolean important =
((item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion) && ((Scroll)item).isKnown()) ||
((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion)item).isKnown());
if (important) {
GLog.p( Messages.get(this, "you_now_have", item.name()) );
} else {
GLog.i( Messages.get(this, "you_now_have", item.name()) );
}
}
curAction = null;
} else {
heap.sprite.drop();
ready();
}
} else {
ready();
}
return false;
} else if (getCloser( dst )) {
return true;
} else {
ready();
return false;
}
}
示例14: attachTo
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
target.paralysed++;
Buff.detach( target, Burning.class );
Buff.detach( target, Chill.class );
if (target instanceof Hero) {
Hero hero = (Hero)target;
ArrayList<Item> freezable = new ArrayList<>();
//does not reach inside of containers
for (Item i : hero.belongings.backpack.items){
if ((i instanceof Potion && !(i instanceof PotionOfStrength || i instanceof PotionOfMight))
|| i instanceof MysteryMeat){
freezable.add(i);
}
}
if (!freezable.isEmpty()){
Item toFreeze = Random.element(freezable).detach( hero.belongings.backpack );
if (toFreeze instanceof Potion){
((Potion) toFreeze).shatter(hero.pos);
} else if (toFreeze instanceof MysteryMeat){
FrozenCarpaccio carpaccio = new FrozenCarpaccio();
if (!carpaccio.collect( hero.belongings.backpack )) {
Dungeon.level.drop( carpaccio, target.pos ).sprite.drop();
}
}
GLog.w( Messages.get(this, "freezes", toFreeze.toString()) );
}
} else if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Potion && !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
((Potion) ((Thief) target).item).shatter(target.pos);
((Thief) target).item = null;
} else if (item instanceof MysteryMeat){
((Thief) target).item = new FrozenCarpaccio();;
}
}
return true;
} else {
return false;
}
}
示例15: saveGame
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; //导入依赖的package包/类
public static void saveGame( String fileName ) throws IOException {
try {
Bundle bundle = new Bundle();
version = Game.versionCode;
bundle.put( VERSION, version );
bundle.put( SEED, seed );
bundle.put( CHALLENGES, challenges );
bundle.put( HERO, hero );
bundle.put( GOLD, gold );
bundle.put( DEPTH, depth );
for (int d : droppedItems.keyArray()) {
bundle.put(Messages.format(DROPPED, d), droppedItems.get(d));
}
quickslot.storePlaceholders( bundle );
Bundle limDrops = new Bundle();
LimitedDrops.store( limDrops );
bundle.put ( LIMDROPS, limDrops );
int count = 0;
int ids[] = new int[chapters.size()];
for (Integer id : chapters) {
ids[count++] = id;
}
bundle.put( CHAPTERS, ids );
Bundle quests = new Bundle();
Ghost .Quest.storeInBundle( quests );
Wandmaker .Quest.storeInBundle( quests );
Blacksmith .Quest.storeInBundle( quests );
Imp .Quest.storeInBundle( quests );
bundle.put( QUESTS, quests );
SpecialRoom.storeRoomsInBundle( bundle );
SecretRoom.storeRoomsInBundle( bundle );
Statistics.storeInBundle( bundle );
Notes.storeInBundle( bundle );
Generator.storeInBundle( bundle );
Scroll.save( bundle );
Potion.save( bundle );
Ring.save( bundle );
Actor.storeNextID( bundle );
Bundle badges = new Bundle();
Badges.saveLocal( badges );
bundle.put( BADGES, badges );
OutputStream output = Game.instance.openFileOutput( fileName, Game.MODE_PRIVATE );
Bundle.write( bundle, output );
output.close();
} catch (IOException e) {
GamesInProgress.setUnknown( hero.heroClass );
ShatteredPixelDungeon.reportException(e);
}
}