diff --git a/packages/trashy_road/assets/audio/wrong_bin.mp3 b/packages/trashy_road/assets/audio/wrong_bin.mp3 new file mode 100644 index 00000000..7853c416 Binary files /dev/null and b/packages/trashy_road/assets/audio/wrong_bin.mp3 differ diff --git a/packages/trashy_road/lib/gen/assets.gen.dart b/packages/trashy_road/lib/gen/assets.gen.dart index c4738b69..6be3b424 100644 --- a/packages/trashy_road/lib/gen/assets.gen.dart +++ b/packages/trashy_road/lib/gen/assets.gen.dart @@ -48,6 +48,9 @@ class $AssetsAudioGen { /// File path: assets/audio/rating_stars3.mp3 String get ratingStars3 => 'assets/audio/rating_stars3.mp3'; + /// File path: assets/audio/wrong_bin.mp3 + String get wrongBin => 'assets/audio/wrong_bin.mp3'; + /// List of all assets List get values => [ backgroundMusic, @@ -60,7 +63,8 @@ class $AssetsAudioGen { plasticBottle, ratingStars1, ratingStars2, - ratingStars3 + ratingStars3, + wrongBin ]; } diff --git a/packages/trashy_road/lib/src/audio/bloc/audio_state.dart b/packages/trashy_road/lib/src/audio/bloc/audio_state.dart index 0c5f7e53..98c568fa 100644 --- a/packages/trashy_road/lib/src/audio/bloc/audio_state.dart +++ b/packages/trashy_road/lib/src/audio/bloc/audio_state.dart @@ -16,20 +16,26 @@ class GameAudioData { const GameAudioData._({ required AssetSource source, required double volume, + Duration? duration, }) : _source = source, - _volume = volume; + _volume = volume, + _duration = duration; GameAudioData.fromPath( String path, { required double volume, + Duration? duration, }) : this._( source: AssetSource(path), volume: volume, + duration: duration, ); final AssetSource _source; final double _volume; + + final Duration? _duration; } abstract class GameBackgroundMusic { @@ -89,4 +95,10 @@ abstract class GameSoundEffects { Assets.audio.ratingStars3, volume: 0.25, ); + + static final wrongBin = GameAudioData.fromPath( + Assets.audio.wrongBin, + volume: 0.25, + duration: const Duration(seconds: 1), + ); } diff --git a/packages/trashy_road/lib/src/game/entities/trash_can/behaviors/trash_can_depositing_behavior.dart b/packages/trashy_road/lib/src/game/entities/trash_can/behaviors/trash_can_depositing_behavior.dart index 3719970b..91fc9a47 100644 --- a/packages/trashy_road/lib/src/game/entities/trash_can/behaviors/trash_can_depositing_behavior.dart +++ b/packages/trashy_road/lib/src/game/entities/trash_can/behaviors/trash_can_depositing_behavior.dart @@ -58,7 +58,10 @@ class TrashCanDepositingBehavior extends Behavior /// /// Does nothing if the [TrashCan] cannot deposit some trash. void deposit() { - if (!_canDeposit()) return; + if (!_canDeposit()) { + game.audioBloc.playEffect(GameSoundEffects.wrongBin); + return; + } game.audioBloc.playEffect( _depositSoundEffects.elementAt(