Search in sources :

Example 26 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject 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 27 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class ObjCreator method createUnit.

public MicroObj createUnit(ObjType type, int x, int y, Player owner, Ref ref) {
    if (!CoreEngine.isArcaneVault()) {
        if (!CoreEngine.isLevelEditor()) {
            if (!type.isGenerated()) {
                type = new ObjType(type);
                game.initType(type);
            }
        }
    }
    if (!CoreEngine.isLevelEditor())
        if (!CoreEngine.isArcaneVault())
            type = checkTypeSubstitution(type, ref);
    BattleFieldObject obj = null;
    if (type.checkProperty(G_PROPS.BF_OBJECT_GROUP, BfObjEnums.BF_OBJECT_GROUP.ENTRANCE.toString())) {
        // TODO      obj = new Entrance(x, y, type, getGame().getDungeon(), null);
        return null;
    } else if (type.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ) {
        obj = newStructure(type, x, y, owner, ref);
    } else {
        obj = new Unit(type, x, y, owner, getGame(), ref);
    }
    if (CoreEngine.isLevelEditor()) {
        return obj;
    }
    // if (WaitMaster.getCompleteOperations().contains(WAIT_OPERATIONS.DUNGEON_SCREEN_READY))
    GuiEventManager.trigger(GuiEventType.UNIT_CREATED, obj);
    game.getState().addObject(obj);
    if (obj instanceof Unit)
        game.getState().getManager().reset((Unit) obj);
    else {
        obj.toBase();
        obj.resetObjects();
        obj.afterEffects();
    }
    return obj;
}
Also used : ObjType(main.entity.type.ObjType) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Unit(eidolons.entity.obj.unit.Unit)

Example 28 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class DC_Game method createUnit.

@Override
public MicroObj createUnit(ObjType type, int x, int y, Player owner, Ref ref) {
    BattleFieldObject unit = ((BattleFieldObject) super.createUnit(type, x, y, owner, ref.getCopy()));
    game.getState().addObject(unit);
    unit.toBase();
    unit.resetObjects();
    unit.afterEffects();
    return unit;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject)

Example 29 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class DC_GameManager method resetValues.

// a single-method spell, Warp Time: take another turn...
public void resetValues(Player owner) {
    for (Obj obj : getGame().getBfObjects()) {
        BattleFieldObject unit = null;
        if (obj instanceof BattleFieldObject) {
            unit = (BattleFieldObject) obj;
            if (owner == null || unit.getOwner() == owner) {
                unit.newRound();
            }
        }
        unit.regen();
    }
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) MicroObj(main.entity.obj.MicroObj) ActiveObj(main.entity.obj.ActiveObj) BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) PassiveAbilityObj(main.ability.PassiveAbilityObj)

Example 30 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class DC_GameMaster method getObjectsOnCoordinate.

public List<BattleFieldObject> getObjectsOnCoordinate(Integer z, Coordinates c, Boolean overlayingIncluded, boolean passableIncluded, boolean cellsIncluded) {
    // TODO auto adding cells won't work!
    if (c == null) {
        return null;
    }
    if (z == null) {
        z = getGame().getDungeon().getZ();
    }
    List<BattleFieldObject> list = null;
    if (// TODO support multi-z?
    z == 0)
        if (getCache(overlayingIncluded) != null)
            list = getCache(overlayingIncluded).get(c);
    if (list != null) {
        return list;
    }
    list = new XList<>();
    for (BattleFieldObject object : getGame().getBfObjects()) {
        if (overlayingIncluded != null) {
            if (overlayingIncluded) {
                if (!object.isOverlaying()) {
                    continue;
                }
            } else {
                if (object.isOverlaying()) {
                    continue;
                }
            }
        }
        if (object.getZ() != z) {
            continue;
        }
        if (object.getCoordinates().equals(c)) {
            list.add(object);
        }
    }
    // if (overlayingIncluded == null)
    if (z == 0)
        if (getCache(overlayingIncluded) != null) {
            getCache(overlayingIncluded).put(c, list);
        }
    return list;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject)

Aggregations

BattleFieldObject (eidolons.entity.obj.BattleFieldObject)52 Unit (eidolons.entity.obj.unit.Unit)24 Coordinates (main.game.bf.Coordinates)22 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)12 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 Obj (main.entity.obj.Obj)9 DequeImpl (main.system.datatypes.DequeImpl)8 Event (main.game.logic.event.Event)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 DIRECTION (main.game.bf.Coordinates.DIRECTION)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Vector2 (com.badlogic.gdx.math.Vector2)4 Align (com.badlogic.gdx.utils.Align)4 Eidolons (eidolons.game.core.Eidolons)4 Gdx (com.badlogic.gdx.Gdx)3 Keys (com.badlogic.gdx.Input.Keys)3 Batch (com.badlogic.gdx.graphics.g2d.Batch)3 Group (com.badlogic.gdx.scenes.scene2d.Group)3