Search in sources :

Example 1 with Potion

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

the class GameScene method create.

@Override
public void create() {
    Music.INSTANCE.play(Assets.TUNE, true);
    SPDSettings.lastClass(Dungeon.hero.heroClass.ordinal());
    super.create();
    Camera.main.zoom(GameMath.gate(minZoom, defaultZoom + SPDSettings.zoom(), maxZoom));
    scene = this;
    terrain = new Group();
    add(terrain);
    water = new SkinnedBlock(Dungeon.level.width() * DungeonTilemap.SIZE, Dungeon.level.height() * DungeonTilemap.SIZE, Dungeon.level.waterTex()) {

        @Override
        protected NoosaScript script() {
            return NoosaScriptNoLighting.get();
        }

        @Override
        public void draw() {
            // water has no alpha component, this improves performance
            Blending.disable();
            super.draw();
            Blending.enable();
        }
    };
    terrain.add(water);
    ripples = new Group();
    terrain.add(ripples);
    DungeonTileSheet.setupVariance(Dungeon.level.map.length, Dungeon.seedCurDepth());
    tiles = new DungeonTerrainTilemap();
    terrain.add(tiles);
    customTiles = new Group();
    terrain.add(customTiles);
    for (CustomTiledVisual visual : Dungeon.level.customTiles) {
        addCustomTile(visual);
    }
    visualGrid = new GridTileMap();
    terrain.add(visualGrid);
    terrainFeatures = new TerrainFeaturesTilemap(Dungeon.level.plants, Dungeon.level.traps);
    terrain.add(terrainFeatures);
    levelVisuals = Dungeon.level.addVisuals();
    add(levelVisuals);
    heaps = new Group();
    add(heaps);
    for (IntMap.Entry<Heap> heap : Dungeon.level.heaps) {
        addHeapSprite(heap.value);
    }
    emitters = new Group();
    effects = new Group();
    healthIndicators = new Group();
    emoicons = new Group();
    mobs = new Group();
    add(mobs);
    for (Mob mob : Dungeon.level.mobs) {
        addMobSprite(mob);
        if (Statistics.amuletObtained) {
            mob.beckon(Dungeon.hero.pos);
        }
    }
    walls = new DungeonWallsTilemap();
    add(walls);
    customWalls = new Group();
    add(customWalls);
    for (CustomTiledVisual visual : Dungeon.level.customWalls) {
        addCustomWall(visual);
    }
    wallBlocking = new WallBlockingTilemap();
    add(wallBlocking);
    add(emitters);
    add(effects);
    gases = new Group();
    add(gases);
    for (Blob blob : Dungeon.level.blobs.values()) {
        blob.emitter = null;
        addBlobSprite(blob);
    }
    fog = new FogOfWar(Dungeon.level.width(), Dungeon.level.height());
    add(fog);
    spells = new Group();
    add(spells);
    statuses = new Group();
    add(statuses);
    add(healthIndicators);
    // always appears ontop of other health indicators
    add(new TargetHealthIndicator());
    add(emoicons);
    hero = new HeroSprite();
    hero.place(Dungeon.hero.pos);
    hero.updateArmor();
    mobs.add(hero);
    add(cellSelector = new CellSelector(tiles));
    pane = new StatusPane();
    pane.camera = uiCamera;
    pane.setSize(uiCamera.width, 0);
    add(pane);
    toolbar = new Toolbar();
    toolbar.camera = uiCamera;
    toolbar.setRect(0, uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height());
    add(toolbar);
    attack = new AttackIndicator();
    attack.camera = uiCamera;
    add(attack);
    loot = new LootIndicator();
    loot.camera = uiCamera;
    add(loot);
    action = new ActionIndicator();
    action.camera = uiCamera;
    add(action);
    resume = new ResumeIndicator();
    resume.camera = uiCamera;
    add(resume);
    log = new GameLog();
    log.camera = uiCamera;
    log.newLine();
    add(log);
    layoutTags();
    busy = new BusyIndicator();
    busy.camera = uiCamera;
    busy.x = 1;
    busy.y = pane.bottom() + 1;
    add(busy);
    switch(InterlevelScene.mode) {
        case RESURRECT:
            ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.level.entrance);
            new Flare(8, 32).color(0xFFFF66, true).show(hero, 2f);
            break;
        case RETURN:
            ScrollOfTeleportation.appear(Dungeon.hero, Dungeon.hero.pos);
            break;
        case FALL:
            Chasm.heroLand();
            break;
        case DESCEND:
            switch(Dungeon.depth) {
                case 1:
                    WndStory.showChapter(WndStory.ID_SEWERS);
                    break;
                case 6:
                    WndStory.showChapter(WndStory.ID_PRISON);
                    break;
                case 11:
                    WndStory.showChapter(WndStory.ID_CAVES);
                    break;
                case 16:
                    WndStory.showChapter(WndStory.ID_CITY);
                    break;
                case 22:
                    WndStory.showChapter(WndStory.ID_HALLS);
                    break;
            }
            if (Dungeon.hero.isAlive() && Dungeon.depth != 22) {
                Badges.validateNoKilling();
            }
            break;
        default:
    }
    ArrayList<Item> dropped = Dungeon.droppedItems.get(Dungeon.depth);
    if (dropped != null) {
        for (Item item : dropped) {
            int pos = Dungeon.level.randomRespawnCell();
            if (item instanceof Potion) {
                ((Potion) item).shatter(pos);
            } else if (item instanceof Plant.Seed) {
                Dungeon.level.plant((Plant.Seed) item, pos);
            } else if (item instanceof Honeypot) {
                Dungeon.level.drop(((Honeypot) item).shatter(null, pos), pos);
            } else {
                Dungeon.level.drop(item, pos);
            }
        }
        Dungeon.droppedItems.remove(Dungeon.depth);
    }
    Dungeon.hero.next();
    Camera.main.target = hero;
    if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
        if (Dungeon.depth == Statistics.deepestFloor && (InterlevelScene.mode == InterlevelScene.Mode.DESCEND || InterlevelScene.mode == InterlevelScene.Mode.FALL)) {
            GLog.h(Messages.get(this, "descend"), Dungeon.depth);
            Sample.INSTANCE.play(Assets.SND_DESCEND);
        } else if (InterlevelScene.mode == InterlevelScene.Mode.RESET) {
            GLog.h(Messages.get(this, "warp"));
        } else {
            GLog.h(Messages.get(this, "return"), Dungeon.depth);
        }
        switch(Dungeon.level.feeling) {
            case CHASM:
                GLog.w(Messages.get(this, "chasm"));
                break;
            case WATER:
                GLog.w(Messages.get(this, "water"));
                break;
            case GRASS:
                GLog.w(Messages.get(this, "grass"));
                break;
            case DARK:
                GLog.w(Messages.get(this, "dark"));
                break;
            default:
        }
        if (Dungeon.level instanceof RegularLevel && ((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
            GLog.w(Messages.get(this, "secrets"));
        }
        InterlevelScene.mode = InterlevelScene.Mode.NONE;
        fadeIn();
    }
    selectCell(defaultCellListener);
}
Also used : Group(com.watabou.noosa.Group) StatusPane(com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane) DungeonTerrainTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap) NoosaScript(com.watabou.noosa.NoosaScript) GridTileMap(com.shatteredpixel.shatteredpixeldungeon.tiles.GridTileMap) AttackIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) WndTradeItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem) WndInfoItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) WndInfoPlant(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant) TargetHealthIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.TargetHealthIndicator) IntMap(com.badlogic.gdx.utils.IntMap) BusyIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.BusyIndicator) SkinnedBlock(com.watabou.noosa.SkinnedBlock) GameLog(com.shatteredpixel.shatteredpixeldungeon.ui.GameLog) Toolbar(com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) WndInfoMob(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob) FogOfWar(com.shatteredpixel.shatteredpixeldungeon.tiles.FogOfWar) Blob(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) ActionIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) ResumeIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator) CustomTiledVisual(com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual) TerrainFeaturesTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.TerrainFeaturesTilemap) WallBlockingTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.WallBlockingTilemap) LootIndicator(com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator) DungeonWallsTilemap(com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonWallsTilemap) HeroSprite(com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite) Honeypot(com.shatteredpixel.shatteredpixeldungeon.items.Honeypot) RegularLevel(com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel)

