add sound effects
This commit is contained in:
parent
86f2345667
commit
587b902e79
39 changed files with 234 additions and 40 deletions
|
|
@ -9,6 +9,7 @@ bevy_egui = { workspace = true }
|
|||
state = { path = "../state" }
|
||||
combat = { path = "../combat" }
|
||||
music = { path = "../music" }
|
||||
ui = { path = "../ui" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use bevy_egui::{
|
|||
use combat::Difficulty;
|
||||
use music::BackgroundMusicPlayer;
|
||||
use state::AppState;
|
||||
use ui::PlayClickSound;
|
||||
|
||||
pub struct UiMenuPlugin;
|
||||
|
||||
|
|
@ -57,7 +58,11 @@ fn setup_menu(mut commands: Commands) {
|
|||
));
|
||||
}
|
||||
|
||||
fn main_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<MenuScreen>>) {
|
||||
fn main_screen(
|
||||
mut contexts: EguiContexts,
|
||||
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("Title")
|
||||
.resizable(false)
|
||||
|
|
@ -81,6 +86,7 @@ fn main_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<Men
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Difficulty);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
ui.centered_and_justified(|ui| {
|
||||
|
|
@ -89,6 +95,7 @@ fn main_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<Men
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Info);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
ui.centered_and_justified(|ui| {
|
||||
|
|
@ -97,6 +104,7 @@ fn main_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<Men
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Settings);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
ui.centered_and_justified(|ui| {
|
||||
|
|
@ -105,6 +113,7 @@ fn main_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<Men
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Credits);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -115,6 +124,7 @@ fn difficulty_screen(
|
|||
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||
mut next_state: ResMut<NextState<AppState>>,
|
||||
mut difficulty: ResMut<Difficulty>,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("DifficultyScreen")
|
||||
|
|
@ -131,6 +141,7 @@ fn difficulty_screen(
|
|||
{
|
||||
*difficulty = Difficulty::Standard;
|
||||
next_state.set(AppState::Game);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
columns[1].label("The intended experience, which is quite difficult.")
|
||||
});
|
||||
|
|
@ -145,6 +156,7 @@ fn difficulty_screen(
|
|||
{
|
||||
*difficulty = Difficulty::Chill;
|
||||
next_state.set(AppState::Game);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
columns[1].label(
|
||||
"Enemies deal significantly less damage. Good to chill and check out the game!",
|
||||
|
|
@ -157,6 +169,7 @@ fn difficulty_screen(
|
|||
{
|
||||
*difficulty = Difficulty::Casual;
|
||||
next_state.set(AppState::Game);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
columns[1].label(
|
||||
"Enemies deal less damage. Good for players who don't want to sweat as much.",
|
||||
|
|
@ -169,6 +182,7 @@ fn difficulty_screen(
|
|||
{
|
||||
*difficulty = Difficulty::Intense;
|
||||
next_state.set(AppState::Game);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
columns[1].label("Enemies deal more damage. Significantly harder.")
|
||||
});
|
||||
|
|
@ -184,11 +198,16 @@ fn difficulty_screen(
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Main);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn info_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<MenuScreen>>) {
|
||||
fn info_screen(
|
||||
mut contexts: EguiContexts,
|
||||
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("InfoScreen")
|
||||
.resizable(false)
|
||||
|
|
@ -215,6 +234,7 @@ fn info_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<Men
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Main);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -223,7 +243,8 @@ fn settings_screen(
|
|||
mut contexts: EguiContexts,
|
||||
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||
mut global_volume: ResMut<GlobalVolume>,
|
||||
mut music_query: Query<&mut AudioSink, With<BackgroundMusicPlayer>>,
|
||||
mut music_query: Query<(&mut AudioSink, &BackgroundMusicPlayer)>,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
mut volume: Local<f32>,
|
||||
mut init: Local<bool>,
|
||||
) {
|
||||
|
|
@ -242,8 +263,9 @@ fn settings_screen(
|
|||
ui.label(RichText::new("Volume").size(FONT_SIZE));
|
||||
ui.add(egui::Slider::new(&mut *volume, 0.0..=100.));
|
||||
global_volume.volume = Volume::Linear(*volume / 100.);
|
||||
if let Ok(mut sink) = music_query.single_mut() {
|
||||
sink.set_volume(Volume::Linear(*volume / 100.));
|
||||
if let Ok((mut sink, player)) = music_query.single_mut() {
|
||||
let player_volume = player.settings.volume.to_linear();
|
||||
sink.set_volume(Volume::Linear(*volume / 100. * player_volume));
|
||||
}
|
||||
});
|
||||
egui::Window::new("SettingsBack")
|
||||
|
|
@ -257,11 +279,16 @@ fn settings_screen(
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Main);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn credits_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<MenuScreen>>) {
|
||||
fn credits_screen(
|
||||
mut contexts: EguiContexts,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
mut next_screen: ResMut<NextState<MenuScreen>>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("SettingsScreen")
|
||||
.resizable(false)
|
||||
|
|
@ -325,6 +352,7 @@ fn credits_screen(mut contexts: EguiContexts, mut next_screen: ResMut<NextState<
|
|||
.clicked()
|
||||
{
|
||||
next_screen.set(MenuScreen::Main);
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue