Search in sources :

Example 31 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.

the class WindGust method cast.

@Override
public boolean cast(Char chr, int cell) {
    Level level = Dungeon.level;
    if (level.cellValid(cell)) {
        Char ch;
        boolean triggered = false;
        Ballistica.cast(chr.getPos(), cell, true, false);
        for (int i = 1; i < 3; i++) {
            int c = Ballistica.trace[i];
            if ((ch = Actor.findChar(c)) != null) {
                int next = Ballistica.trace[i + 1];
                triggered = true;
                ch.getSprite().emitter().burst(WindParticle.FACTORY, 5);
                ch.getSprite().burst(0xFF99FFFF, 3);
                Sample.INSTANCE.play(Assets.SND_MELD);
                if (ch.isMovable() && (level.passable[next] || level.avoid[next]) && Actor.findChar(next) == null) {
                    ch.move(next);
                    ch.getSprite().move(ch.getPos(), next);
                    Dungeon.observe();
                } else {
                    ch.damage(2, this);
                }
            }
            if (triggered) {
                castCallback(chr);
                return true;
            }
        }
    }
    return false;
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) Level(com.watabou.pixeldungeon.levels.Level)

Example 32 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.

the class Bounce method proc.

@Override
public int proc(Armor armor, @NonNull Char attacker, Char defender, int damage) {
    int armorLevel = Math.max(0, armor.level());
    Level level = Dungeon.level;
    if (attacker.isMovable() && level.adjacent(attacker.getPos(), defender.getPos()) && Random.Int(armorLevel + 5) >= 4) {
        for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
            int ofs = Level.NEIGHBOURS8[i];
            if (attacker.getPos() - defender.getPos() == ofs) {
                int newPos = attacker.getPos() + ofs;
                if (newPos < 0 || newPos > level.passable.length) {
                    newPos = defender.getPos();
                }
                if ((level.passable[newPos] || level.avoid[newPos]) && Actor.findChar(newPos) == null) {
                    Actor.addDelayed(new Pushing(attacker, attacker.getPos(), newPos), -1);
                    attacker.setPos(newPos);
                    level.press(newPos, attacker);
                }
                break;
            }
        }
    }
    return damage;
}
Also used : Pushing(com.watabou.pixeldungeon.effects.Pushing) Level(com.watabou.pixeldungeon.levels.Level)

Example 33 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.

the class PseudoPasty method pick.

@Override
public Item pick(Char ch, int pos) {
    Level level = Dungeon.level;
    int spawnPos = level.getEmptyCellNextTo(pos);
    if (!level.cellValid(spawnPos)) {
        return this;
    }
    MimicPie mob = new MimicPie();
    mob.setPos(spawnPos);
    mob.setState(mob.WANDERING);
    mob.adjustStats(Dungeon.depth);
    level.spawnMob(mob);
    Dungeon.hero.checkVisibleMobs();
    AttackIndicator.updateState();
    CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
    Sample.INSTANCE.play(Assets.SND_MIMIC);
    return null;
}
Also used : Level(com.watabou.pixeldungeon.levels.Level) MimicPie(com.watabou.pixeldungeon.actors.mobs.MimicPie)

Example 34 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.

the class Hero method getCloser.

private boolean getCloser(final int target) {
    if (rooted) {
        return false;
    }
    int step = -1;
    Level level = Dungeon.level;
    Buff wallWalkerBuff = null;
    if (!level.isBossLevel()) {
        wallWalkerBuff = buff(RingOfStoneWalking.StoneWalking.class);
    }
    if (level.adjacent(getPos(), target)) {
        if (Actor.findChar(target) == null) {
            if (!hasBuff(Blindness.class)) {
                if (level.pit[target] && !isFlying() && !Chasm.jumpConfirmed) {
                    Chasm.heroJump(this);
                    interrupt();
                    return false;
                }
                if (TrapHelper.isVisibleTrap(level.map[target]) && !isFlying() && !TrapHelper.stepConfirmed) {
                    TrapHelper.heroTriggerTrap(this);
                    interrupt();
                    return false;
                }
            }
            if (wallWalkerBuff == null && (level.passable[target] || level.avoid[target])) {
                step = target;
            }
            if (wallWalkerBuff != null && level.solid[target]) {
                step = target;
            }
            LevelObject obj = level.getTopLevelObject(target);
            if (obj != null && obj.pushable(this)) {
                interrupt();
                if (!obj.push(this)) {
                    return false;
                }
            }
        }
    } else {
        int len = level.getLength();
        boolean[] p = wallWalkerBuff != null ? level.solid : level.passable;
        boolean[] v = level.visited;
        boolean[] m = level.mapped;
        boolean[] passable = new boolean[len];
        for (int i = 0; i < len; i++) {
            passable[i] = p[i] && (v[i] || m[i]);
        }
        step = Dungeon.findPath(this, getPos(), target, passable, level.fieldOfView);
    }
    if (step != -1) {
        int oldPos = getPos();
        LevelObject obj = level.getTopLevelObject(step);
        if (obj != null) {
            if (step == target) {
                interrupt();
                if (!obj.interact(this)) {
                    return false;
                }
            } else {
                if (!obj.stepOn(this)) {
                    interrupt();
                    return false;
                }
            }
        }
        move(step);
        getSprite().move(oldPos, getPos());
        if (wallWalkerBuff != null) {
            int dmg = hp() / 2 > 2 ? hp() / 2 : 2;
            damage(dmg, wallWalkerBuff);
        }
        spend(1 / speed());
        return true;
    } else {
        return false;
    }
}
Also used : LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) Blindness(com.watabou.pixeldungeon.actors.buffs.Blindness) Level(com.watabou.pixeldungeon.levels.Level) Buff(com.watabou.pixeldungeon.actors.buffs.Buff) RingOfStoneWalking(com.watabou.pixeldungeon.items.rings.RingOfStoneWalking)

