Search in sources :

Example 6 with Event

use of main.game.logic.event.Event in project Eidolons by IDemiurge.

the class GameManager method effectApplies.

public boolean effectApplies(EffectImpl effect) {
    Ref ref = effect.getRef();
    ref.setEffect(effect);
    return (!getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.EFFECT_IS_BEING_APPLIED, ref)));
}
Also used : Ref(main.entity.Ref) Event(main.game.logic.event.Event)

Example 7 with Event

use of main.game.logic.event.Event in project Eidolons by IDemiurge.

the class DamageDealer method dealDamage.

// proceeds to deal the damage - to toughness and endurance separately and with appropriate events
private static int dealDamage(Ref ref, boolean magical, DAMAGE_TYPE dmg_type) {
    Event event = new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE, ref);
    if (!event.fire()) {
        return -1;
    }
    int amount = ref.getAmount();
    if (amount <= 0) {
        return 0;
    }
    ref = Ref.getCopy(ref);
    DC_ActiveObj active = (DC_ActiveObj) ref.getActive();
    Unit attacker = (Unit) ref.getSourceObj();
    BattleFieldObject attacked = (BattleFieldObject) ref.getTargetObj();
    if (dmg_type == null) {
        dmg_type = active.getEnergyType();
    }
    int blocked = 0;
    if (attacked instanceof Unit)
        if (!DamageCalculator.isUnblockable(ref)) {
            if (ref.getSource() != ref.getTarget()) {
                if (isAttack(ref)) {
                    blocked = attacked.getGame().getArmorMaster().getArmorBlockDamage(amount, (Unit) attacked, attacker, active);
                } else {
                    blocked = attacked.getGame().getArmorMaster().getArmorBlockForActionDamage(amount, dmg_type, attacker, active);
                }
            }
        }
    int t_damage = DamageCalculator.calculateToughnessDamage(attacked, attacker, amount, ref, blocked, dmg_type);
    int e_damage = DamageCalculator.calculateEnduranceDamage(attacked, attacker, amount, ref, blocked, dmg_type);
    // PhaseAnimator.handleDamageAnimAndLog(ref, attacked, magical, dmg_type);
    ref.setAmount(e_damage);
    // TODO separate event types?
    if (!new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_DEALT_MAGICAL_ENDURANCE_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_DEALT_PHYSICAL_ENDURANCE_DAMAGE, ref).fire()) {
        return 0;
    }
    ref.setAmount(t_damage);
    if (!new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_DEALT_MAGICAL_TOUGHNESS_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_DEALT_PHYSICAL_TOUGHNESS_DAMAGE, ref).fire()) {
        return 0;
    }
    int result = dealPureDamage(attacked, attacker, t_damage, e_damage, ref);
    ref.setAmount(result);
    new Event(magical ? STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE : STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE, ref).fire();
    if (isLogOn()) {
        attacked.getGame().getLogManager().doneLogEntryNode(ENTRY_TYPE.DAMAGE, attacked, amount);
    }
    return result;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit)

Example 8 with Event

use of main.game.logic.event.Event in project Eidolons by IDemiurge.

the class ArenaSpawner method spawnWave.

private void spawnWave(List<ObjAtCoordinate> unitMap, Wave wave, boolean prespawnMode) {
    game.getLogManager().log("New encounter: " + wave.getName());
    if (unitMap == null) {
        getPositioner().setMaxSpacePercentageTaken(MAX_SPACE_PERC_CREEPS);
        wave.initUnitMap();
        unitMap = wave.getUnitMap();
    }
    try {
        getBattleMaster().getWaveAssembler().resetPositions(wave);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    for (ObjAtCoordinate oac : unitMap) {
        Coordinates c = oac.getCoordinates();
        FACING_DIRECTION facing = getFacingAdjuster().getFacingForEnemy(c);
        boolean invalid = false;
        if (c == null) {
            invalid = true;
        } else if (c.isInvalid()) {
            invalid = true;
        } else if (game.getBattleField().getGrid().isCoordinateObstructed(c)) {
            invalid = true;
        }
        if (invalid) {
            c = Positioner.adjustCoordinate(c, facing);
        }
        ObjType type = oac.getType();
        Unit unit = (Unit) game.createUnit(type, c, wave.getOwner());
        UnitTrainingMaster.train(unit);
        unit.setFacing(facing);
        wave.addUnit(unit);
        game.fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING, Ref.getSelfTargetingRefCopy(unit)));
    }
    if (!PartyHelper.checkMergeParty(wave)) {
        try {
            PartyHelper.addCreepParty(wave);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) ObjAtCoordinate(main.entity.type.ObjAtCoordinate) ObjType(main.entity.type.ObjType) Coordinates(main.game.bf.Coordinates) Event(main.game.logic.event.Event) Unit(eidolons.entity.obj.unit.Unit)

Example 9 with Event

use of main.game.logic.event.Event in project Eidolons by IDemiurge.

the class GridPanel method onIngameEvent.

private EventCallback onIngameEvent() {
    return param -> {
        Event event = (Event) param.get();
        Ref ref = event.getRef();
        boolean caught = false;
        if (event.getType() == STANDARD_EVENT_TYPE.EFFECT_HAS_BEEN_APPLIED) {
            GuiEventManager.trigger(GuiEventType.EFFECT_APPLIED, event.getRef());
            caught = true;
        } else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_CLOCKWISE || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_ANTICLOCKWISE) {
            BattleFieldObject hero = (BattleFieldObject) ref.getObj(KEYS.TARGET);
            // if (hero.isMainHero()) TODO this is an experiment (insane) feature...
            // if (hero.isMine()) {
            // turnField(event.getType());
            // }
            BaseView view = viewMap.get(hero);
            if (view != null && view instanceof GridUnitView) {
                GridUnitView unitView = ((GridUnitView) view);
                unitView.updateRotation(hero.getFacing().getDirection().getDegrees());
                // SoundController.getCustomEventSound(SOUND_EVENT.UNIT_TURNS, );
                if (hero instanceof Unit)
                    DC_SoundMaster.playTurnSound((Unit) hero);
            }
            caught = true;
        } else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_FALLEN_UNCONSCIOUS) {
            GuiEventManager.trigger(UNIT_GREYED_OUT_ON, ref.getSourceObj());
        } else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_RECOVERED_FROM_UNCONSCIOUSNESS) {
            GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
        } else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED) {
            GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
            if (!DeathAnim.isOn() || ref.isDebug()) {
                GuiEventManager.trigger(DESTROY_UNIT_MODEL, ref.getTargetObj());
            }
            caught = true;
        } else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_BEING_MOVED) {
            if (// || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
            !MoveAnimation.isOn())
                removeUnitView((BattleFieldObject) ref.getSourceObj());
            caught = true;
        } else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_FINISHED_MOVING) {
            if (!MoveAnimation.isOn() || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
                moveUnitView((BattleFieldObject) ref.getSourceObj());
            caught = true;
        } else if (event.getType().name().startsWith("PARAM_BEING_MODIFIED")) {
            caught = true;
        } else if (event.getType().name().startsWith("PROP_")) {
            caught = true;
        } else if (event.getType().name().startsWith("ABILITY_")) {
            caught = true;
        } else if (event.getType().name().startsWith("EFFECT_")) {
            caught = true;
        } else if (event.getType().name().startsWith("PARAM_MODIFIED")) {
            if (GuiEventManager.isParamEventAlwaysFired(event.getType().getArg())) {
                UnitView view = (UnitView) getViewMap().get(event.getRef().getSourceObj());
                if (view != null)
                    if (view.isVisible())
                        if (view.getHpBar() != null)
                            // if (view.getHpBar( ).getDataSource().canHpBarBeVisible())
                            view.resetHpBar(new ResourceSourceImpl((BattleFieldObject) event.getRef().getSourceObj()));
            }
            caught = true;
        }
        if (!caught) {
        /*      System.out.println("catch ingame event: " + event.getType() + " in " + event.getRef());
           */
        }
    };
}
Also used : StrPathBuilder(main.system.auxiliary.StrPathBuilder) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) LastSeenMaster(eidolons.game.battlecraft.logic.battlefield.vision.LastSeenMaster) GuiEventType(main.system.GuiEventType) MapMaster(main.system.auxiliary.data.MapMaster) Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) DungeonScreen(eidolons.libgdx.screens.DungeonScreen) Ref(main.entity.Ref) Pair(org.apache.commons.lang3.tuple.Pair) Vector2(com.badlogic.gdx.math.Vector2) GdxMaster(eidolons.libgdx.GdxMaster) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OptionsMaster(eidolons.system.options.OptionsMaster) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) HpBar(eidolons.libgdx.bf.overlays.HpBar) OUTLINE_TYPE(main.content.enums.rules.VisionEnums.OUTLINE_TYPE) MoveAnimation(eidolons.libgdx.anims.std.MoveAnimation) TextureManager(eidolons.libgdx.texture.TextureManager) DC_Obj(eidolons.entity.obj.DC_Obj) ActorMaster(eidolons.libgdx.anims.ActorMaster) Event(main.game.logic.event.Event) FadeOutAction(eidolons.libgdx.anims.actions.FadeOutAction) Align(com.badlogic.gdx.utils.Align) DC_Game(eidolons.game.core.game.DC_Game) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ShadowMap(eidolons.libgdx.bf.light.ShadowMap) HelpMaster(eidolons.system.text.HelpMaster) List(java.util.List) OutlineMaster(eidolons.game.battlecraft.logic.battlefield.vision.OutlineMaster) Keys(com.badlogic.gdx.Input.Keys) Coordinates(main.game.bf.Coordinates) WallMap(eidolons.libgdx.bf.overlays.WallMap) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) java.util(java.util) DequeImpl(main.system.datatypes.DequeImpl) DeathAnim(eidolons.libgdx.anims.std.DeathAnim) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) AnimMaster(eidolons.libgdx.anims.AnimMaster) EVENT_TYPE(main.game.logic.event.Event.EVENT_TYPE) Gdx(com.badlogic.gdx.Gdx) Batch(com.badlogic.gdx.graphics.g2d.Batch) WaitMaster(main.system.threading.WaitMaster) GuiEventManager(main.system.GuiEventManager) StringMaster(main.system.auxiliary.StringMaster) DC_Engine(eidolons.game.battlecraft.DC_Engine) OverlaysManager(eidolons.libgdx.bf.overlays.OverlaysManager) PanelActionsDataSource(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.PanelActionsDataSource) GRAPHIC_OPTION(eidolons.system.options.GraphicsOptions.GRAPHIC_OPTION) VisionManager(eidolons.game.battlecraft.logic.battlefield.vision.VisionManager) LogMaster(main.system.auxiliary.log.LogMaster) EventCallback(main.system.EventCallback) KEYS(main.entity.Ref.KEYS) AnimationConstructor(eidolons.libgdx.anims.AnimationConstructor) FloatingTextMaster(eidolons.libgdx.anims.text.FloatingTextMaster) ResourceSourceImpl(eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl) Group(com.badlogic.gdx.scenes.scene2d.Group) StyleHolder(eidolons.libgdx.StyleHolder) TEXT_CASES(eidolons.libgdx.anims.text.FloatingTextMaster.TEXT_CASES) eidolons.libgdx.bf(eidolons.libgdx.bf) WAIT_OPERATIONS(main.system.threading.WaitMaster.WAIT_OPERATIONS) java.awt(java.awt) TextureCache(eidolons.libgdx.texture.TextureCache) Eidolons(eidolons.game.core.Eidolons) Unit(eidolons.entity.obj.unit.Unit) DC_SoundMaster(eidolons.system.audio.DC_SoundMaster) SHADE_LIGHT(eidolons.libgdx.bf.light.ShadowMap.SHADE_LIGHT) ResourceSourceImpl(eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Event(main.game.logic.event.Event) Unit(eidolons.entity.obj.unit.Unit)

Example 10 with Event

use of main.game.logic.event.Event in project Eidolons by IDemiurge.

the class GridPanel method init.

public GridPanel init(DequeImpl<BattleFieldObject> units) {
    this.viewMap = new HashMap<>();
    emptyImage = TextureCache.getOrCreateR(getCellImagePath());
    cornerRegion = TextureCache.getOrCreateR(gridCornerElementPath);
    cells = new GridCellContainer[cols][rows];
    int rows1 = rows - 1;
    for (int x = 0; x < cols; x++) {
        for (int y = 0; y < rows; y++) {
            cells[x][y] = new GridCellContainer(emptyImage, x, rows1 - y);
            cells[x][y].setX(x * GridMaster.CELL_W);
            cells[x][y].setY(y * GridMaster.CELL_H);
            addActor(cells[x][y].init());
            checkAddBorder(x, y);
        }
    }
    if (OptionsMaster.getGraphicsOptions().getBooleanValue(GRAPHIC_OPTION.SPRITE_CACHE_ON))
        TextureManager.addCellsToCache(cols, rows);
    addActor(new CellBorderManager());
    bindEvents();
    createUnitsViews(units);
    setHeight(cells[0][0].getHeight() * rows);
    setWidth(cells[0][0].getWidth() * cols);
    addListener(new BattleClickListener() {

        @Override
        public boolean mouseMoved(InputEvent event, float x, float y) {
            GridPanel.this.getStage().setScrollFocus(GridPanel.this);
            return false;
        }

        @Override
        public boolean touchDown(InputEvent e, float x, float y, int pointer, int button) {
            // return PhaseAnimator.getInstance().checkAnimClicked(x, y, pointer, button);
            return false;
        }
    });
    addActor(overlayManager = new OverlaysManager(this));
    addActor(animMaster = AnimMaster.getInstance());
    animMaster.bindEvents();
    if (AnimationConstructor.isPreconstructAllOnGameInit())
        units.forEach(unit -> {
            if (unit instanceof Unit)
                animMaster.getConstructor().preconstructAll((Unit) unit);
        });
    if (fpsDebug) {
        fpsLabel = new Label("0", StyleHolder.getDefaultLabelStyle());
        addActor(fpsLabel);
        fpsLabel.setAlignment(Align.topLeft);
    }
    return this;
}
Also used : StrPathBuilder(main.system.auxiliary.StrPathBuilder) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) LastSeenMaster(eidolons.game.battlecraft.logic.battlefield.vision.LastSeenMaster) GuiEventType(main.system.GuiEventType) MapMaster(main.system.auxiliary.data.MapMaster) Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) DungeonScreen(eidolons.libgdx.screens.DungeonScreen) Ref(main.entity.Ref) Pair(org.apache.commons.lang3.tuple.Pair) Vector2(com.badlogic.gdx.math.Vector2) GdxMaster(eidolons.libgdx.GdxMaster) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OptionsMaster(eidolons.system.options.OptionsMaster) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) HpBar(eidolons.libgdx.bf.overlays.HpBar) OUTLINE_TYPE(main.content.enums.rules.VisionEnums.OUTLINE_TYPE) MoveAnimation(eidolons.libgdx.anims.std.MoveAnimation) TextureManager(eidolons.libgdx.texture.TextureManager) DC_Obj(eidolons.entity.obj.DC_Obj) ActorMaster(eidolons.libgdx.anims.ActorMaster) Event(main.game.logic.event.Event) FadeOutAction(eidolons.libgdx.anims.actions.FadeOutAction) Align(com.badlogic.gdx.utils.Align) DC_Game(eidolons.game.core.game.DC_Game) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ShadowMap(eidolons.libgdx.bf.light.ShadowMap) HelpMaster(eidolons.system.text.HelpMaster) List(java.util.List) OutlineMaster(eidolons.game.battlecraft.logic.battlefield.vision.OutlineMaster) Keys(com.badlogic.gdx.Input.Keys) Coordinates(main.game.bf.Coordinates) WallMap(eidolons.libgdx.bf.overlays.WallMap) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) java.util(java.util) DequeImpl(main.system.datatypes.DequeImpl) DeathAnim(eidolons.libgdx.anims.std.DeathAnim) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) AnimMaster(eidolons.libgdx.anims.AnimMaster) EVENT_TYPE(main.game.logic.event.Event.EVENT_TYPE) Gdx(com.badlogic.gdx.Gdx) Batch(com.badlogic.gdx.graphics.g2d.Batch) WaitMaster(main.system.threading.WaitMaster) GuiEventManager(main.system.GuiEventManager) StringMaster(main.system.auxiliary.StringMaster) DC_Engine(eidolons.game.battlecraft.DC_Engine) OverlaysManager(eidolons.libgdx.bf.overlays.OverlaysManager) PanelActionsDataSource(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.PanelActionsDataSource) GRAPHIC_OPTION(eidolons.system.options.GraphicsOptions.GRAPHIC_OPTION) VisionManager(eidolons.game.battlecraft.logic.battlefield.vision.VisionManager) LogMaster(main.system.auxiliary.log.LogMaster) EventCallback(main.system.EventCallback) KEYS(main.entity.Ref.KEYS) AnimationConstructor(eidolons.libgdx.anims.AnimationConstructor) FloatingTextMaster(eidolons.libgdx.anims.text.FloatingTextMaster) ResourceSourceImpl(eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl) Group(com.badlogic.gdx.scenes.scene2d.Group) StyleHolder(eidolons.libgdx.StyleHolder) TEXT_CASES(eidolons.libgdx.anims.text.FloatingTextMaster.TEXT_CASES) eidolons.libgdx.bf(eidolons.libgdx.bf) WAIT_OPERATIONS(main.system.threading.WaitMaster.WAIT_OPERATIONS) java.awt(java.awt) TextureCache(eidolons.libgdx.texture.TextureCache) Eidolons(eidolons.game.core.Eidolons) Unit(eidolons.entity.obj.unit.Unit) DC_SoundMaster(eidolons.system.audio.DC_SoundMaster) SHADE_LIGHT(eidolons.libgdx.bf.light.ShadowMap.SHADE_LIGHT) OverlaysManager(eidolons.libgdx.bf.overlays.OverlaysManager) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Event (main.game.logic.event.Event)34 Ref (main.entity.Ref)17 Unit (eidolons.entity.obj.unit.Unit)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)6 Coordinates (main.game.bf.Coordinates)4 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3 Gdx (com.badlogic.gdx.Gdx)2 Keys (com.badlogic.gdx.Input.Keys)2 Batch (com.badlogic.gdx.graphics.g2d.Batch)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 Vector2 (com.badlogic.gdx.math.Vector2)2 Group (com.badlogic.gdx.scenes.scene2d.Group)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 Align (com.badlogic.gdx.utils.Align)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 DC_Engine (eidolons.game.battlecraft.DC_Engine)2 LastSeenMaster (eidolons.game.battlecraft.logic.battlefield.vision.LastSeenMaster)2 OutlineMaster (eidolons.game.battlecraft.logic.battlefield.vision.OutlineMaster)2