Search in sources :

Example 21 with Event

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

the class DeathMaster method unitDies.

public void unitDies(DC_ActiveObj activeObj, Obj _killed, Obj _killer, boolean leaveCorpse, boolean quietly) {
    if (_killed.isDead())
        return;
    String message = null;
    if (_killed == _killer) {
        // + _killed.getInfoString();
        message = _killed + " dies ";
    } else
        message = _killed + " killed by " + _killer + " with " + activeObj;
    SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
    _killed.setDead(true);
    BattleFieldObject killed = (BattleFieldObject) _killed;
    BattleFieldObject killer = (BattleFieldObject) _killer;
    Ref ref = Ref.getCopy(killed.getRef());
    ref.setSource(killer.getId());
    ref.setTarget(killed.getId());
    for (AbilityObj abil : killed.getPassives()) {
        abil.kill();
    }
    if (killed.getBuffs() != null) {
        for (Attachment attach : killed.getBuffs()) {
            if (!attach.isRetainAfterDeath()) {
                getState().getAttachmentsMap().get(killed).remove(attach);
                attach.remove();
            }
        }
    }
    if (!leaveCorpse) {
    // leave a *ghost*?
    // destroy items?
    } else {
        if (killed instanceof Unit) {
            try {
                getGame().getDroppedItemManager().dropDead((Unit) killed);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
        try {
            getGame().getGraveyardManager().unitDies(killed);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    // getGame().getBattleField().remove(killed); // TODO GRAVEYARD
    if (!quietly) {
        Ref REF = Ref.getCopy(killer.getRef());
        REF.setTarget(killed.getId());
        REF.setSource(killer.getId());
        if (activeObj != null)
            REF.setObj(KEYS.ACTIVE, activeObj);
        if (killed instanceof Unit) {
            getGame().getRules().getMoraleKillingRule().unitDied((Unit) killed, killer.getRef().getAnimationActive());
        }
        LogEntryNode node = game.getLogManager().newLogEntryNode(ENTRY_TYPE.DEATH, killed);
        if (killer.getRef().getAnimationActive() != null) {
            ANIM animation = killer.getRef().getAnimationActive().getAnimation();
            if (animation != null) {
                animation.addPhase(new AnimPhase(PHASE_TYPE.DEATH, killer, killed));
                node.setLinkedAnimation(animation);
            }
        }
        DC_SoundMaster.playEffectSound(SOUNDS.DEATH, killed);
        game.getLogManager().logDeath(killed, killer);
        getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED, REF));
        game.getLogManager().doneLogEntryNode();
    } else {
        GuiEventManager.trigger(GuiEventType.DESTROY_UNIT_MODEL, killed);
    }
// refreshAll();
}
Also used : AbilityObj(main.ability.AbilityObj) Ref(main.entity.Ref) AnimPhase(main.system.graphics.AnimPhase) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) Attachment(main.entity.obj.Attachment) Unit(eidolons.entity.obj.unit.Unit) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Example 22 with Event

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

the class UnconsciousRule method fallUnconscious.

public static void fallUnconscious(Unit unit) {
    if (unit.getAI().isOutsideCombat()) {
        unit.getAI().isOutsideCombat();
    }
    unit.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_FALLEN_UNCONSCIOUS, unit.getRef()));
    DC_SoundMaster.playEffectSound(SOUNDS.DEATH, unit);
    DC_SoundMaster.playEffectSound(SOUNDS.FALL, unit);
    getUnconsciousEffect(unit).apply();
    unit.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_FALLS_UNCONSCIOUS, unit.getRef()));
    unit.getGame().getLogManager().newLogEntryNode(ENTRY_TYPE.UNCONSCIOUS, unit);
// double regen? what's with focus, stamina, essence, morale? ... some
// may be reset, others reduced, others regen
}
Also used : Event(main.game.logic.event.Event)

Example 23 with Event

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

the class UnconsciousRule method unitRecovers.

private static void unitRecovers(Unit unit) {
    // unit.removeBuff(BUFF_NAME);
    unit.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_RECOVERED_FROM_UNCONSCIOUSNESS, unit.getRef()));
    // remove buff pretty much
    getWakeUpEffect(unit).apply();
    unit.getGame().getLogManager().newLogEntryNode(ENTRY_TYPE.CONSCIOUS, unit);
// event
}
Also used : Event(main.game.logic.event.Event)

Example 24 with Event

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

the class AtbController method processTimeElapsed.

private void processTimeElapsed(Float time) {
    addTime(time);
    getManager().getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.TIME_ELAPSED, new Ref(Math.round(time * TIME_LOGIC_MODIFIER))));
    GuiEventManager.trigger(GuiEventType.TIME_PASSED, time);
    GuiEventManager.trigger(GuiEventType.NEW_ATB_TIME, this.time);
    if (this.time >= TIME_IN_ROUND) {
        addTime(-TIME_IN_ROUND);
        manager.getGame().getStateManager().newRound();
        newRound();
    }
    if (!isPrecalc())
        manager.getGame().getLogManager().log(getTimeString(time) + " passed, " + getTimeString(TIME_IN_ROUND - this.time) + " until end of round");
    for (AtbUnit unit : this.unitsInAtb) {
        unit.setAtbReadiness(unit.getAtbReadiness() + time * unit.getInitiative());
    }
    if (!isPrecalc())
        manager.getGame().getManager().atbTimeElapsed(time);
}
Also used : Ref(main.entity.Ref) Event(main.game.logic.event.Event)

Example 25 with Event

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

the class DC_StateManager method endTurn.

public void endTurn() {
    try {
        if (game.isStarted()) {
            applyEndOfTurnRules();
            applyEndOfTurnDamage();
        }
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    try {
        new Event(STANDARD_EVENT_TYPE.ROUND_ENDS, new Ref(getGame())).fire();
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
}
Also used : Ref(main.entity.Ref) Event(main.game.logic.event.Event)

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