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