Example 2 with Potion

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

the class Frost method attachTo.

@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;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) FrozenCarpaccio(com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio) PotionOfMight(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) PotionOfStrength(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength) Thief(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) ArrayList(java.util.ArrayList) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)

Example 3 with Potion

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

the class SecretLaboratoryRoom method paint.

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);
        }
    }
}
Also used : Alchemy(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) HashMap(java.util.HashMap) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 4 with Potion

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

the class Heap method freeze.

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());
        }
    }
}
Also used : PotionOfMight(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) PotionOfStrength(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength) MysteryMeat(com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)

Example 5 with Potion

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

the class ShopRoom method ChooseBag.

protected static Bag ChooseBag(Belongings pack) {
    // 0=pouch, 1=holder, 2=bandolier, 3=holster
    int[] bagItems = new int[4];
    // count up items in the main bag
    for (Item item : pack.backpack.items) {
        if (item instanceof Plant.Seed || item instanceof Runestone)
            bagItems[0]++;
        if (item instanceof Scroll)
            bagItems[1]++;
        if (item instanceof Potion)
            bagItems[2]++;
        if (item instanceof Wand || item instanceof MissileWeapon)
            bagItems[3]++;
    }
    // disqualify bags that have already been dropped
    if (Dungeon.LimitedDrops.VELVET_POUCH.dropped())
        bagItems[0] = -1;
    if (Dungeon.LimitedDrops.SCROLL_HOLDER.dropped())
        bagItems[1] = -1;
    if (Dungeon.LimitedDrops.POTION_BANDOLIER.dropped())
        bagItems[2] = -1;
    if (Dungeon.LimitedDrops.MAGICAL_HOLSTER.dropped())
        bagItems[3] = -1;
    // find the best bag to drop. This does give a preference to later bags, if counts are equal
    int bestBagIdx = 0;
    for (int i = 1; i <= 3; i++) {
        if (bagItems[bestBagIdx] <= bagItems[i]) {
            bestBagIdx = i;
        }
    }
    // drop it, or return nothing if no bag works
    if (bagItems[bestBagIdx] == -1)
        return null;
    switch(bestBagIdx) {
        case 0:
        default:
            Dungeon.LimitedDrops.VELVET_POUCH.drop();
            return new VelvetPouch();
        case 1:
            Dungeon.LimitedDrops.SCROLL_HOLDER.drop();
            return new ScrollHolder();
        case 2:
            Dungeon.LimitedDrops.POTION_BANDOLIER.drop();
            return new PotionBandolier();
        case 3:
            Dungeon.LimitedDrops.MAGICAL_HOLSTER.drop();
            return new MagicalHolster();
    }
}
Also used : Potion(com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion) Scroll(com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll) Wand(com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand) VelvetPouch(com.shatteredpixel.shatteredpixeldungeon.items.bags.VelvetPouch) ScrollHolder(com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder) Runestone(com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone) Point(com.watabou.utils.Point) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) MagicalHolster(com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster) PotionBandolier(com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier) MissileWeapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon)

Aggregations

Potion (com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion)5 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)3 MysteryMeat (com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)2 PotionOfMight (com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight)2 PotionOfStrength (com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength)2 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)2 IntMap (com.badlogic.gdx.utils.IntMap)1 Alchemy (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy)1 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)1 Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)1 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)1 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)1 MagicalHolster (com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster)1 PotionBandolier (com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier)1 ScrollHolder (com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder)1 VelvetPouch (com.shatteredpixel.shatteredpixeldungeon.items.bags.VelvetPouch)1