Arrow and fire projectile dispose animation - UQdeco2800/2021-studio-2 GitHub Wiki

Overview

The weapon breakage animation is trigger while the weapon dispose task is called so that the weapon is wait before dispose

Code

    public void waitForDeathAnimation() {
        if (this.declareEnd) {
            this.start = System.currentTimeMillis();
            owner.getEntity().getComponent(HitboxComponent.class).dispose();
            this.declareEnd = false;
        } else {
            owner.getEntity().getComponent(PhysicsMovementComponent.class).setMoving(false);
            if ((System.currentTimeMillis() - start) / 1000 >= duration) {
                stop();
                owner.getEntity().prepareDispose();
                status = Status.FINISHED;
            }
        }
    }

This code is called so that the weapon (arrow) is wait for the animation is finished running

The animation is trigger if the weapon have contact with any object

    public void broken() {
        if (!entity.getEntityType().equals("fireBall")) {
            animator.startAnimation("brokenArrow");
        } else {
            animator.startAnimation("hit");
        }
    }

The broken method is called to start the animation if the weapon is on collision