2014-07-27 13:39:07 +00:00
|
|
|
/*
|
|
|
|
* Pixel Dungeon
|
|
|
|
* Copyright (C) 2012-2014 Oleg Dolya
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
2014-08-03 18:46:22 +00:00
|
|
|
package com.shatteredpixel.shatteredpixeldungeon.items;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
2014-11-24 21:48:45 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
2015-02-04 03:48:13 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
2015-02-04 03:48:13 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
|
2015-02-04 03:48:13 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
2014-11-24 21:48:45 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
|
2015-02-13 08:21:55 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
2014-11-24 21:48:45 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
|
2014-12-01 08:28:10 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed;
|
2015-02-04 03:48:13 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
2015-02-04 03:48:13 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage;
|
2014-11-24 21:48:45 +00:00
|
|
|
import com.watabou.noosa.audio.Sample;
|
2014-07-27 13:39:07 +00:00
|
|
|
import com.watabou.utils.Bundlable;
|
|
|
|
import com.watabou.utils.Bundle;
|
|
|
|
import com.watabou.utils.Random;
|
|
|
|
|
2014-11-24 21:48:45 +00:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
public class Heap implements Bundlable {
|
|
|
|
|
2015-02-04 03:48:13 +00:00
|
|
|
private static final String TXT_MIMIC = "This is a mimic!";
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
private static final int SEEDS_TO_POTION = 3;
|
|
|
|
|
|
|
|
public enum Type {
|
|
|
|
HEAP,
|
|
|
|
FOR_SALE,
|
|
|
|
CHEST,
|
|
|
|
LOCKED_CHEST,
|
|
|
|
CRYSTAL_CHEST,
|
|
|
|
TOMB,
|
2014-10-30 14:02:25 +00:00
|
|
|
SKELETON,
|
2015-02-04 03:48:13 +00:00
|
|
|
REMAINS,
|
|
|
|
MIMIC
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
public Type type = Type.HEAP;
|
|
|
|
|
|
|
|
public int pos = 0;
|
|
|
|
|
|
|
|
public ItemSprite sprite;
|
|
|
|
|
2015-02-04 03:48:13 +00:00
|
|
|
public LinkedList<Item> items = new LinkedList<Item>();
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
public int image() {
|
|
|
|
switch (type) {
|
|
|
|
case HEAP:
|
|
|
|
case FOR_SALE:
|
|
|
|
return size() > 0 ? items.peek().image() : 0;
|
|
|
|
case CHEST:
|
2015-02-04 03:48:13 +00:00
|
|
|
case MIMIC:
|
2014-07-27 13:39:07 +00:00
|
|
|
return ItemSpriteSheet.CHEST;
|
|
|
|
case LOCKED_CHEST:
|
|
|
|
return ItemSpriteSheet.LOCKED_CHEST;
|
|
|
|
case CRYSTAL_CHEST:
|
|
|
|
return ItemSpriteSheet.CRYSTAL_CHEST;
|
|
|
|
case TOMB:
|
|
|
|
return ItemSpriteSheet.TOMB;
|
|
|
|
case SKELETON:
|
|
|
|
return ItemSpriteSheet.BONES;
|
2014-10-30 14:02:25 +00:00
|
|
|
case REMAINS:
|
|
|
|
return ItemSpriteSheet.REMAINS;
|
2014-07-27 13:39:07 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemSprite.Glowing glowing() {
|
|
|
|
return (type == Type.HEAP || type == Type.FOR_SALE) && items.size() > 0 ? items.peek().glowing() : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void open( Hero hero ) {
|
|
|
|
switch (type) {
|
2015-02-04 03:48:13 +00:00
|
|
|
case MIMIC:
|
|
|
|
if (Mimic.spawnAt(pos, items) != null) {
|
|
|
|
GLog.n(TXT_MIMIC);
|
|
|
|
destroy();
|
|
|
|
} else {
|
|
|
|
type = Type.CHEST;
|
|
|
|
}
|
|
|
|
break;
|
2014-07-27 13:39:07 +00:00
|
|
|
case TOMB:
|
|
|
|
Wraith.spawnAround( hero.pos );
|
|
|
|
break;
|
|
|
|
case SKELETON:
|
2014-10-30 14:02:25 +00:00
|
|
|
case REMAINS:
|
2014-07-27 13:39:07 +00:00
|
|
|
CellEmitter.center( pos ).start( Speck.factory( Speck.RATTLE ), 0.1f, 3 );
|
|
|
|
for (Item item : items) {
|
|
|
|
if (item.cursed) {
|
|
|
|
if (Wraith.spawnAt( pos ) == null) {
|
|
|
|
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
|
|
|
|
hero.damage( hero.HP / 2, this );
|
|
|
|
}
|
|
|
|
Sample.INSTANCE.play( Assets.SND_CURSED );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
2015-02-04 03:48:13 +00:00
|
|
|
|
|
|
|
if (type != Type.MIMIC) {
|
|
|
|
type = Type.HEAP;
|
|
|
|
sprite.link();
|
|
|
|
sprite.drop();
|
|
|
|
}
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int size() {
|
|
|
|
return items.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Item pickUp() {
|
|
|
|
|
|
|
|
Item item = items.removeFirst();
|
|
|
|
if (items.isEmpty()) {
|
|
|
|
destroy();
|
|
|
|
} else if (sprite != null) {
|
|
|
|
sprite.view( image(), glowing() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Item peek() {
|
|
|
|
return items.peek();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void drop( Item item ) {
|
|
|
|
|
|
|
|
if (item.stackable) {
|
|
|
|
|
|
|
|
for (Item i : items) {
|
|
|
|
if (i.isSimilar( item )) {
|
|
|
|
i.quantity += item.quantity;
|
|
|
|
item = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
items.remove( item );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item instanceof Dewdrop) {
|
|
|
|
items.add( item );
|
|
|
|
} else {
|
|
|
|
items.addFirst( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sprite != null) {
|
|
|
|
sprite.view( image(), glowing() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void replace( Item a, Item b ) {
|
|
|
|
int index = items.indexOf( a );
|
|
|
|
if (index != -1) {
|
|
|
|
items.remove( index );
|
|
|
|
items.add( index, b );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void burn() {
|
2015-02-04 03:48:13 +00:00
|
|
|
|
|
|
|
if (type == Type.MIMIC) {
|
|
|
|
Mimic m = Mimic.spawnAt( pos, items );
|
|
|
|
if (m != null) {
|
|
|
|
Buff.affect( m, Burning.class ).reignite( m );
|
|
|
|
m.sprite.emitter().burst( FlameParticle.FACTORY, 5 );
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
if (type != Type.HEAP) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean burnt = false;
|
|
|
|
boolean evaporated = false;
|
|
|
|
|
|
|
|
for (Item item : items.toArray( new Item[0] )) {
|
|
|
|
if (item instanceof Scroll) {
|
|
|
|
items.remove( item );
|
|
|
|
burnt = true;
|
|
|
|
} else if (item instanceof Dewdrop) {
|
|
|
|
items.remove( item );
|
|
|
|
evaporated = true;
|
|
|
|
} else if (item instanceof MysteryMeat) {
|
|
|
|
replace( item, ChargrilledMeat.cook( (MysteryMeat)item ) );
|
|
|
|
burnt = true;
|
2015-02-13 08:21:55 +00:00
|
|
|
} else if (item instanceof Bomb) {
|
2015-02-13 15:00:46 +00:00
|
|
|
items.remove( item );
|
|
|
|
((Bomb) item).explode( pos );
|
|
|
|
//stop processing the burning, it will be replaced by the explosion.
|
2015-02-13 08:21:55 +00:00
|
|
|
return;
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (burnt || evaporated) {
|
|
|
|
|
|
|
|
if (Dungeon.visible[pos]) {
|
|
|
|
if (burnt) {
|
|
|
|
burnFX( pos );
|
|
|
|
} else {
|
|
|
|
evaporateFX( pos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isEmpty()) {
|
|
|
|
destroy();
|
|
|
|
} else if (sprite != null) {
|
|
|
|
sprite.view( image(), glowing() );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2015-02-13 08:21:55 +00:00
|
|
|
|
2015-02-13 15:00:46 +00:00
|
|
|
//Note: should not be called to initiate an explosion, but rather by an explosion that is happening.
|
2015-02-13 08:21:55 +00:00
|
|
|
public void explode() {
|
|
|
|
|
2015-02-13 15:00:46 +00:00
|
|
|
//breaks open most standard containers, mimics die.
|
2015-02-13 08:21:55 +00:00
|
|
|
if (type == Type.MIMIC || type == Type.CHEST || type == Type.SKELETON) {
|
|
|
|
type = Type.HEAP;
|
|
|
|
sprite.link();
|
|
|
|
sprite.drop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != Type.HEAP) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for (Item item : items.toArray( new Item[0] )) {
|
|
|
|
|
|
|
|
if (item instanceof Potion) {
|
|
|
|
items.remove( item );
|
|
|
|
((Potion) item).shatter(pos);
|
|
|
|
|
|
|
|
} else if (item instanceof Bomb) {
|
|
|
|
items.remove( item );
|
|
|
|
((Bomb) item).explode(pos);
|
2015-02-13 15:00:46 +00:00
|
|
|
//stop processing current explosion, it will be replaced by the new one.
|
2015-02-13 08:21:55 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-16 10:01:24 +00:00
|
|
|
} else if (item instanceof Honeypot.ShatteredPot){
|
|
|
|
|
|
|
|
//need to let the bee know the pot is being destroyed.
|
|
|
|
((Honeypot.ShatteredPot) item).goAway();
|
|
|
|
items.remove( item );
|
|
|
|
|
2015-02-13 08:21:55 +00:00
|
|
|
//unique and upgraded items can endure the blast
|
|
|
|
} else if (!(item.level > 0 || item.unique))
|
|
|
|
items.remove( item );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (items.isEmpty())
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
}
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
public void freeze() {
|
2015-02-04 03:48:13 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
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;
|
2015-02-13 08:21:55 +00:00
|
|
|
} else if (item instanceof Potion) {
|
|
|
|
((Potion) item).shatter(pos);
|
|
|
|
frozen = true;
|
2015-02-13 15:00:46 +00:00
|
|
|
} else if (item instanceof Bomb){
|
2015-02-16 10:01:24 +00:00
|
|
|
((Bomb) item).fuse = null;
|
2015-02-13 15:00:46 +00:00
|
|
|
frozen = true;
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frozen) {
|
|
|
|
if (isEmpty()) {
|
|
|
|
destroy();
|
|
|
|
} else if (sprite != null) {
|
|
|
|
sprite.view( image(), glowing() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Item transmute() {
|
|
|
|
|
|
|
|
CellEmitter.get( pos ).burst( Speck.factory( Speck.BUBBLE ), 3 );
|
|
|
|
Splash.at( pos, 0xFFFFFF, 3 );
|
|
|
|
|
|
|
|
float chances[] = new float[items.size()];
|
|
|
|
int count = 0;
|
2014-08-14 21:27:54 +00:00
|
|
|
|
|
|
|
|
2014-08-16 02:48:02 +00:00
|
|
|
if (items.size() == 2 && items.get(0) instanceof Seed && items.get(1) instanceof Blandfruit ) {
|
2014-08-14 21:27:54 +00:00
|
|
|
|
2014-08-16 02:48:02 +00:00
|
|
|
Sample.INSTANCE.play( Assets.SND_PUFF );
|
2014-08-14 21:27:54 +00:00
|
|
|
CellEmitter.center( pos ).burst( Speck.factory( Speck.EVOKE ), 3 );
|
|
|
|
|
|
|
|
Blandfruit result = new Blandfruit();
|
2014-08-16 02:48:02 +00:00
|
|
|
result.cook((Seed)items.get(0));
|
2014-08-14 21:27:54 +00:00
|
|
|
|
|
|
|
destroy();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
for (Item item : items) {
|
|
|
|
if (item instanceof Seed) {
|
|
|
|
count += item.quantity;
|
|
|
|
chances[index++] = item.quantity;
|
2014-08-14 21:27:54 +00:00
|
|
|
} else{
|
2014-07-27 13:39:07 +00:00
|
|
|
count = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-08-14 21:27:54 +00:00
|
|
|
|
2014-11-24 21:48:45 +00:00
|
|
|
//alchemists toolkit gives a chance to cook a potion in two or even one seeds
|
2014-12-03 20:26:58 +00:00
|
|
|
AlchemistsToolkit.alchemy alchemy = Dungeon.hero.buff(AlchemistsToolkit.alchemy.class);
|
|
|
|
int bonus = alchemy != null ? alchemy.level() : -1;
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-12-03 20:26:58 +00:00
|
|
|
if (bonus != -1 ? alchemy.tryCook(count) : count >= SEEDS_TO_POTION) {
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
CellEmitter.get( pos ).burst( Speck.factory( Speck.WOOL ), 6 );
|
|
|
|
Sample.INSTANCE.play( Assets.SND_PUFF );
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-12-01 08:28:10 +00:00
|
|
|
Item potion;
|
|
|
|
|
2014-11-24 21:48:45 +00:00
|
|
|
if (Random.Int( count + bonus ) == 0) {
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
CellEmitter.center( pos ).burst( Speck.factory( Speck.EVOKE ), 3 );
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
destroy();
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
Statistics.potionsCooked++;
|
|
|
|
Badges.validatePotionsCooked();
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-12-01 08:28:10 +00:00
|
|
|
potion = Generator.random( Generator.Category.POTION );
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
} else {
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
Seed proto = (Seed)items.get( Random.chances( chances ) );
|
|
|
|
Class<? extends Item> itemClass = proto.alchemyClass;
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
destroy();
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
Statistics.potionsCooked++;
|
|
|
|
Badges.validatePotionsCooked();
|
2014-11-24 21:48:45 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
if (itemClass == null) {
|
2014-12-01 08:28:10 +00:00
|
|
|
potion = Generator.random( Generator.Category.POTION );
|
2014-07-27 13:39:07 +00:00
|
|
|
} else {
|
|
|
|
try {
|
2014-12-01 08:28:10 +00:00
|
|
|
potion = itemClass.newInstance();
|
2014-07-27 13:39:07 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2014-11-24 21:48:45 +00:00
|
|
|
}
|
|
|
|
|
2014-12-03 20:26:58 +00:00
|
|
|
//not a buff per-se, meant to cancel out higher potion accuracy when ppl are farming for potions of exp.
|
|
|
|
if (bonus > 0)
|
|
|
|
if (Random.Int(1000/bonus) == 0)
|
|
|
|
return new PotionOfExperience();
|
|
|
|
|
2014-12-01 08:28:10 +00:00
|
|
|
while (potion instanceof PotionOfHealing && Random.Int(15) - Dungeon.limitedDrops.cookingHP.count >= 0)
|
|
|
|
potion = Generator.random( Generator.Category.POTION );
|
|
|
|
|
|
|
|
if (potion instanceof PotionOfHealing)
|
|
|
|
Dungeon.limitedDrops.cookingHP.count++;
|
|
|
|
|
|
|
|
return potion;
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void burnFX( int pos ) {
|
|
|
|
CellEmitter.get( pos ).burst( ElmoParticle.FACTORY, 6 );
|
|
|
|
Sample.INSTANCE.play( Assets.SND_BURNING );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void evaporateFX( int pos ) {
|
|
|
|
CellEmitter.get( pos ).burst( Speck.factory( Speck.STEAM ), 5 );
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return items == null || items.size() == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void destroy() {
|
|
|
|
Dungeon.level.heaps.remove( this.pos );
|
|
|
|
if (sprite != null) {
|
|
|
|
sprite.kill();
|
|
|
|
}
|
|
|
|
items.clear();
|
|
|
|
items = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final String POS = "pos";
|
|
|
|
private static final String TYPE = "type";
|
|
|
|
private static final String ITEMS = "items";
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public void restoreFromBundle( Bundle bundle ) {
|
|
|
|
pos = bundle.getInt( POS );
|
|
|
|
type = Type.valueOf( bundle.getString( TYPE ) );
|
2014-10-25 02:13:31 +00:00
|
|
|
items = new LinkedList<Item>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS )) );
|
2014-09-22 02:34:06 +00:00
|
|
|
items.removeAll(Collections.singleton(null));
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void storeInBundle( Bundle bundle ) {
|
|
|
|
bundle.put( POS, pos );
|
|
|
|
bundle.put( TYPE, type.toString() );
|
|
|
|
bundle.put( ITEMS, items );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|