Search in sources :

Example 1 with DC_HeroSlotItem

use of eidolons.entity.item.DC_HeroSlotItem in project Eidolons by IDemiurge.

the class FacingCondition method check.

@Override
public boolean check(Ref ref) {
    if (!(ref.getSourceObj() instanceof DC_UnitModel)) {
        return false;
    }
    BattleFieldObject obj1 = (BattleFieldObject) ref.getSourceObj();
    DC_Obj obj2;
    if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
        if (!(ref.getObj(KEYS.MATCH) instanceof DC_HeroSlotItem)) {
            return false;
        }
        obj2 = ((DC_HeroAttachedObj) ref.getObj(KEYS.MATCH)).getOwnerObj();
    } else {
        obj2 = (DC_Obj) ref.getObj(KEYS.MATCH);
    }
    boolean result = false;
    if (getTemplate() != null) {
        Coordinates c = obj2.getCoordinates();
        if (obj2.isOverlaying())
            if (obj2 instanceof BattleFieldObject) {
                DIRECTION d = ((BattleFieldObject) obj2).getDirection();
                if (d != null) {
                    c = c.getAdjacentCoordinate(d.rotate180(), 2);
                }
            // the coordinate to which unit must be facing in order to face the overlaying obj on the other side
            }
        if (obj1 == null)
            return false;
        if (c == null)
            return false;
        FACING_SINGLE facing = FacingMaster.getSingleFacing(obj1.getFacing(), obj1.getCoordinates(), c);
        result = Arrays.asList(templates).contains(facing);
        if (facing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
            if (result) {
                if (left_right == null) {
                    left_right = obj1.checkBool(GenericEnums.STD_BOOLS.LEFT_RIGHT_REACH);
                }
                if (left_right) {
                    int degrees = obj1.getFacing().getDirection().getDegrees();
                    int degrees2 = DirectionMaster.getRelativeDirection(obj1, obj2).getDegrees();
                    boolean left = degrees > degrees2;
                    if (left) {
                        return left_right;
                    }
                    return !left_right;
                }
            }
        }
    }
    return result;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) BfObj(main.entity.obj.BfObj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 2 with DC_HeroSlotItem

use of eidolons.entity.item.DC_HeroSlotItem in project Eidolons by IDemiurge.

the class ActionAnimation method drawReduction.

protected boolean drawReduction(boolean shield) {
    int percentage = (int) phase.getArgs()[0];
    int blocked = (int) phase.getArgs()[1];
    int durability = (int) phase.getArgs()[2];
    int amount = (int) phase.getArgs()[3];
    DAMAGE_TYPE dmg_type = (DAMAGE_TYPE) phase.getArgs()[4];
    DC_HeroSlotItem armor = (DC_HeroSlotItem) phase.getArgs()[5];
    // calculate centered
    int y = 4;
    Image image = armor.getIcon().getImage();
    int x = (w - image.getWidth(null)) / 2;
    drawOnTarget(image, x, y);
    Font font = getFontNeutral();
    y += 5 + image.getHeight(null);
    image = ImageManager.getDamageTypeImage(dmg_type.getName());
    drawOnTarget(image, 0, y - (image.getHeight(null) - FontMaster.getFontHeight(font)) / 2);
    String string = StringMaster.wrapInBraces(blocked + "") + " blocked " + StringMaster.wrapInParenthesis(ArmorMaster.getArmorValue(armor, dmg_type) + " max.");
    x = (w - FontMaster.getStringWidth(font, string)) / 2;
    y += drawTextOnTarget(string, font, x, y) - 6;
    string = StringMaster.wrapInParenthesis(percentage + "%" + ((shield) ? " chance" : " of attack"));
    x = (w - FontMaster.getStringWidth(font, string)) / 2;
    y += drawTextOnTarget(string, font, x, y) - 6;
    // Shield/armor  chance, numbers, dmg type, durability
    if (durability <= 0) {
        return true;
    }
    font = getFontNegative();
    string = StringMaster.wrapInBraces(durability + "") + " durability lost";
    x = (w - FontMaster.getStringWidth(font, string)) / 2;
    drawTextOnTarget(string, font, x, y, ColorManager.CRIMSON);
    // update initial amount/dmg_type?
    return true;
}
Also used : DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem)

Example 3 with DC_HeroSlotItem

use of eidolons.entity.item.DC_HeroSlotItem in project Eidolons by IDemiurge.

the class HeroManager method update.

public void update(Unit hero, boolean refresh) {
    // hero.setItemsInitialized(false);
    if (hero == null) {
        return;
    }
    for (DC_HeroSlotItem item : hero.getSlotItems()) {
        if (item != null) {
            if (item.getAttachments() != null) {
                item.getAttachments().clear();
                for (BuffObj buff : item.getBuffs()) {
                    buff.kill();
                }
            }
        }
    }
    hero.toBase();
    if (game.isSimulation()) {
        List<Attachment> attachments = hero.getAttachments();
        List<Effect> secondLayerEffects = new ArrayList<>();
        if (attachments != null) {
            for (Attachment a : attachments) {
                try {
                    for (Effect e : a.getEffects()) {
                        if (e.getLayer() != Effect.SECOND_LAYER) {
                            e.apply(Ref.getSelfTargetingRefCopy(hero));
                        } else {
                            secondLayerEffects.add(e);
                        }
                    }
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        for (Effect e : secondLayerEffects) {
            e.apply(Ref.getSelfTargetingRefCopy(hero));
        }
        EffectFinder.applyAttachmentEffects(hero.getMainWeapon(), null);
        EffectFinder.applyAttachmentEffects(hero.getOffhandWeapon(), null);
        EffectFinder.applyAttachmentEffects(hero.getArmor(), null);
    }
    hero.afterEffects();
    hero.setDirty(true);
    if (!hero.getGame().isSimulation()) {
        try {
            hero.resetObjects();
            hero.resetQuickSlotsNumber();
            refreshInvWindow();
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
        return;
    }
    if (refresh) {
        refresh(hero);
    }
}
Also used : Attachment(main.entity.obj.Attachment) Effect(main.ability.effects.Effect) BuffObj(main.entity.obj.BuffObj) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem)

Aggregations

DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)3 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)1 Effect (main.ability.effects.Effect)1 DAMAGE_TYPE (main.content.enums.GenericEnums.DAMAGE_TYPE)1 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)1 Attachment (main.entity.obj.Attachment)1 BfObj (main.entity.obj.BfObj)1 BuffObj (main.entity.obj.BuffObj)1 Coordinates (main.game.bf.Coordinates)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1