Search in sources :

Example 1 with RotateByAction

use of com.badlogic.gdx.scenes.scene2d.actions.RotateByAction in project Eidolons by IDemiurge.

the class AttackAnim method getAction.

/*
delayAction
scale
size - elongate
 */
// TODO back?
@Override
protected Action getAction() {
    // if (sequence != null)  //reset sometimes?
    // return sequence;
    sequence = new SequenceAction();
    int i = 0;
    float totalDuration = 0;
    for (ATK_ANIMS anim : anims) {
        for (float angle : anim.targetAngles) {
            List<Pair<MoveByAction, RotateByAction>> swings = new ArrayList<>();
            float duration = this.duration;
            if (duration <= 0) {
                duration = 1;
            }
            // anim.durations[i];
            totalDuration += duration;
            float x = anim.offsetsX[i];
            float y = anim.offsetsY[i];
            MoveByAction mainMove = null;
            try {
                mainMove = getMoveAction(x, y, duration);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
            if (mainMove == null) {
                return null;
            }
            RotateByAction mainRotate = getRotateAction(angle, duration);
            swings.add(new ImmutablePair<>(mainMove, mainRotate));
            swings.forEach(swing -> {
                sequence.addAction(new ParallelAction(swing.getKey(), swing.getValue()));
            });
            i++;
        }
    }
    setDuration(totalDuration);
    return sequence;
}
Also used : ParallelAction(com.badlogic.gdx.scenes.scene2d.actions.ParallelAction) RotateByAction(com.badlogic.gdx.scenes.scene2d.actions.RotateByAction) ArrayList(java.util.ArrayList) MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 2 with RotateByAction

use of com.badlogic.gdx.scenes.scene2d.actions.RotateByAction in project Eidolons by IDemiurge.

the class AttackAnim method getRotateAction.

protected RotateByAction getRotateAction(float angle, float duration) {
    RotateByAction mainRotate = new RotateByAction();
    // angle += targetAngleOffset;
    FACING_DIRECTION facing = getFacing();
    // add default offset
    boolean offhand = getActive().isOffhand();
    Boolean left = PositionMaster.isToTheLeftOr(getOriginCoordinates(), getDestinationCoordinates());
    Boolean above = PositionMaster.isAboveOr(getOriginCoordinates(), getDestinationCoordinates());
    Boolean add = null;
    if (facing.isVertical()) {
        add = above;
    } else {
        add = left;
    }
    FACING_SINGLE relativeFacing = FacingMaster.getSingleFacing(facing, getOriginCoordinates(), getDestinationCoordinates());
    // increase angle?
    int addAngle = 0;
    switch(relativeFacing) {
        case IN_FRONT:
            break;
        case BEHIND:
            break;
        case TO_THE_SIDE:
            if (getActive().isOffhand()) {
                if (left) {
                    break;
                }
            }
        case NONE:
            // TODO on the same cell?
            break;
    }
    angle += addAngle;
    // pixel collision for impact!
    mainRotate.setDuration(duration);
    mainRotate.setAmount(angle);
    return mainRotate;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) RotateByAction(com.badlogic.gdx.scenes.scene2d.actions.RotateByAction) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Aggregations

RotateByAction (com.badlogic.gdx.scenes.scene2d.actions.RotateByAction)2 MoveByAction (com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)1 ParallelAction (com.badlogic.gdx.scenes.scene2d.actions.ParallelAction)1 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)1 ArrayList (java.util.ArrayList)1 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)1 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Pair (org.apache.commons.lang3.tuple.Pair)1