Search in sources :

Example 1 with Buff

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

the class BuffIndicator method layout.

@Override
protected void layout() {
    clear();
    SparseArray<Image> newIcons = new SparseArray<Image>();
    for (Buff buff : ch.buffs()) {
        int icon = buff.icon();
        if (icon != NONE) {
            Image img = new Image(texture);
            img.frame(film.get(icon));
            img.x = x + members.size() * (SIZE + 2);
            img.y = y;
            add(img);
            newIcons.put(icon, img);
        }
    }
    for (Integer key : icons.keyArray()) {
        if (newIcons.get(key) == null) {
            Image icon = icons.get(key);
            icon.origin.set(SIZE / 2);
            add(icon);
            add(new AlphaTweener(icon, 0, 0.6f) {

                @Override
                protected void updateValues(float progress) {
                    super.updateValues(progress);
                    image.scale.set(1 + 5 * progress);
                }

                ;
            });
        }
    }
    icons = newIcons;
}
Also used : SparseArray(com.watabou.utils.SparseArray) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener) Image(com.watabou.noosa.Image) Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Example 2 with Buff

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

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 level = intentional ? (2 * awareness - awareness * awareness) : awareness;
    if (distance <= 0) {
        level /= 2 - distance;
        distance = 1;
    }
    int cx = pos % Level.WIDTH;
    int cy = pos / Level.WIDTH;
    int ax = cx - distance;
    if (ax < 0) {
        ax = 0;
    }
    int bx = cx + distance;
    if (bx >= Level.WIDTH) {
        bx = Level.WIDTH - 1;
    }
    int ay = cy - distance;
    if (ay < 0) {
        ay = 0;
    }
    int by = cy + distance;
    if (by >= Level.HEIGHT) {
        by = Level.HEIGHT - 1;
    }
    for (int y = ay; y <= by; y++) {
        for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {
            if (Dungeon.visible[p]) {
                if (intentional) {
                    sprite.parent.addToBack(new CheckedCell(p));
                }
                if (Level.secret[p] && (intentional || Random.Float() < level)) {
                    int oldValue = Dungeon.level.map[p];
                    GameScene.discoverTile(p, oldValue);
                    Level.set(p, Terrain.discover(oldValue));
                    GameScene.updateMap(p);
                    ScrollOfMagicMapping.discover(p);
                    smthFound = true;
                }
                if (intentional) {
                    Heap heap = Dungeon.level.heaps.get(p);
                    if (heap != null && heap.type == Type.HIDDEN) {
                        heap.open(this);
                        smthFound = true;
                    }
                }
            }
        }
    }
    if (intentional) {
        sprite.showStatus(CharSprite.DEFAULT, TXT_SEARCH);
        sprite.operate(pos);
        if (smthFound) {
            spendAndNext(Random.Float() < level ? 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) RingOfDetection(com.watabou.pixeldungeon.items.rings.RingOfDetection) Buff(com.watabou.pixeldungeon.actors.buffs.Buff) RingOfDetection(com.watabou.pixeldungeon.items.rings.RingOfDetection) Heap(com.watabou.pixeldungeon.items.Heap)

Example 3 with Buff

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

the class Hero method attackSkill.

@Override
public int attackSkill(Char target) {
    int bonus = 0;
    for (Buff buff : buffs(RingOfAccuracy.Accuracy.class)) {
        bonus += ((RingOfAccuracy.Accuracy) buff).level;
    }
    float accuracy = (bonus == 0) ? 1 : (float) Math.pow(1.4, bonus);
    if (rangedWeapon != null && Level.distance(pos, target.pos) == 1) {
        accuracy *= 0.5f;
    }
    KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon;
    if (wep != null) {
        return (int) (attackSkill * accuracy * wep.acuracyFactor(this));
    } else {
        return (int) (attackSkill * accuracy);
    }
}
Also used : RingOfAccuracy(com.watabou.pixeldungeon.items.rings.RingOfAccuracy) KindOfWeapon(com.watabou.pixeldungeon.items.KindOfWeapon) Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Example 4 with Buff

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

the class Hero method spend.

@Override
public void spend(float time) {
    int hasteLevel = 0;
    for (Buff buff : buffs(RingOfHaste.Haste.class)) {
        hasteLevel += ((RingOfHaste.Haste) buff).level;
    }
    super.spend(hasteLevel == 0 ? time : (float) (time * Math.pow(1.1, -hasteLevel)));
}
Also used : RingOfHaste(com.watabou.pixeldungeon.items.rings.RingOfHaste) Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Example 5 with Buff

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

the class Char method restoreFromBundle.

@Override
public void restoreFromBundle(Bundle bundle) {
    super.restoreFromBundle(bundle);
    pos = bundle.getInt(POS);
    HP = bundle.getInt(TAG_HP);
    HT = bundle.getInt(TAG_HT);
    for (Bundlable b : bundle.getCollection(BUFFS)) {
        if (b != null) {
            ((Buff) b).attachTo(this);
        }
    }
}
Also used : Bundlable(com.watabou.utils.Bundlable) Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Aggregations

Buff (com.watabou.pixeldungeon.actors.buffs.Buff)8 Heap (com.watabou.pixeldungeon.items.Heap)2 Image (com.watabou.noosa.Image)1 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)1 Awareness (com.watabou.pixeldungeon.actors.buffs.Awareness)1 Blindness (com.watabou.pixeldungeon.actors.buffs.Blindness)1 MindVision (com.watabou.pixeldungeon.actors.buffs.MindVision)1 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 CheckedCell (com.watabou.pixeldungeon.effects.CheckedCell)1 KindOfWeapon (com.watabou.pixeldungeon.items.KindOfWeapon)1 RingOfAccuracy (com.watabou.pixeldungeon.items.rings.RingOfAccuracy)1 RingOfDetection (com.watabou.pixeldungeon.items.rings.RingOfDetection)1 RingOfEvasion (com.watabou.pixeldungeon.items.rings.RingOfEvasion)1 RingOfHaste (com.watabou.pixeldungeon.items.rings.RingOfHaste)1 Bundlable (com.watabou.utils.Bundlable)1 SparseArray (com.watabou.utils.SparseArray)1