more sound effects
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use super::{BackbackSwapEvent, Backpack, BackpackHead};
|
||||
use crate::{GameState, heads_ui::HeadsImages, loading_assets::UIAssets};
|
||||
use crate::{GameState, heads_ui::HeadsImages, loading_assets::UIAssets, sounds::PlaySound};
|
||||
use bevy::prelude::*;
|
||||
|
||||
static HEAD_SLOTS: usize = 5;
|
||||
@@ -270,6 +270,7 @@ fn swap_head_inputs(
|
||||
let action = *trigger.event();
|
||||
if action == BackpackAction::OpenClose {
|
||||
state.open = !state.open;
|
||||
commands.trigger(PlaySound::Backpack { open: state.open });
|
||||
}
|
||||
|
||||
if !state.open {
|
||||
@@ -290,6 +291,7 @@ fn swap_head_inputs(
|
||||
}
|
||||
|
||||
if changed {
|
||||
commands.trigger(PlaySound::Selection);
|
||||
sync(&backpack, &mut state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::{
|
||||
backpack::{BackbackSwapEvent, Backpack, BackpackHead},
|
||||
loading_assets::UIAssets,
|
||||
player::head_id_to_str,
|
||||
sounds::PlaySound,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
@@ -204,6 +205,7 @@ fn on_select_active_head(
|
||||
}
|
||||
}
|
||||
|
||||
commands.trigger(PlaySound::Selection);
|
||||
commands.trigger(HeadChanged(res.heads[res.current_slot].unwrap()));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,14 @@ pub struct AudioAssets {
|
||||
pub gate: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/effects/cash.ogg")]
|
||||
pub cash: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/ui/selection.ogg")]
|
||||
pub selection: Handle<AudioSource>,
|
||||
|
||||
#[asset(path = "sfx/ui/backpack_open.ogg")]
|
||||
pub backpack_open: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/ui/backpack_close.ogg")]
|
||||
pub backpack_close: Handle<AudioSource>,
|
||||
|
||||
#[asset(path = "sfx/hit", collection(typed))]
|
||||
pub hit: Vec<Handle<AudioSource>>,
|
||||
#[asset(path = "sfx/heads", collection(mapped, typed))]
|
||||
|
||||
@@ -133,7 +133,7 @@ fn music(assets: Res<AudioAssets>, mut commands: Commands) {
|
||||
AudioPlayer::new(assets.music.clone()),
|
||||
PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
volume: Volume::new(0.6),
|
||||
volume: Volume::new(0.4),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
@@ -142,7 +142,7 @@ fn music(assets: Res<AudioAssets>, mut commands: Commands) {
|
||||
AudioPlayer::new(assets.ambient.clone()),
|
||||
PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
volume: Volume::new(1.),
|
||||
volume: Volume::new(0.8),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
|
||||
@@ -8,6 +8,8 @@ pub enum PlaySound {
|
||||
Gun,
|
||||
Gate,
|
||||
CashCollect,
|
||||
Selection,
|
||||
Backpack { open: bool },
|
||||
Head(String),
|
||||
}
|
||||
|
||||
@@ -37,6 +39,14 @@ fn spawn_sounds(
|
||||
PlaySound::Gun => assets.gun.clone(),
|
||||
PlaySound::Gate => assets.gate.clone(),
|
||||
PlaySound::CashCollect => assets.cash.clone(),
|
||||
PlaySound::Selection => assets.selection.clone(),
|
||||
PlaySound::Backpack { open } => {
|
||||
if *open {
|
||||
assets.backpack_open.clone()
|
||||
} else {
|
||||
assets.backpack_close.clone()
|
||||
}
|
||||
}
|
||||
PlaySound::Head(name) => {
|
||||
let filename = format!("{}.ogg", name);
|
||||
assets
|
||||
|
||||
Reference in New Issue
Block a user