Search in sources :

Example 51 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class HitAnim method resetSprites.

@Override
protected void resetSprites() {
    sprites.clear();
    spriteType = getSpriteType((BattleFieldObject) getRef().getTargetObj());
    hitType = getHitType(getActive(), spriteType);
    String spritePath = StrPathBuilder.build(getHitSpritesPath(), spriteType.name(), hitType.spritePath) + ".txt";
    // + ".png";
    // SpriteAnimation sprite = SpriteAnimationFactory.getSpriteAnimation(spritePath);
    // scale?
    SmartTextureAtlas atlas = SmartTextureAtlas.getAtlas(PathFinder.getImagePath() + spritePath);
    if (atlas == null)
        return;
    Array<AtlasRegion> regions = atlas.getRegions();
    SpriteAnimation sprite = SpriteAnimationFactory.getSpriteAnimation(regions, getDuration() / regions.size, 1);
    if (getRef().getTargetObj() instanceof Unit)
        sprite.setColor(getColorForSprite((Unit) getRef().getTargetObj()));
    sprites.add(sprite);
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) SmartTextureAtlas(eidolons.libgdx.texture.SmartTextureAtlas) SpriteAnimation(eidolons.libgdx.anims.sprite.SpriteAnimation) AtlasRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion) Unit(eidolons.entity.obj.unit.Unit)

Example 52 with Unit

use of eidolons.entity.obj.unit.Unit 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 53 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class VisibilityCondition method check.

@Override
public boolean check(Ref ref) {
    if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
        return false;
    }
    DC_Obj match = (DC_Obj) ref.getObj(KEYS.MATCH);
    boolean result = false;
    if (this.match == null && this.source == null) {
        if (p_vision != null) {
            PLAYER_VISION playerVision = match.getActivePlayerVisionStatus();
            if (game.getManager().getActiveObj().isMine() != ref.getSourceObj().isMine()) {
                if (ref.getSourceObj().isMine()) {
                    playerVision = match.getPlayerVisionStatus(false);
                } else {
                // TODO for enemy unit on player's unit...
                }
            }
            if (playerVision == p_vision) {
                return true;
            }
        }
        UNIT_VISION visionStatus = match.getUnitVisionStatus();
        if (!ref.getSourceObj().isActiveSelected()) {
            visionStatus = match.getGame().getVisionMaster().getSightMaster().getUnitVisibilityStatus(match, (Unit) ref.getSourceObj());
        }
        return visionStatus.isSufficient(u_vision);
    }
    if (p_vision != null) {
        Unit unit = (Unit) ref.getObj(source);
        result = unit.getActivePlayerVisionStatus() == p_vision;
    } else if (u_vision != null) {
        match = (DC_Obj) ref.getObj(this.match);
        // if (((DC_Game) game).getManager().isAI_Turn()) { what's the idea?
        Unit activeObj = (Unit) ref.getObj(source);
        result = ((DC_Game) game).getVisionMaster().getUnitVisibilityStatus(match, activeObj).isSufficient(u_vision);
    // }
    }
    return result;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) PLAYER_VISION(main.content.enums.rules.VisionEnums.PLAYER_VISION) UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION) BfObj(main.entity.obj.BfObj) DC_Game(eidolons.game.core.game.DC_Game) Unit(eidolons.entity.obj.unit.Unit)

Example 54 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class ClassTreeCondition method check.

@Override
public boolean check(Ref ref) {
    ObjType type = DataManager.getType(className, DC_TYPE.CLASSES);
    if (type == null) {
        return true;
    }
    Unit hero = (Unit) ref.getSourceObj();
    for (DC_FeatObj c : hero.getClasses()) {
        if (c.getType().equals(type)) {
            return true;
        }
        if (c.getProperty(G_PROPS.CLASS_GROUP).equalsIgnoreCase(type.getProperty(G_PROPS.CLASS_GROUP))) {
            if (c.getIntParam(PARAMS.CIRCLE) >= type.getIntParam(PARAMS.CIRCLE)) {
                return false;
            }
        }
    }
    return true;
}
Also used : DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) ObjType(main.entity.type.ObjType) Unit(eidolons.entity.obj.unit.Unit)

Example 55 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class ItemCondition method check.

@Override
public boolean check(Ref ref) {
    if (ref.getGame().isSimulation()) {
        return true;
    }
    if (slot == null) {
        slot = (weapon) ? ItemEnums.ITEM_SLOT.MAIN_HAND.toString() : ItemEnums.ITEM_SLOT.ARMOR.toString();
    }
    Entity item;
    Unit unit = (Unit) ref.getObj(obj_ref);
    if (unit == null) {
        return false;
    }
    if (slot.equalsIgnoreCase(KEYS.RANGED.toString())) {
        item = unit.getRef().getObj(KEYS.RANGED);
    } else {
        if (slot.equalsIgnoreCase("weapon"))
            item = unit.getItem(!ref.getActive().isOffhand() ? ITEM_SLOT.MAIN_HAND : ITEM_SLOT.OFF_HAND);
        else
            item = unit.getItem(new EnumMaster<ITEM_SLOT>().retrieveEnumConst(ITEM_SLOT.class, slot, true));
    }
    if (item == null) {
        return false;
    }
    if (// any item in the slot
    prop == null) {
        return true;
    }
    String string = item.getProp(prop);
    return new StringComparison(string, val, strict).preCheck(ref);
// String prop2 = ref.getObj(obj_string).getProp(slot);
// if (StringMaster.isEmpty(prop2)) {
// try {
// prop2 = "" + ref.getObj(obj_string).getRef().getObj(slot).getId();
// } catch (Exception e) {
// return false;
// }
// }
// item = DataManager.getType(prop2, C_OBJ_TYPE.ITEMS);
// return StringMaster.compare(string, val, true);
}
Also used : Entity(main.entity.Entity) ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) StringComparison(main.elements.conditions.StringComparison) EnumMaster(main.system.auxiliary.EnumMaster) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)258 Coordinates (main.game.bf.Coordinates)53 Ref (main.entity.Ref)33 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)30 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)26 DC_Obj (eidolons.entity.obj.DC_Obj)26 ArrayList (java.util.ArrayList)26 Obj (main.entity.obj.Obj)26 ObjType (main.entity.type.ObjType)23 DC_SpellObj (eidolons.entity.active.DC_SpellObj)13 DC_Cell (eidolons.entity.obj.DC_Cell)11 Event (main.game.logic.event.Event)11 DC_UnitAction (eidolons.entity.active.DC_UnitAction)10 List (java.util.List)10 DC_Game (eidolons.game.core.game.DC_Game)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 DequeImpl (main.system.datatypes.DequeImpl)8 OUTLINE_TYPE (main.content.enums.rules.VisionEnums.OUTLINE_TYPE)7 Entity (main.entity.Entity)7 DIRECTION (main.game.bf.Coordinates.DIRECTION)7