Example 35 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.

the class Hero method search.

public boolean search(boolean intentional) {
    boolean smthFound = false;
    int positive = 0;
    int negative = 0;
    for (Buff buff : buffs(RingOfDetection.Detection.class)) {
        int bonus = ((RingOfDetection.Detection) buff).level;
        if (bonus > positive) {
            positive = bonus;
        } else if (bonus < 0) {
            negative += bonus;
        }
    }
    int distance = 1 + positive + negative;
    float searchLevel = intentional ? (2 * awareness - awareness * awareness) : awareness;
    if (distance <= 0) {
        searchLevel /= 2 - distance;
        distance = 1;
    }
    Level level = Dungeon.level;
    int cx = level.cellX(getPos());
    int cy = level.cellY(getPos());
    int ax = cx - distance;
    if (ax < 0) {
        ax = 0;
    }
    int bx = cx + distance;
    if (bx >= level.getWidth()) {
        bx = level.getWidth() - 1;
    }
    int ay = cy - distance;
    if (ay < 0) {
        ay = 0;
    }
    int by = cy + distance;
    if (by >= level.getHeight()) {
        by = level.getHeight() - 1;
    }
    for (int y = ay; y <= by; y++) {
        for (int x = ax, p = ax + y * level.getWidth(); x <= bx; x++, p++) {
            if (Dungeon.visible[p]) {
                if (intentional) {
                    getSprite().getParent().addToBack(new CheckedCell(p));
                }
                if (intentional || Random.Float() < searchLevel) {
                    if (level.secret[p]) {
                        int oldValue = level.map[p];
                        GameScene.discoverTile(p);
                        level.set(p, Terrain.discover(oldValue));
                        GameScene.updateMap(p);
                        ScrollOfMagicMapping.discover(p);
                        smthFound = true;
                    }
                    LevelObject obj = level.getLevelObject(p);
                    if (obj != null && obj.secret()) {
                        obj.discover();
                        smthFound = true;
                    }
                }
            }
        }
    }
    if (intentional) {
        getSprite().showStatus(CharSprite.DEFAULT, TXT_SEARCH);
        getSprite().operate(getPos());
        if (smthFound) {
            spendAndNext(Random.Float() < searchLevel ? TIME_TO_SEARCH : TIME_TO_SEARCH * 2);
        } else {
            spendAndNext(TIME_TO_SEARCH);
        }
    }
    if (smthFound) {
        GLog.w(TXT_NOTICED_SMTH);
        Sample.INSTANCE.play(Assets.SND_SECRET);
        interrupt();
    }
    return smthFound;
}
Also used : CheckedCell(com.watabou.pixeldungeon.effects.CheckedCell) LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) RingOfDetection(com.watabou.pixeldungeon.items.rings.RingOfDetection) Level(com.watabou.pixeldungeon.levels.Level) Buff(com.watabou.pixeldungeon.actors.buffs.Buff) RingOfDetection(com.watabou.pixeldungeon.items.rings.RingOfDetection)

Aggregations

Level (com.watabou.pixeldungeon.levels.Level)37 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)7 Char (com.watabou.pixeldungeon.actors.Char)5 DeadEndLevel (com.watabou.pixeldungeon.levels.DeadEndLevel)5 LevelObject (com.nyrds.pixeldungeon.levels.objects.LevelObject)4 Pushing (com.watabou.pixeldungeon.effects.Pushing)4 IceCavesLevel (com.nyrds.pixeldungeon.levels.IceCavesLevel)3 NecroLevel (com.nyrds.pixeldungeon.levels.NecroLevel)3 Position (com.nyrds.pixeldungeon.utils.Position)3 Heap (com.watabou.pixeldungeon.items.Heap)3 CavesBossLevel (com.watabou.pixeldungeon.levels.CavesBossLevel)3 CavesLevel (com.watabou.pixeldungeon.levels.CavesLevel)3 CityBossLevel (com.watabou.pixeldungeon.levels.CityBossLevel)3 CityLevel (com.watabou.pixeldungeon.levels.CityLevel)3 HallsBossLevel (com.watabou.pixeldungeon.levels.HallsBossLevel)3 HallsLevel (com.watabou.pixeldungeon.levels.HallsLevel)3 LastLevel (com.watabou.pixeldungeon.levels.LastLevel)3 LastShopLevel (com.watabou.pixeldungeon.levels.LastShopLevel)3 PrisonBossLevel (com.watabou.pixeldungeon.levels.PrisonBossLevel)3 PrisonLevel (com.watabou.pixeldungeon.levels.PrisonLevel)3