Search in sources :

Example 41 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CellSelector method onClick.

@Override
protected void onClick(NoosaInputProcessor.Touch touch) {
    if (dragging) {
        dragging = false;
    } else {
        PointF p = Camera.main.screenToCamera((int) touch.current.x, (int) touch.current.y);
        for (Char mob : Dungeon.level.mobs.toArray(new Mob[0])) {
            if (mob.sprite != null && mob.sprite.overlapsPoint(p.x, p.y)) {
                select(mob.pos);
                return;
            }
        }
        for (Heap heap : Dungeon.level.heaps.values()) {
            if (heap.sprite != null && heap.sprite.overlapsPoint(p.x, p.y)) {
                select(heap.pos);
                return;
            }
        }
        select(((DungeonTilemap) target).screenToTile((int) touch.current.x, (int) touch.current.y, true));
    }
}
Also used : Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) PointF(com.watabou.utils.PointF) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 42 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CharSprite method bloodBurstA.

public void bloodBurstA(PointF from, int damage) {
    if (visible) {
        PointF c = center();
        int n = (int) Math.min(9 * Math.sqrt((double) damage / ch.HT), 9);
        Splash.at(c, PointF.angle(from, c), 3.1415926f / 2, blood(), n);
    }
}
Also used : PointF(com.watabou.utils.PointF)

Example 43 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class OptionSlider method createChildren.

@Override
protected void createChildren() {
    super.createChildren();
    add(BG = Chrome.get(Chrome.Type.BUTTON));
    BG.alpha(0.5f);
    add(title = PixelScene.renderText(9));
    add(this.minTxt = PixelScene.renderText(6));
    add(this.maxTxt = PixelScene.renderText(6));
    add(sliderBG = new ColorBlock(1, 1, 0xFF222222));
    sliderNode = Chrome.get(Chrome.Type.BUTTON);
    sliderNode.size(5, 9);
    touchArea = new TouchArea(0, 0, 0, 0) {

        boolean pressed = false;

        @Override
        protected void onTouchDown(NoosaInputProcessor.Touch touch) {
            pressed = true;
            PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
            sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
            sliderNode.brightness(1.5f);
        }

        @Override
        protected void onDrag(NoosaInputProcessor.Touch touch) {
            if (pressed) {
                PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
                sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
            }
        }

        @Override
        protected void onTouchUp(NoosaInputProcessor.Touch touch) {
            if (pressed) {
                PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
                sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
                sliderNode.resetColor();
                // sets the selected value
                selectedVal = minVal + Math.round(sliderNode.x / tickDist);
                sliderNode.x = (int) (x + tickDist * (selectedVal - minVal));
                onChange();
                pressed = false;
            }
        }
    };
    add(touchArea);
}
Also used : TouchArea(com.watabou.noosa.TouchArea) PointF(com.watabou.utils.PointF) NoosaInputProcessor(com.watabou.input.NoosaInputProcessor) ColorBlock(com.watabou.noosa.ColorBlock)

Example 44 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class TerrainFeaturesTilemap method growPlant.

public void growPlant(final int pos) {
    final Image plant = tile(pos, map[pos]);
    if (plant == null)
        return;
    plant.origin.set(8, 12);
    plant.scale.set(0);
    plant.point(DungeonTilemap.tileToWorld(pos));
    parent.add(plant);
    parent.add(new ScaleTweener(plant, new PointF(1, 1), 0.2f) {

        protected void onComplete() {
            plant.killAndErase();
            killAndErase();
            updateMapCell(pos);
        }
    });
}
Also used : ScaleTweener(com.watabou.noosa.tweeners.ScaleTweener) PointF(com.watabou.utils.PointF) Image(com.watabou.noosa.Image)

Example 45 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Compass method update.

@Override
public void update() {
    super.update();
    if (cell < 0 || cell >= Dungeon.level.length()) {
        visible = false;
        return;
    }
    if (!visible) {
        visible = Dungeon.level.visited[cell] || Dungeon.level.mapped[cell];
    }
    if (visible) {
        PointF scroll = Camera.main.scroll;
        if (!scroll.equals(lastScroll)) {
            lastScroll.set(scroll);
            PointF center = Camera.main.center().offset(scroll);
            angle = (float) Math.atan2(cellCenter.x - center.x, center.y - cellCenter.y) * RAD_2_G;
        }
    }
}
Also used : PointF(com.watabou.utils.PointF)

Aggregations

PointF (com.watabou.utils.PointF)56 Emitter (com.watabou.noosa.particles.Emitter)9 ScaleTweener (com.watabou.noosa.tweeners.ScaleTweener)5 Point (com.watabou.utils.Point)5 RectF (android.graphics.RectF)3 PosTweener (com.watabou.noosa.tweeners.PosTweener)3 ArrayList (java.util.ArrayList)2 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 Crossbow (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow)1 Dart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)1 Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)1 ConnectionRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom)1 CharSprite (com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite)1 NoosaInputProcessor (com.watabou.input.NoosaInputProcessor)1 ColorBlock (com.watabou.noosa.ColorBlock)1 Image (com.watabou.noosa.Image)1 TextureFilm (com.watabou.noosa.TextureFilm)1 TouchArea (com.watabou.noosa.TouchArea)1