feat(sounds): Added dirt and gravel sound
This commit is contained in:
@@ -445,12 +445,14 @@ public class Game extends AutoTransientSupport {
|
||||
.toList();
|
||||
|
||||
if (placeHandler.place(this, x, y)) {
|
||||
if (item.getClass().isAnnotationPresent(PlaceSound.class)) {
|
||||
var key = item.getClass().getAnnotation(PlaceSound.class).value();
|
||||
blocks.removeAll(blocksRemove);
|
||||
for (Block block : blocks) {
|
||||
if (block.getClass().isAnnotationPresent(PlaceSound.class)) {
|
||||
var key = block.getClass().getAnnotation(PlaceSound.class).value();
|
||||
|
||||
gameStates.dependencies.sound.playSound(configuration, key);
|
||||
}
|
||||
blocks.removeAll(blocksRemove);
|
||||
}
|
||||
gameStates.dependencies.eventHandlerProvider.handlePlace(screenRenderer, this, x, y);
|
||||
screenRenderer.render(this);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import cz.jzitnik.game.core.sound.SoundKey;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@RequireAnnotation(ItemRegistry.class)
|
||||
@RequireAnnotation(BlockRegistry.class)
|
||||
public @interface PlaceSound {
|
||||
SoundKey value();
|
||||
}
|
||||
|
||||
@@ -2,5 +2,8 @@ package cz.jzitnik.game.core.sound;
|
||||
|
||||
public enum SoundKey {
|
||||
GRASS,
|
||||
GRASS_WALKING
|
||||
GRASS_WALKING,
|
||||
|
||||
GRAVEL,
|
||||
GRAVEL_WALKING
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.core.sound.SoundType;
|
||||
|
||||
@SoundRegistry(key = SoundKey.GRASS, resourceLocation = {
|
||||
"dirt/grass1.wav",
|
||||
"dirt/grass2.wav",
|
||||
"dirt/grass3.wav",
|
||||
"dirt/grass4.wav"
|
||||
"grass/grass1.wav",
|
||||
"grass/grass2.wav",
|
||||
"grass/grass3.wav",
|
||||
"grass/grass4.wav"
|
||||
}, type = SoundType.BLOCK)
|
||||
public class GrassSound {
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.core.sound.SoundType;
|
||||
|
||||
@SoundRegistry(key = SoundKey.GRASS_WALKING, resourceLocation = {
|
||||
"dirt/walk1.wav",
|
||||
"dirt/walk2.wav",
|
||||
"dirt/walk3.wav",
|
||||
"dirt/walk4.wav",
|
||||
"dirt/walk5.wav",
|
||||
"dirt/walk6.wav",
|
||||
"grass/walk1.wav",
|
||||
"grass/walk2.wav",
|
||||
"grass/walk3.wav",
|
||||
"grass/walk4.wav",
|
||||
"grass/walk5.wav",
|
||||
"grass/walk6.wav",
|
||||
}, type = SoundType.BLOCK)
|
||||
public class GrassWalkingSound {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.core.sound.registry;
|
||||
|
||||
import cz.jzitnik.game.annotations.SoundRegistry;
|
||||
import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.core.sound.SoundType;
|
||||
|
||||
@SoundRegistry(key = SoundKey.GRAVEL, resourceLocation = {
|
||||
"gravel/gravel1.wav",
|
||||
"gravel/gravel2.wav",
|
||||
"gravel/gravel3.wav",
|
||||
"gravel/gravel4.wav"
|
||||
}, type = SoundType.BLOCK)
|
||||
public class GravelSound {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.core.sound.registry;
|
||||
|
||||
import cz.jzitnik.game.annotations.SoundRegistry;
|
||||
import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.core.sound.SoundType;
|
||||
|
||||
@SoundRegistry(key = SoundKey.GRAVEL_WALKING, resourceLocation = {
|
||||
"gravel/step1.wav",
|
||||
"gravel/step2.wav",
|
||||
"gravel/step3.wav",
|
||||
"gravel/step4.wav",
|
||||
}, type = SoundType.BLOCK)
|
||||
public class GravelWalkingSound {
|
||||
}
|
||||
@@ -2,13 +2,20 @@ package cz.jzitnik.game.entities.items.registry.blocks.blocks;
|
||||
|
||||
import cz.jzitnik.game.SpriteLoader;
|
||||
import cz.jzitnik.game.annotations.BlockRegistry;
|
||||
import cz.jzitnik.game.annotations.MineSound;
|
||||
import cz.jzitnik.game.annotations.PlaceSound;
|
||||
import cz.jzitnik.game.annotations.ResetDataOnMine;
|
||||
import cz.jzitnik.game.annotations.WalkSound;
|
||||
import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.entities.Block;
|
||||
import cz.jzitnik.game.entities.items.ItemType;
|
||||
import cz.jzitnik.game.logic.services.grass.GrassDirtData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@PlaceSound(SoundKey.GRAVEL)
|
||||
@MineSound(SoundKey.GRAVEL)
|
||||
@WalkSound(SoundKey.GRAVEL_WALKING)
|
||||
@ResetDataOnMine
|
||||
@BlockRegistry("dirt")
|
||||
public class DirtBlock extends Block {
|
||||
|
||||
@@ -3,11 +3,18 @@ package cz.jzitnik.game.entities.items.registry.blocks.blocks;
|
||||
import cz.jzitnik.game.SpriteLoader;
|
||||
import cz.jzitnik.game.annotations.BlockRegistry;
|
||||
import cz.jzitnik.game.annotations.FallingBlock;
|
||||
import cz.jzitnik.game.annotations.MineSound;
|
||||
import cz.jzitnik.game.annotations.PlaceSound;
|
||||
import cz.jzitnik.game.annotations.WalkSound;
|
||||
import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.entities.Block;
|
||||
import cz.jzitnik.game.entities.items.ItemType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@PlaceSound(SoundKey.GRAVEL)
|
||||
@MineSound(SoundKey.GRAVEL)
|
||||
@WalkSound(SoundKey.GRAVEL_WALKING)
|
||||
@FallingBlock
|
||||
@BlockRegistry("gravel")
|
||||
public class GravelBlock extends Block {
|
||||
|
||||
@@ -2,12 +2,9 @@ package cz.jzitnik.game.entities.items.registry.items.blocks;
|
||||
|
||||
import cz.jzitnik.game.SpriteLoader;
|
||||
import cz.jzitnik.game.annotations.ItemRegistry;
|
||||
import cz.jzitnik.game.annotations.PlaceSound;
|
||||
import cz.jzitnik.game.core.sound.SoundKey;
|
||||
import cz.jzitnik.game.entities.items.Item;
|
||||
import cz.jzitnik.game.entities.items.ItemType;
|
||||
|
||||
@PlaceSound(SoundKey.GRASS)
|
||||
@ItemRegistry("grass")
|
||||
public class GrassItem extends Item {
|
||||
public GrassItem() {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user