Search in sources :

Example 26 with Char

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

the class Freezing method evolve.

@Override
protected void evolve() {
    boolean[] water = Dungeon.level.water;
    int cell;
    Fire fire = (Fire) Dungeon.level.blobs.get(Fire.class);
    for (int i = area.left - 1; i <= area.right; i++) {
        for (int j = area.top - 1; j <= area.bottom; j++) {
            cell = i + j * Dungeon.level.width();
            if (cur[cell] > 0) {
                if (fire != null && fire.volume > 0 && fire.cur[cell] > 0) {
                    fire.clear(cell);
                    off[cell] = cur[cell] = 0;
                    continue;
                }
                Char ch = Actor.findChar(cell);
                if (ch != null && !ch.isImmune(this.getClass())) {
                    if (ch.buff(Frost.class) != null) {
                        Buff.affect(ch, Frost.class, 2f);
                    } else {
                        Buff.affect(ch, Chill.class, water[cell] ? 5f : 3f);
                        Chill chill = ch.buff(Chill.class);
                        if (chill != null && chill.cooldown() >= 10f) {
                            Buff.affect(ch, Frost.class, 5f);
                        }
                    }
                }
                Heap heap = Dungeon.level.heaps.get(cell);
                if (heap != null)
                    heap.freeze();
                off[cell] = cur[cell] - 1;
                volume += off[cell];
            } else {
                off[cell] = 0;
            }
        }
    }
}
Also used : Chill(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Frost(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 27 with Char

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

the class Hero method handle.

public boolean handle(int cell) {
    if (cell == -1) {
        return false;
    }
    Char ch;
    Heap heap;
    if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
        curAction = new HeroAction.Alchemy(cell);
    } else if (fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) {
        if (ch instanceof NPC) {
            curAction = new HeroAction.Interact((NPC) ch);
        } else {
            curAction = new HeroAction.Attack(ch);
        }
    } else if ((heap = Dungeon.level.heaps.get(cell)) != null && // moving to an item doesn't auto-pickup when enemies are near...
    (visibleEnemies.size() == 0 || cell == pos || // ...but only for standard heaps, chests and similar open as normal.
    (heap.type != Type.HEAP && heap.type != Type.FOR_SALE))) {
        switch(heap.type) {
            case HEAP:
                curAction = new HeroAction.PickUp(cell);
                break;
            case FOR_SALE:
                curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell) : new HeroAction.PickUp(cell);
                break;
            default:
                curAction = new HeroAction.OpenChest(cell);
        }
    } else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
        curAction = new HeroAction.Unlock(cell);
    } else if (cell == Dungeon.level.exit && Dungeon.depth < 26) {
        curAction = new HeroAction.Descend(cell);
    } else if (cell == Dungeon.level.entrance) {
        curAction = new HeroAction.Ascend(cell);
    } else {
        curAction = new HeroAction.Move(cell);
        lastAction = null;
    }
    if (ready)
        return act();
    else
        return false;
}
Also used : NPC(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Example 28 with Char

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

the class Item method cast.

public void cast(final Hero user, final int dst) {
    final int cell = throwPos(user, dst);
    user.sprite.zap(cell);
    user.busy();
    Sample.INSTANCE.play(Assets.SND_MISS, 0.6f, 0.6f, 1.5f);
    Char enemy = Actor.findChar(cell);
    QuickSlotButton.target(enemy);
    final float delay = castDelay(user, dst);
    if (enemy != null) {
        ((MissileSprite) user.sprite.parent.recycle(MissileSprite.class)).reset(user.sprite, enemy.sprite, this, new Callback() {

            @Override
            public void call() {
                Item.this.detach(user.belongings.backpack).onThrow(cell);
                user.spendAndNext(delay);
            }
        });
    } else {
        ((MissileSprite) user.sprite.parent.recycle(MissileSprite.class)).reset(user.sprite, cell, this, new Callback() {

            @Override
            public void call() {
                Item.this.detach(user.belongings.backpack).onThrow(cell);
                user.spendAndNext(delay);
            }
        });
    }
}
Also used : Callback(com.watabou.utils.Callback) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) MissileSprite(com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite)

Example 29 with Char

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

the class Potion method splash.

protected void splash(int cell) {
    Fire fire = (Fire) Dungeon.level.blobs.get(Fire.class);
    if (fire != null)
        fire.clear(cell);
    final int color = ItemSprite.pick(image, 8, 10);
    Char ch = Actor.findChar(cell);
    if (ch != null) {
        Buff.detach(ch, Burning.class);
        Buff.detach(ch, Ooze.class);
        Splash.at(ch.sprite.center(), color, 5);
    } else {
        Splash.at(cell, color, 5);
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Fire(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)

Example 30 with Char

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

the class Dungeon method flee.

public static int flee(Char ch, int cur, int from, boolean[] pass, boolean[] visible) {
    setupPassable();
    if (ch.flying) {
        BArray.or(pass, Dungeon.level.avoid, passable);
    } else {
        System.arraycopy(pass, 0, passable, 0, Dungeon.level.length());
    }
    for (Char c : Actor.chars()) {
        if (visible[c.pos]) {
            passable[c.pos] = false;
        }
    }
    passable[cur] = true;
    return PathFinder.getStepBack(cur, from, passable);
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char)

Aggregations

Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)65 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)13 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)8 Callback (com.watabou.utils.Callback)8 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)5 ArrayList (java.util.ArrayList)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)3 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)3 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)3 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)3 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Paralysis (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis)2 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)2 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 CorrosiveGas (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1