Skip to content

Commit

Permalink
Created new controller and atlas for demon animation
Browse files Browse the repository at this point in the history
  • Loading branch information
gregchan550 committed Sep 17, 2023
1 parent a8f2a49 commit 15e116e
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 13 deletions.
186 changes: 186 additions & 0 deletions source/core/assets/images/mobboss/demon.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
demon.png
size:2048,2048
repeat:none
demon_cleave
index:6
bounds:2,1622,288,160
demon_cleave
index:11
bounds:582,1784,288,160
demon_cleave
index:3
bounds:872,1784,288,160
demon_cleave
index:8
bounds:1162,1784,288,160
demon_cleave
index:13
bounds:582,1298,288,160
demon_cleave
index:5
bounds:582,1136,288,160
demon_cleave
index:10
bounds:1452,1622,288,160
demon_cleave
index:15
bounds:872,1136,288,160
demon_cleave
index:2
bounds:1162,1298,288,160
demon_cleave
index:7
bounds:292,650,288,160
demon_cleave
index:12
bounds:1162,1136,288,160
demon_cleave
index:4
bounds:872,812,288,160
demon_cleave
index:9
bounds:292,326,288,160
demon_cleave
index:14
bounds:1162,812,288,160
demon_cleave
index:1
bounds:1742,1136,288,160
demon_death
index:11
bounds:292,1784,288,160
demon_death
index:4
bounds:292,1622,288,160
demon_death
index:16
bounds:292,1460,288,160
demon_death
index:9
bounds:582,1622,288,160
demon_death
index:1
bounds:2,1136,288,160
demon_death
index:21
bounds:292,1298,288,160
demon_death
index:22
bounds:292,1298,288,160
demon_death
index:13
bounds:2,974,288,160
demon_death
index:6
bounds:292,1136,288,160
demon_death
index:18
bounds:2,812,288,160
demon_death
index:10
bounds:872,1298,288,160
demon_death
index:3
bounds:1162,1460,288,160
demon_death
index:15
bounds:292,812,288,160
demon_death
index:8
bounds:582,974,288,160
demon_death
index:20
bounds:1742,1622,288,160
demon_death
index:12
bounds:582,812,288,160
demon_death
index:5
bounds:872,974,288,160
demon_death
index:17
bounds:582,650,288,160
demon_death
index:2
bounds:1162,974,288,160
demon_death
index:14
bounds:582,488,288,160
demon_death
index:7
bounds:872,650,288,160
demon_death
index:19
bounds:582,326,288,160
demon_idle
index:3
bounds:2,1298,288,160
demon_idle
index:5
bounds:872,1460,288,160
demon_idle
index:2
bounds:1742,1784,288,160
demon_idle
index:4
bounds:1452,1298,288,160
demon_idle
index:1
bounds:1452,1136,288,160
demon_idle
index:6
bounds:1452,974,288,160
demon_take_hit
index:2
bounds:2,1784,288,160
demon_take_hit
index:4
bounds:872,1622,288,160
demon_take_hit
index:1
bounds:292,974,288,160
demon_take_hit
index:3
bounds:2,488,288,160
demon_take_hit
index:5
bounds:2,164,288,160
demon_walk
index:8
bounds:2,1460,288,160
demon_walk
index:5
bounds:582,1460,288,160
demon_walk
index:11
bounds:1162,1622,288,160
demon_walk
index:2
bounds:1452,1784,288,160
demon_walk
index:7
bounds:2,650,288,160
demon_walk
index:4
bounds:1452,1460,288,160
demon_walk
index:9
bounds:1742,1460,288,160
demon_walk
index:10
bounds:2,326,288,160
demon_walk
index:1
bounds:292,488,288,160
demon_walk
index:6
bounds:1742,1298,288,160
demon_walk
index:12
bounds:2,2,288,160
demon_walk
index:3
bounds:292,164,288,160
default
index:1
bounds:1452,1136,288,160
Binary file added source/core/assets/images/mobboss/demon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public class ForestGameArea extends GameArea {
"images/projectiles/stun_effect.png",
"images/projectiles/firework_anim.png",
"images/projectiles/pierce_anim.png",
"images/projectiles/snow_ball.png"
"images/projectiles/snow_ball.png",
"images/mobboss/demon.png"
};
private static final String[] forestTextureAtlases = {
"images/economy/econ-tower.atlas",
Expand Down Expand Up @@ -136,7 +137,8 @@ public class ForestGameArea extends GameArea {
"images/projectiles/burn_effect.atlas",
"images/projectiles/firework_anim.atlas",
"images/projectiles/mobProjectile.atlas",
"images/projectiles/stun_effect.atlas"
"images/projectiles/stun_effect.atlas",
"images/mobboss/demon.atlas"
};
private static final String[] forestSounds = {
"sounds/Impact4.ogg",
Expand Down Expand Up @@ -240,6 +242,9 @@ public void create() {
spawnEffectProjectile(new Vector2(2, 6), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.SLOW, false);
spawnXenoGrunts();
spawnWeaponTower();

spawnDemonBoss();

//mobBoss1 = spawnMobBoss1();
startWaveTimer();
// spawnIncome();
Expand Down Expand Up @@ -384,6 +389,10 @@ private Entity spawnPlayer(GridPoint2 position) {
// return ghostKing;
// }

private void spawnDemonBoss() {
Entity demon = MobBossFactory.createDemonBoss();
spawnEntityAt(demon, new GridPoint2(19, 4), true, false);
}

private Entity spawnMobBoss1() {
int[] pickedLanes = new Random().ints(0, 8)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.csse3200.game.components.bosses;

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

public class DemonAnimationController extends Component {
AnimationRenderComponent animator;

/**
* Creation call for a TowerAnimationController, fetches the animationRenderComponent that this controller will
* be attached to and registers all the event listeners required to trigger the animations and sounds.
*/
@Override
public void create() {
super.create();
animator = this.entity.getComponent(AnimationRenderComponent.class);
entity.getEvents().addListener("demon_walk", this::animateStart);
}

void animateStart() {
animator.startAnimation("demon_walk");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.TimeUtils;
import com.badlogic.gdx.utils.Timer;
import com.csse3200.game.ai.tasks.AITaskComponent;
import com.csse3200.game.ai.tasks.DefaultTask;
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.components.tasks.MovementTask;
Expand All @@ -14,9 +12,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DemonBossMovementTask extends DefaultTask implements PriorityTask {
public class DemonBossTask extends DefaultTask implements PriorityTask {

private static final Logger logger = LoggerFactory.getLogger(DemonBossMovementTask.class);
private static final Logger logger = LoggerFactory.getLogger(DemonBossTask.class);
private static final int PRIORITY = 3;
private Vector2 currentPos;
private MovementTask movementTask;
Expand All @@ -31,23 +29,21 @@ private enum STATE {
}
private STATE demonState = STATE.IDLE;

public DemonBossMovementTask() {
public DemonBossTask() {
physics = ServiceLocator.getPhysicsService().getPhysics();
}

@Override
public void start() {
super.start();
this.currentPos = owner.getEntity().getPosition();
System.out.println(currentPos);
jump(getJumpPos());
System.out.println("DEMON: " + owner.getEntity().getPosition());
}

@Override
public void update() {
this.currentPos = owner.getEntity().getPosition();
if (currentPos == jumpPos) {
if (currentPos.equals(jumpPos)) {
logger.debug("Demon jump completed");
}
}
Expand All @@ -58,6 +54,8 @@ public int getPriority() {
}

private void jump(Vector2 finalPos) {
// Start animation
owner.getEntity().getEvents().trigger("demon_walk");
MovementTask jump = new MovementTask(finalPos);
jump.create(owner);
owner.getEntity().getComponent(PhysicsMovementComponent.class).setSpeed(DEMON_JUMP_SPEED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.csse3200.game.ai.tasks.AITaskComponent;
import com.csse3200.game.components.*;
import com.csse3200.game.components.bosses.DemonAnimationController;
import com.csse3200.game.components.npc.Boss1AnimationController;
import com.csse3200.game.components.npc.Boss2AnimationController;
import com.csse3200.game.components.tasks.bosstask.DemonBossMovementTask;
import com.csse3200.game.components.tasks.bosstask.DemonBossTask;
import com.csse3200.game.components.tasks.bosstask.FinalBossMovementTask;
import com.csse3200.game.components.tasks.bosstask.RangeBossTask;
import com.csse3200.game.components.tasks.bosstask.bossDeathTask;
Expand All @@ -25,20 +26,36 @@ public class MobBossFactory {
private static final NPCConfigs configs = FileLoader.readClass(NPCConfigs.class, "configs/Boss.json");
private static final int PRIORITY = 1;
private static final int BOSS_MOB_AGRO_RANGE = 10;
private static final int DEMON_HEALTH = 10000;
private static final int DEMON_ATTACK = 50;

// Create Demon Boss
private static Entity createDemonBoss() {
public static Entity createDemonBoss() {
MobBossConfigs config = configs.MobBoss;
Entity demon = createBaseBoss();

// Animation addition
AnimationRenderComponent animator1 = new AnimationRenderComponent(
ServiceLocator.getResourceService().getAsset("images/mobboss/demon.atlas", TextureAtlas.class));
animator1.addAnimation("demon_walk", 0.3f, Animation.PlayMode.LOOP);

// AI task addition
AITaskComponent aiTaskComponent = new AITaskComponent()
.addTask(new DemonBossMovementTask());
.addTask(new DemonBossTask());

// Component addition
demon
.addComponent(animator1)
.addComponent(new DemonAnimationController())
.addComponent(aiTaskComponent)
.addComponent(new CombatStatsComponent(DEMON_HEALTH, DEMON_ATTACK));

// Scale demon
demon.getComponent(AnimationRenderComponent.class).scaleEntity();
demon.scaleHeight(3f);
demon.scaleWidth(3f);

System.out.println("Demon Created\n");
return demon;
}

Expand Down

0 comments on commit 15e116e

Please sign in to comment.