Add sound and animation to enemy death
This commit is contained in:
BIN
animations/e6f067f1-eba0-4e62-99c3-2fd867e6f142.png
Normal file
BIN
animations/e6f067f1-eba0-4e62-99c3-2fd867e6f142.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 324 KiB |
BIN
audio/e452e215-f581-40fe-a5cf-f555d3db83b8.ogg
Normal file
BIN
audio/e452e215-f581-40fe-a5cf-f555d3db83b8.ogg
Normal file
Binary file not shown.
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@@ -9,5 +9,8 @@ $2261c04f-b02e-4486-b388-8a0fa41622e9(2261c04f-b02e-4486-b388-8a0fa41622e9.ttf
|
||||
$ab9d40b4-eb28-45d7-bff2-9432a05eb41a(ab9d40b4-eb28-45d7-bff2-9432a05eb41a.xml
|
||||
Start MenuB[
|
||||
$56ca6b39-f949-4212-9c23-312db25887e0(56ca6b39-f949-4212-9c23-312db25887e0.xml Game MenuJ[
|
||||
$61e67e44-a0cd-4210-8d1e-ccddcd62c78d(61e67e44-a0cd-4210-8d1e-ccddcd62c78d.pngSlash (R]
|
||||
$1311327d-4b74-4252-94da-23ee4129e357(1311327d-4b74-4252-94da-23ee4129e357.oggSword slash
|
||||
$61e67e44-a0cd-4210-8d1e-ccddcd62c78d(61e67e44-a0cd-4210-8d1e-ccddcd62c78d.pngSlash (JZ
|
||||
$e6f067f1-eba0-4e62-99c3-2fd867e6f142(e6f067f1-eba0-4e62-99c3-2fd867e6f142.pngPoof (R]
|
||||
$1311327d-4b74-4252-94da-23ee4129e357(1311327d-4b74-4252-94da-23ee4129e357.oggSword slashR\
|
||||
$e452e215-f581-40fe-a5cf-f555d3db83b8(e452e215-f581-40fe-a5cf-f555d3db83b8.ogg
|
||||
Deku death
|
||||
@@ -25,6 +25,8 @@ public class EnemyDAO {
|
||||
.animationSpeed(result.getFloat("animation_speed"))
|
||||
.blocking(result.getBoolean("blocking"))
|
||||
.meleeWeapon(result.getString("melee_weapon"))
|
||||
.dieAnimation(result.getString("die_animation"))
|
||||
.dieSound(result.getString("die_sound"))
|
||||
.build();
|
||||
enemies.put(result.getString("id"), enemy);
|
||||
}
|
||||
|
||||
@@ -14,4 +14,6 @@ public class EnemyModel {
|
||||
private final float animationSpeed;
|
||||
private final boolean blocking;
|
||||
private final String meleeWeapon;
|
||||
private final String dieAnimation;
|
||||
private final String dieSound;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.bartlomiejpluta.base.api.ai.NPC;
|
||||
import com.bartlomiejpluta.base.api.move.MoveEvent;
|
||||
|
||||
import com.bartlomiejpluta.base.lib.ai.NoopAI;
|
||||
import com.bartlomiejpluta.base.lib.animation.*;
|
||||
|
||||
import com.bartlomiejpluta.demo.runner.DemoRunner;
|
||||
import com.bartlomiejpluta.demo.database.model.EnemyModel;
|
||||
@@ -20,6 +21,7 @@ import com.bartlomiejpluta.demo.ai.*;
|
||||
public class Enemy extends Character implements NPC {
|
||||
private final EnemyModel template;
|
||||
private AI ai = NoopAI.INSTANCE;
|
||||
private final AnimationRunner dieAnimation;
|
||||
|
||||
public Enemy(@NonNull Context context, @NonNull EnemyModel template) {
|
||||
super(context, context.createEntity(template.getEntitySet()));
|
||||
@@ -29,6 +31,7 @@ public class Enemy extends Character implements NPC {
|
||||
setAnimationSpeed(template.getAnimationSpeed());
|
||||
setBlocking(template.isBlocking());
|
||||
setWeapon(new MeleeWeapon(context, ((DemoRunner) context.getGameRunner()).getMeleeWeaponDAO().get(template.getMeleeWeapon())));
|
||||
this.dieAnimation = new SimpleAnimationRunner(template.getDieAnimation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +50,8 @@ public class Enemy extends Character implements NPC {
|
||||
ai = NoopAI.INSTANCE;
|
||||
|
||||
getLayer().handleEvent(new EnemyDiedEvent(this));
|
||||
dieAnimation.run(context, getLayer(), this);
|
||||
context.playSound(template.getDieSound());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user