forked from jzitnik/twodcraft
feat(sounds): Added hurt sound
This commit is contained in:
parent
e58c7be90d
commit
94abddef81
@ -46,7 +46,7 @@ public class Sound {
|
|||||||
var resources = annotation.resourceLocation();
|
var resources = annotation.resourceLocation();
|
||||||
var resource = resources[random.nextInt(resources.length)];
|
var resource = resources[random.nextInt(resources.length)];
|
||||||
|
|
||||||
var typeVolume = anot.isAnnotationPresent(SoundTypeSet.class)
|
var typeVolume = anot == null ? 100 : anot.isAnnotationPresent(SoundTypeSet.class)
|
||||||
? anot.getAnnotation(SoundTypeSet.class).value().getVolume()
|
? anot.getAnnotation(SoundTypeSet.class).value().getVolume()
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
@ -8,4 +8,6 @@ public enum SoundKey {
|
|||||||
GRAVEL_WALKING,
|
GRAVEL_WALKING,
|
||||||
|
|
||||||
WOOD,
|
WOOD,
|
||||||
|
|
||||||
|
HURT,
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package cz.jzitnik.game.core.sound.registry;
|
||||||
|
|
||||||
|
import cz.jzitnik.game.annotations.SoundRegistry;
|
||||||
|
import cz.jzitnik.game.core.sound.SoundKey;
|
||||||
|
|
||||||
|
@SoundRegistry(key = SoundKey.HURT, resourceLocation = {
|
||||||
|
"hurt.ogg",
|
||||||
|
})
|
||||||
|
public class HurtSound {
|
||||||
|
}
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
import cz.jzitnik.game.Game;
|
import cz.jzitnik.game.Game;
|
||||||
import cz.jzitnik.game.annotations.ReduceFallDamage;
|
import cz.jzitnik.game.annotations.ReduceFallDamage;
|
||||||
import cz.jzitnik.game.core.reducefalldamage.Reducer;
|
import cz.jzitnik.game.core.reducefalldamage.Reducer;
|
||||||
|
import cz.jzitnik.game.core.sound.SoundKey;
|
||||||
import cz.jzitnik.tui.ScreenRenderer;
|
import cz.jzitnik.tui.ScreenRenderer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -62,6 +63,7 @@ public class Player implements Serializable {
|
|||||||
health = Math.max(0, health - amount);
|
health = Math.max(0, health - amount);
|
||||||
if (amount != 0) {
|
if (amount != 0) {
|
||||||
game.playerHit(screenRenderer);
|
game.playerHit(screenRenderer);
|
||||||
|
game.getGameStates().dependencies.sound.playSound(game.getConfiguration(), SoundKey.HURT, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (health == 0) {
|
if (health == 0) {
|
||||||
|
BIN
src/main/resources/sounds/hurt.ogg
Normal file
BIN
src/main/resources/sounds/hurt.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user