-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
100 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::entity::actor::AnimationState; | ||
use crate::entity::witch::ActorState; | ||
use crate::states::GameState; | ||
use bevy::prelude::*; | ||
use bevy_kira_audio::prelude::*; | ||
use std::time::Duration; | ||
|
||
#[derive(Default, Component, Reflect)] | ||
pub struct WitchWandSprite; | ||
|
||
#[derive(Default, Component, Reflect)] | ||
pub struct Footsteps(Handle<AudioInstance>); | ||
|
||
fn update_volume( | ||
mut witch_query: Query<(&ActorState, &mut Footsteps), Changed<ActorState>>, | ||
mut audio_instances: ResMut<Assets<AudioInstance>>, | ||
) { | ||
for (state, footsteps) in witch_query.iter_mut() { | ||
if let Some(instance) = audio_instances.get_mut(&footsteps.0) { | ||
let volume = match state.0 { | ||
AnimationState::Idle => 0.0, | ||
AnimationState::Walk => 0.6, | ||
}; | ||
instance.set_volume(volume, AudioTween::linear(Duration::from_millis(200))); | ||
} | ||
} | ||
} | ||
|
||
pub struct FootStepsPlugin; | ||
|
||
impl Plugin for FootStepsPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(Update, (update_volume).run_if(in_state(GameState::InGame))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ mod debug; | |
mod enemy; | ||
mod entity; | ||
mod equipment; | ||
mod footsteps; | ||
mod game; | ||
mod hud; | ||
mod input; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters