Search in sources :

Example 1 with BaseView

use of eidolons.libgdx.bf.grid.BaseView in project Eidolons by IDemiurge.

the class DoorAnimation method start.

@Override
public void start() {
    setDuration(1);
    Obj door = getRef().getTargetObj();
    BaseView actor = DungeonScreen.getInstance().getGridPanel().getViewMap().get(door);
    // ActorMaster.addFadeInOrOut(actor.getPortrait(), getDuration());
    if (open) {
        String path = door.getImagePath();
        path = StringMaster.cropFormat(path) + "_open" + ".png";
        // if (newImage == null)
        {
            // TODO as an afterAction!
            TextureRegion r = TextureCache.getOrCreateR(path);
            actor.setOriginalTextureAlt(r);
        // newImage = new Image(r);
        }
    } else {
        actor.setOriginalTextureAlt(null);
    // newImage = actor.getAltPortrait();
    }
    // newImage.setColor(1, 1, 1, 0);
    // actor.setAltPortrait(actor.getPortrait());
    // actor.setPortrait(newImage);
    // actor.addActor(newImage);
    // ActorMaster.addFadeInOrOut(actor.getPortrait(), getDuration());
    super.start();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Obj(main.entity.obj.Obj) BaseView(eidolons.libgdx.bf.grid.BaseView)

Example 2 with BaseView

use of eidolons.libgdx.bf.grid.BaseView in project Eidolons by IDemiurge.

the class FloatingTextMaster method createAndShowParamModText.

public void createAndShowParamModText(Object o) {
    Pair<PARAMETER, Ref> pair = (Pair<PARAMETER, Ref>) o;
    Entity active = pair.getValue().getObj(KEYS.ACTIVE);
    int amount = 0;
    if (pair.getValue().getAmount() != null)
        amount = pair.getValue().getAmount();
    else {
        return;
    }
    FloatingText text = getFloatingText(active, TEXT_CASES.PARAM_MOD, new ImmutablePair<>(pair.getKey(), amount));
    Obj obj = active.getRef().getTargetObj();
    if (obj == null)
        obj = active.getRef().getSourceObj();
    if (obj != null) {
        BaseView view = DungeonScreen.getInstance().getGridPanel().getViewMap().get(obj);
        if (view != null) {
            Vector2 v = view.localToStageCoordinates(new Vector2(view.getX(), view.getY()));
            text.setPosition(v.x, v.y);
        }
    }
    GuiEventManager.trigger(GuiEventType.ADD_FLOATING_TEXT, text);
}
Also used : Entity(main.entity.Entity) Ref(main.entity.Ref) Vector2(com.badlogic.gdx.math.Vector2) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) BaseView(eidolons.libgdx.bf.grid.BaseView) PARAMETER(main.content.values.parameters.PARAMETER) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 3 with BaseView

use of eidolons.libgdx.bf.grid.BaseView in project Eidolons by IDemiurge.

the class MoveAnimation method start.

@Override
public void start() {
    try {
        super.start();
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    Unit unit = (Unit) getRef().getSourceObj();
    if (!ListMaster.isNotEmpty(EffectFinder.getEffectsOfClass(getActive(), MoveEffect.class)))
        unit = (Unit) getRef().getTargetObj();
    BaseView actor = DungeonScreen.getInstance().getGridPanel().getViewMap().get(unit);
    if (!DungeonScreen.getInstance().getGridPanel().detachUnitView(unit)) {
        return;
    }
    // DungeonScreen.getInstance().getGridStage().addActor(actor);
    // actor.setPosition(getX(), getY());
    getAction().setStartPointY(actor.getY());
    getAction().setStartPointX(actor.getX());
    actor.addAction(getAction());
    action.setTarget(actor);
}
Also used : BaseView(eidolons.libgdx.bf.grid.BaseView) Unit(eidolons.entity.obj.unit.Unit)

Example 4 with BaseView

use of eidolons.libgdx.bf.grid.BaseView in project Eidolons by IDemiurge.

the class GdxUnitPosSizeTest method test.

@Test
public void test() {
    WaitMaster.waitForInput(WAIT_OPERATIONS.DUNGEON_SCREEN_READY);
    player = DC_Game.game.getPlayer(true);
    for (Unit unit : DC_Game.game.getUnits()) {
        BaseView component = DungeonScreen.getInstance().getGridPanel().getViewMap().get(unit);
        container = (GridCellContainer) component.getParent();
        container.recalcUnitViewBounds();
        int index = 0;
        for (BaseView sub : container.getUnitViews(true)) {
            checkComponent(sub, container.getUnitViews(true).size(), // + 2
            index);
            index++;
        }
    }
}
Also used : BaseView(eidolons.libgdx.bf.grid.BaseView) Unit(eidolons.entity.obj.unit.Unit) Test(org.junit.Test)

Example 5 with BaseView

use of eidolons.libgdx.bf.grid.BaseView in project Eidolons by IDemiurge.

the class ShadeLightCell method adjustPosition.

public void adjustPosition(int x, int y) {
    float offsetX = 0;
    float offsetY = 0;
    setScale(1f, 1f);
    setVisible(true);
    for (Obj sub : DC_Game.game.getRules().getIlluminationRule().getEffectCache().keySet()) {
        if (sub instanceof Unit)
            // TODO illuminate some other way for units...
            continue;
        if (sub instanceof Structure) {
            if (sub.getCoordinates().x == x)
                if (sub.getCoordinates().y == y)
                    if (((Structure) sub).isOverlaying()) {
                        DIRECTION d = ((Structure) sub).getDirection();
                        if (d == null) {
                            setScale(0.7f, 0.7f);
                            continue;
                        }
                        setScale(d.growX == null ? 1 : 0.8f, d.growY == null ? 1 : 0.8f);
                        Dimension dim = GridMaster.getOffsetsForOverlaying(d, (int) getWidth() - 64, (int) getHeight() - 64);
                        offsetX += dim.width;
                        offsetY += dim.height;
                    // so if 2+ overlays, will be centered between them...
                    } else {
                        BaseView view = DungeonScreen.getInstance().getGridPanel().getViewMap().get(sub);
                        offsetX += view.getX() * 3;
                        offsetY += view.getY() * 3;
                        if (view.getParent() instanceof GridCellContainer) {
                            if ((((GridCellContainer) view.getParent()).getUnitViews(true).size() > 1)) {
                                if (!view.isHovered())
                                    setVisible(false);
                            }
                        }
                    }
        }
    }
    setPosition(originalX + offsetX / 3, originalY + offsetY / 3);
}
Also used : Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) GridCellContainer(eidolons.libgdx.bf.grid.GridCellContainer) BaseView(eidolons.libgdx.bf.grid.BaseView) Unit(eidolons.entity.obj.unit.Unit) Structure(eidolons.entity.obj.Structure)

Aggregations

BaseView (eidolons.libgdx.bf.grid.BaseView)5 Unit (eidolons.entity.obj.unit.Unit)3 Obj (main.entity.obj.Obj)3 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 Structure (eidolons.entity.obj.Structure)1 GridCellContainer (eidolons.libgdx.bf.grid.GridCellContainer)1 PARAMETER (main.content.values.parameters.PARAMETER)1 Entity (main.entity.Entity)1 Ref (main.entity.Ref)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Pair (org.apache.commons.lang3.tuple.Pair)1 Test (org.junit.Test)1