add sound effects
This commit is contained in:
parent
86f2345667
commit
587b902e79
39 changed files with 234 additions and 40 deletions
|
|
@ -16,6 +16,7 @@ building_placement = { path = "../building_placement" }
|
|||
building_core = { path = "../building_core" }
|
||||
upgrade = { path = "../upgrade" }
|
||||
combat = { path = "../combat" }
|
||||
ui = { path = "../ui" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use resources::{
|
|||
AvailableWorkers, Cost, Quantity, ResourceDeposit, Resources, WorkedResourceDeposit,
|
||||
};
|
||||
use state::{BasePhaseState, CoreState, GameState, Phase};
|
||||
use ui::PlayClickSound;
|
||||
use ui_state::GameUIState;
|
||||
use upgrade::{UnlockUpgrade, Upgradable, Upgrade};
|
||||
|
||||
|
|
@ -80,6 +81,7 @@ fn plan_ui(
|
|||
mut contexts: EguiContexts,
|
||||
curr_phase: Res<State<BasePhaseState>>,
|
||||
mut next_phase: ResMut<NextState<BasePhaseState>>,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("PlanUI")
|
||||
|
|
@ -92,6 +94,7 @@ fn plan_ui(
|
|||
.button(RichText::new("EXECUTE").size(VERY_LARGE_FONT_SIZE))
|
||||
.clicked()
|
||||
{
|
||||
writer.write(PlayClickSound);
|
||||
next_phase.set(BasePhaseState::Execute {
|
||||
phase: curr_phase.get().phase_count(),
|
||||
});
|
||||
|
|
@ -202,6 +205,7 @@ fn side_panel(
|
|||
)>,
|
||||
mut selected_preview_writer: EventWriter<SelectBuildingPreview>,
|
||||
mut select_writer: EventWriter<SelectEntity>,
|
||||
mut writer: EventWriter<PlayClickSound>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("Resources")
|
||||
|
|
@ -214,6 +218,7 @@ fn side_panel(
|
|||
if let Ok((selected, selected_name)) = selected.single() {
|
||||
if ui.button("x").clicked() {
|
||||
select_writer.write(SelectEntity(None));
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
|
||||
ui.heading(selected_name.as_str());
|
||||
|
|
@ -246,6 +251,7 @@ fn side_panel(
|
|||
ui.add_enabled(false, egui::Button::new("Maximum workers reached"));
|
||||
} else {
|
||||
if ui.button("Add worker").clicked() {
|
||||
writer.write(PlayClickSound);
|
||||
available_workers.0 = available_workers.0.saturating_sub(1);
|
||||
if let Some(ref mut worked) = opt_worked {
|
||||
worked.workers = worked.workers.saturating_add(1);
|
||||
|
|
@ -264,6 +270,7 @@ fn side_panel(
|
|||
// remove
|
||||
if let Some(ref mut worked) = opt_worked {
|
||||
if ui.button("Remove worker").clicked() {
|
||||
writer.write(PlayClickSound);
|
||||
worked.workers = worked.workers.saturating_sub(1);
|
||||
available_workers.0 = available_workers.0.saturating_add(1);
|
||||
if worked.workers == 0 {
|
||||
|
|
@ -305,6 +312,7 @@ fn side_panel(
|
|||
RichText::new(upgrade_name.as_str()).size(LARGE_FONT_SIZE);
|
||||
if resources.0.can_buy(upgrade.cost) {
|
||||
if ui.button(button_text).clicked() {
|
||||
writer.write(PlayClickSound);
|
||||
resources.0 = resources.0 - upgrade.cost;
|
||||
commands.trigger_targets(
|
||||
UnlockUpgrade { building: selected },
|
||||
|
|
@ -341,6 +349,7 @@ fn side_panel(
|
|||
.clicked()
|
||||
{
|
||||
commands.entity(selected).despawn();
|
||||
writer.write(PlayClickSound);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -361,6 +370,7 @@ fn side_panel(
|
|||
RichText::new(format!("{} - {}", name, cost.0.to_string())).size(FONT_SIZE);
|
||||
if resources.can_buy(cost.0) {
|
||||
if ui.button(button_text).clicked() {
|
||||
writer.write(PlayClickSound);
|
||||
selected_preview_writer.write(SelectBuildingPreview(Some(info.preview)));
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue