Search in sources :

Example 1 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class Ring method renewBuff.

private void renewBuff() {
    if (buff != null) {
        Char owner = buff.target;
        buff.detach();
        if ((buff = buff()) != null) {
            buff.attachTo(owner);
        }
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char)

Example 2 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class Shock method hit.

private void hit(Char ch, int damage) {
    if (damage < 1) {
        return;
    }
    affected.add(ch);
    ch.damage(Level.water[ch.pos] && !ch.flying ? (int) (damage * 2) : damage, LightningTrap.LIGHTNING);
    ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
    ch.sprite.flash();
    points[nPoints++] = ch.pos;
    HashSet<Char> ns = new HashSet<Char>();
    for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
        Char n = Actor.findChar(ch.pos + Level.NEIGHBOURS8[i]);
        if (n != null && !affected.contains(n)) {
            ns.add(n);
        }
    }
    if (ns.size() > 0) {
        hit(Random.element(ns), Random.Int(damage / 2, damage));
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) HashSet(java.util.HashSet)

Example 3 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class WandOfDisintegration method onZap.

@Override
protected void onZap(int cell) {
    boolean terrainAffected = false;
    int level = power();
    int maxDistance = distance();
    Ballistica.distance = Math.min(Ballistica.distance, maxDistance);
    ArrayList<Char> chars = new ArrayList<Char>();
    for (int i = 1; i < Ballistica.distance; i++) {
        int c = Ballistica.trace[i];
        Char ch;
        if ((ch = Actor.findChar(c)) != null) {
            chars.add(ch);
        }
        int terr = Dungeon.level.map[c];
        if (terr == Terrain.DOOR || terr == Terrain.SIGN) {
            Dungeon.level.destroy(c);
            GameScene.updateMap(c);
            terrainAffected = true;
        } else if (terr == Terrain.HIGH_GRASS) {
            Level.set(c, Terrain.GRASS);
            GameScene.updateMap(c);
            terrainAffected = true;
        }
        CellEmitter.center(c).burst(PurpleParticle.BURST, Random.IntRange(1, 2));
    }
    if (terrainAffected) {
        Dungeon.observe();
    }
    int lvl = level + chars.size();
    int dmgMin = lvl;
    int dmgMax = 8 + lvl * lvl / 3;
    for (Char ch : chars) {
        ch.damage(Random.NormalIntRange(dmgMin, dmgMax), this);
        ch.sprite.centerEmitter().burst(PurpleParticle.BURST, Random.IntRange(1, 2));
        ch.sprite.flash();
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) ArrayList(java.util.ArrayList)

Example 4 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

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.Cook(cell);
    } else if (Level.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 (Level.fieldOfView[cell] && (heap = Dungeon.level.heaps.get(cell)) != null && heap.type != Heap.Type.HIDDEN) {
        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) {
        curAction = new HeroAction.Descend(cell);
    } else if (cell == Dungeon.level.entrance) {
        curAction = new HeroAction.Ascend(cell);
    } else {
        curAction = new HeroAction.Move(cell);
        lastAction = null;
    }
    return act();
}
Also used : NPC(com.watabou.pixeldungeon.actors.mobs.npcs.NPC) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Heap(com.watabou.pixeldungeon.items.Heap) Char(com.watabou.pixeldungeon.actors.Char)

Example 5 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class ConfusionGas method evolve.

@Override
protected void evolve() {
    super.evolve();
    Char ch;
    for (int i = 0; i < LENGTH; i++) {
        if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) {
            Buff.prolong(ch, Vertigo.class, Vertigo.duration(ch));
        }
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char)

Aggregations

Char (com.watabou.pixeldungeon.actors.Char)27 Heap (com.watabou.pixeldungeon.items.Heap)4 Actor (com.watabou.pixeldungeon.actors.Actor)2 Burning (com.watabou.pixeldungeon.actors.buffs.Burning)2 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)1 SnipersMark (com.watabou.pixeldungeon.actors.buffs.SnipersMark)1 NPC (com.watabou.pixeldungeon.actors.mobs.npcs.NPC)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 Lightning (com.watabou.pixeldungeon.effects.Lightning)1 Pushing (com.watabou.pixeldungeon.effects.Pushing)1 Swap (com.watabou.pixeldungeon.effects.Swap)1 Item (com.watabou.pixeldungeon.items.Item)1 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)1 MissileSprite (com.watabou.pixeldungeon.sprites.MissileSprite)1 Callback (com.watabou.utils.Callback)1