Skip to content

Commit

Permalink
Merge branch 'Team-1--Projectiles' of https://github.com/UQcsse3200/2…
Browse files Browse the repository at this point in the history
…023-studio-3 into collision-components-test
  • Loading branch information
freshc0w committed Sep 11, 2023
2 parents 14ce258 + 2379fd7 commit 4f6934a
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 4 deletions.
42 changes: 42 additions & 0 deletions source/core/assets/images/projectiles/pierce_anim.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

pierce_anim.png
size: 256, 32
format: RGBA8888
filter: Nearest, Nearest
repeat: none
projectile
rotate: false
xy: 2, 2
size: 35, 26
orig: 35, 26
offset: 0, 0
index: -1
projectile
rotate: false
xy: 76, 2
size: 35, 26
orig: 35, 26
offset: 0, 0
index: -1
projectile
rotate: false
xy: 39, 2
size: 35, 26
orig: 35, 26
offset: 0, 0
index: -1
projectile
rotate: false
xy: 113, 2
size: 35, 26
orig: 35, 26
offset: 0, 0
index: -1
default
projectile
rotate: false
xy: 2, 2
size: 35, 26
orig: 35, 26
offset: 0, 0
index: -1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public class ForestGameArea extends GameArea {
"images/projectiles/snow_ball.png",
"images/projectiles/burn_effect.png",
"images/projectiles/stun_effect.png",
"images/projectiles/firework_anim.png"
"images/projectiles/firework_anim.png",
"images/projectiles/pierce_anim.png"


};
Expand Down Expand Up @@ -145,7 +146,8 @@ public class ForestGameArea extends GameArea {
"images/projectiles/snow_ball.atlas",
"images/projectiles/burn_effect.atlas",
"images/projectiles/stun_effect.atlas",
"images/projectiles/firework_anim.atlas"
"images/projectiles/firework_anim.atlas",
"images/projectiles/pierce_anim.atlas"

};
private static final String[] forestSounds = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.csse3200.game.components.projectile;

import com.csse3200.game.components.Component;
import com.csse3200.game.rendering.AnimationRenderComponent;

public class PierceProjectileAnimationController extends Component {
/** Event name constants */
private static final String START = "startProjectile";
/** Animation name constants */
private static final String START_ANIM = "projectile";
AnimationRenderComponent animator;


@Override
public void create() {
super.create();
animator = this.entity.getComponent(AnimationRenderComponent.class);
entity.getEvents().addListener(START, this::animateStart);

}

void animateStart() {
animator.startAnimation(START_ANIM);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static Entity createEffectProjectile(short targetLayer, Vector2 destinati
* Pierce fireball is basically a fireball that does damage but won't self destruct on hit.
*/
public static Entity createPierceFireBall(short targetLayer, Vector2 destination, Vector2 speed) {
Entity fireBall = createFireBall(targetLayer, destination, speed);
Entity fireBall = createPierceBallAnim(targetLayer, destination, speed);
fireBall.getComponent(TouchAttackComponent.class).setDisposeOnHit(false);
fireBall.getComponent(TouchAttackComponent.class).setKnockBack(0f);

Expand Down Expand Up @@ -169,14 +169,22 @@ public static Entity createFireBall(short targetLayer, Vector2 destination, Vect

projectile
.addComponent(animator)
.addComponent(new ProjectileAnimationController());
.addComponent(new PierceProjectileAnimationController());
// * TEMPORARY
// .addComponent(new DeleteOnMapEdgeComponent());
// .addComponent(new SelfDestructOnHitComponent(PhysicsLayer.OBSTACLE));

return projectile;
}

/**
* Creates new animation and fireballs for SplitFireworkComponent.
*
* @param targetLayer The enemy layer that the projectile collides with.
* @param destination The destination the projectile heads towards.
* @param speed The speed of the projectile.
* @return Returns a new fireball projectile entity.
*/
public static Entity createFireworks(short targetLayer, Vector2 destination, Vector2 speed) {
Entity projectile = createBaseProjectile(targetLayer, destination, speed);

Expand All @@ -192,6 +200,21 @@ public static Entity createFireworks(short targetLayer, Vector2 destination, Vec
return projectile;
}

public static Entity createPierceBallAnim(short targetLayer, Vector2 destination, Vector2 speed) {
Entity projectile = createBaseProjectile(targetLayer, destination, speed);

AnimationRenderComponent animator =
new AnimationRenderComponent(
ServiceLocator.getResourceService()
.getAsset("images/projectiles/pierce_anim.atlas", TextureAtlas.class));
animator.addAnimation(START_ANIM, 0.05f, Animation.PlayMode.LOOP);
projectile
.addComponent(animator)
.addComponent(new FireworkAnimationController());

return projectile;
}


/**
* Creates a engineer bullet
Expand Down

0 comments on commit 4f6934a

Please sign in to comment.