From 3f5b64485dd2eed89d7fc3a52dac69ad4d1231ca Mon Sep 17 00:00:00 2001 From: MiniSoda17 Date: Sat, 9 Sep 2023 16:21:46 +1000 Subject: [PATCH] Added new Engineer Bullets for Engineers to shoot --- .../projectiles/engineer_projectile.atlas | 26 +++++++------------ .../csse3200/game/areas/ForestGameArea.java | 7 ++--- ... EngineerBulletsAnimationControlller.java} | 6 ++--- .../tasks/human/EngineerCombatTask.java | 3 ++- .../entities/factories/ProjectileFactory.java | 5 ++-- 5 files changed, 22 insertions(+), 25 deletions(-) rename source/core/src/main/com/csse3200/game/components/projectile/{EngineerBullets.java => EngineerBulletsAnimationControlller.java} (72%) diff --git a/source/core/assets/images/projectiles/engineer_projectile.atlas b/source/core/assets/images/projectiles/engineer_projectile.atlas index 47eb72f99..9790d718e 100644 --- a/source/core/assets/images/projectiles/engineer_projectile.atlas +++ b/source/core/assets/images/projectiles/engineer_projectile.atlas @@ -6,25 +6,11 @@ filter: Nearest, Nearest repeat: none bullet rotate: false - xy: 68, 2 + xy: 47, 2 size: 19, 19 orig: 19, 19 offset: 0, 0 index: -1 -bullet - rotate: false - xy: 25, 2 - size: 20, 19 - orig: 20, 19 - offset: 0, 0 - index: -1 -default - rotate: false - xy: 25, 2 - size: 20, 19 - orig: 20, 19 - offset: 0, 0 - index: -1 bullet rotate: false xy: 2, 2 @@ -34,8 +20,16 @@ bullet index: -1 bulletFinal rotate: false - xy: 47, 2 + xy: 68, 2 size: 19, 19 orig: 19, 19 offset: 0, 0 index: -1 +bullet + rotate: false + xy: 25, 2 + size: 20, 19 + orig: 20, 19 + offset: 0, 0 + index: -1 + diff --git a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java index 5666d6af0..a16d7d231 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -112,7 +112,7 @@ public class ForestGameArea extends GameArea { "images/towers/TNTTower.atlas", "images/projectiles/basic_projectile.atlas", "images/projectiles/mobProjectile.atlas", - "images/projectiles/engineer_bullets.atlas" + "images/projectiles/engineer_projectile.atlas" }; private static final String[] forestSounds = { "sounds/Impact4.ogg", @@ -162,7 +162,8 @@ public void create() { // Types of projectile spawnEffectProjectile(new Vector2(0, 10), PhysicsLayer.HUMANS, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.BURN, true); - spawnMobBall(new Vector2(15,10), PhysicsLayer.NPC, towardsTowers, new Vector2(2f, 2f)); + spawnMobBall(new Vector2(0, 8), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f)); + spawnXenoGrunts(); spawnGhosts(); @@ -300,7 +301,7 @@ private void spawnProjectile(Vector2 position, short targetLayer, int direction, * */ private void spawnMobBall(Vector2 position, short targetLayer, int direction, Vector2 speed) { - Entity Projectile = ProjectileFactory.createMobBall(targetLayer, new Vector2(direction, position.y), speed); + Entity Projectile = ProjectileFactory.createEngineerBullet(targetLayer, new Vector2(direction, position.y), speed); Projectile.setPosition(position); spawnEntity(Projectile); } diff --git a/source/core/src/main/com/csse3200/game/components/projectile/EngineerBullets.java b/source/core/src/main/com/csse3200/game/components/projectile/EngineerBulletsAnimationControlller.java similarity index 72% rename from source/core/src/main/com/csse3200/game/components/projectile/EngineerBullets.java rename to source/core/src/main/com/csse3200/game/components/projectile/EngineerBulletsAnimationControlller.java index 6b0a4d820..ad8d0fd57 100644 --- a/source/core/src/main/com/csse3200/game/components/projectile/EngineerBullets.java +++ b/source/core/src/main/com/csse3200/game/components/projectile/EngineerBulletsAnimationControlller.java @@ -4,7 +4,7 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; //used for sound -public class EngineerBullets extends Component{ +public class EngineerBulletsAnimationControlller extends Component{ /** Event name constants */ AnimationRenderComponent animator; @@ -13,8 +13,8 @@ public class EngineerBullets extends Component{ public void create() { super.create(); animator = this.entity.getComponent(AnimationRenderComponent.class); - entity.getEvents().addListener("start", this::animateStart); - entity.getEvents().addListener("final", this::animateFinal); + entity.getEvents().addListener("startProjectile", this::animateStart); + entity.getEvents().addListener("startProjectileFinal", this::animateFinal); } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index f26d84be0..23dbea9c0 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -134,7 +134,8 @@ public void updateEngineerState() { Entity newProjectile = ProjectileFactory.createEngineerBullet(PhysicsLayer.NPC, new Vector2(100, owner.getEntity().getPosition().y), new Vector2(4f, 4f)); - newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.75), (float) (owner.getEntity().getPosition().y + 0.4)); + newProjectile.setScale(0.8f, 0.8f); + newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.3), (float) (owner.getEntity().getPosition().y + 0.15)); ServiceLocator.getEntityService().register(newProjectile); shotsFired += 1; reloadTime = timeSource.getTime(); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java index 63482bd5f..a99cf2826 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java @@ -22,6 +22,7 @@ import com.csse3200.game.physics.components.PhysicsComponent; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.badlogic.gdx.math.Vector2; +import com.csse3200.game.components.projectile.EngineerBulletsAnimationControlller; import com.csse3200.game.components.projectile.MobProjectileAnimationController; import com.csse3200.game.components.projectile.ProjectileAnimationController; @@ -129,13 +130,13 @@ public static Entity createEngineerBullet(short targetLayer, Vector2 destination AnimationRenderComponent animator = new AnimationRenderComponent( ServiceLocator.getResourceService() - .getAsset(BASE_PROJECTILE_ATLAS, TextureAtlas.class)); + .getAsset("images/projectiles/engineer_projectile.atlas", TextureAtlas.class)); animator.addAnimation("bullet", START_SPEED, Animation.PlayMode.NORMAL); animator.addAnimation("bulletFinal", FINAL_SPEED, Animation.PlayMode.NORMAL); projectile .addComponent(animator) - .addComponent(new ProjectileAnimationController()); + .addComponent(new EngineerBulletsAnimationControlller()); // .addComponent(new SelfDestructOnHitComponent(PhysicsLayer.OBSTACLE)); return projectile;