Search in sources :

Example 6 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class DC_MovementManager method moveTo.

public void moveTo(Coordinates coordinates) {
    Unit unit = game.getManager().getActiveObj();
    List<ActionPath> paths = pathCache.get(unit);
    if (paths == null) {
        paths = buildPath(unit, coordinates);
        // Coordinates adjacentCoordinate = coordinates.getAdjacentCoordinate(DirectionMaster
        // .getRelativeDirection(unit.getCoordinates(), coordinates));
        // if (DialogMaster.confirm("No path could be built to " + coordinates
        // + "; proceed to the closest cell? - " + adjacentCoordinate)) {
        // moveTo(adjacentCoordinate);
        // } else {
        // return;
        // }
        pathCache.put(unit, paths);
    }
    if (paths == null) {
        return;
    }
    Action action = null;
    for (ActionPath path : paths) {
        // if (DialogMaster.confirm("Path built to : " + path + "\nExecute "
        // + path.getActions().get(0).toString() + "?")) {
        // action = path.getActions().get(0);
        // break;
        // }
        // just check if still passible
        // if (path.getActions().get(0))
        action = path.getActions().get(0);
        break;
    }
    if (action == null) {
        pathCache.remove(unit);
        return;
    }
    // ActionAnimation anim = new ActionAnimation(action);
    // anim.start();
    Context context = new Context(unit.getRef());
    if (action.getActive().isMove()) {
        context.setTarget(game.getCellByCoordinate(coordinates).getId());
    }
    unit.getGame().getGameLoop().actionInput(new ActionInput(action.getActive(), context));
}
Also used : Context(main.game.logic.action.context.Context) Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ActionInput(eidolons.game.core.ActionInput) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) Unit(eidolons.entity.obj.unit.Unit)

Example 7 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class DeathMaster method unitAnnihilated.

public void unitAnnihilated(Obj _killed, Obj _killer) {
    String message = null;
    if (_killed == _killer) {
        // + _killed.getInfoString();
        message = _killed + " annihilates ";
    } else
        message = _killed + " annihilated by " + _killer;
    SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
    getGame().getGraveyardManager().removeCorpse(_killed);
    _killed.setAnnihilated(true);
    getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_ANNIHILATED, new Context(_killer, _killed)));
// TODO 	getGame().getDroppedItemManager().remove((DC_HeroObj) _killed, item);
}
Also used : Context(main.game.logic.action.context.Context) Event(main.game.logic.event.Event)

Example 8 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class AttackTest method attackTest.

@Test
public void attackTest() {
    assertTrue(source != null);
    assertTrue(target != null);
    int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    assertTrue(source.getNaturalWeapon() != null);
    DC_UnitAction attackAction = source.getAction("punch");
    assertTrue(attackAction != null);
    Eidolons.getGame().getGameLoop().actionInput(new ActionInput(attackAction, new Context(source, target)));
    // old! attackAction.activateOn(target);
    Boolean result = (Boolean) WaitMaster.waitForInput(WAIT_OPERATIONS.ACTION_COMPLETE);
    assertTrue(result);
    Integer newToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    Integer newEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    assertTrue(newToughness < origToughness);
    assertTrue(newEndurance < origEndurance);
}
Also used : Context(main.game.logic.action.context.Context) ActionInput(eidolons.game.core.ActionInput) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Test(org.junit.Test)

Example 9 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class FacingPanel method getGearListener.

private EventListener getGearListener(boolean clockwise) {
    return new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // GuiEventManager
            WaitMaster.receiveInput(WAIT_OPERATIONS.ACTION_INPUT, new ActionInput(dataSource.getTurnAction(clockwise), new Context(dataSource.getEntity().getRef())));
            GearCluster gear = clockwise ? gearsClockwise : gearsAntiClockwise;
            gear.activeWork(0.25f, 0.5f);
            return super.touchDown(event, x, y, pointer, button);
        }
    };
}
Also used : Context(main.game.logic.action.context.Context) ActionInput(eidolons.game.core.ActionInput) GearCluster(eidolons.libgdx.gui.generic.GearCluster) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 10 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class QuickWeaponPanel method getListener.

private EventListener getListener() {
    return new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (button == 1) {
                GuiEventManager.trigger(GuiEventType.RADIAL_MENU_CLOSE);
                GuiEventManager.trigger(GuiEventType.CREATE_RADIAL_MENU, dataSource.getWeapon());
            } else {
                WaitMaster.receiveInput(WAIT_OPERATIONS.ACTION_INPUT, new ActionInput(getDataSource().getOwnerObj().getAttackAction(offhand), new Context(getDataSource().getOwnerObj(), null)));
            }
            return false;
        }

        @Override
        public boolean mouseMoved(InputEvent event, float x, float y) {
            return super.mouseMoved(event, x, y);
        }

        @Override
        public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
            super.enter(event, x, y, pointer, fromActor);
            weapon.setZIndex(getChildren().size - 2);
        }

        @Override
        public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
            super.exit(event, x, y, pointer, toActor);
            weapon.setZIndex(1);
        }
    };
}
Also used : Context(main.game.logic.action.context.Context) ActionInput(eidolons.game.core.ActionInput) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

Context (main.game.logic.action.context.Context)14 ActionInput (eidolons.game.core.ActionInput)9 Unit (eidolons.entity.obj.unit.Unit)4 DC_UnitAction (eidolons.entity.active.DC_UnitAction)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 DungeonObj (eidolons.game.module.dungeoncrawl.objects.DungeonObj)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 DC_QuickItemAction (eidolons.entity.active.DC_QuickItemAction)1 DC_SpellObj (eidolons.entity.active.DC_SpellObj)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 AiQuickItemAction (eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction)1 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)1 AnimContext (eidolons.libgdx.anims.AnimContext)1 GearCluster (eidolons.libgdx.gui.generic.GearCluster)1 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)1 Obj (main.entity.obj.Obj)1 Coordinates (main.game.bf.Coordinates)1