Search in sources :

Example 1 with Recipe

use of com.shatteredpixel.shatteredpixeldungeon.items.Recipe in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndAlchemy method updateState.

private void updateState() {
    ArrayList<Item> ingredients = filterInput(Item.class);
    Recipe recipe = Recipe.findRecipe(ingredients);
    if (recipe != null) {
        output.item(recipe.sampleOutput(ingredients));
        output.visible = true;
        btnCombine.enable(true);
    } else {
        btnCombine.enable(false);
        output.visible = false;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Recipe(com.shatteredpixel.shatteredpixeldungeon.items.Recipe)

Example 2 with Recipe

use of com.shatteredpixel.shatteredpixeldungeon.items.Recipe in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndAlchemy method combine.

private void combine() {
    ArrayList<Item> ingredients = filterInput(Item.class);
    Recipe recipe = Recipe.findRecipe(ingredients);
    Item result = null;
    if (recipe != null) {
        result = recipe.brew(ingredients);
    }
    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);
        }
        synchronized (inputs) {
            for (int i = 0; i < inputs.length; i++) {
                if (inputs[i] != null && inputs[i].item != null) {
                    if (inputs[i].item.quantity() <= 0) {
                        inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
                        inputs[i].item = null;
                    } else {
                        inputs[i].slot.item(inputs[i].item);
                    }
                }
            }
        }
        btnCombine.enable(false);
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Recipe(com.shatteredpixel.shatteredpixeldungeon.items.Recipe)

Aggregations

Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)2 Recipe (com.shatteredpixel.shatteredpixeldungeon.items.Recipe)2