new sounds
This commit is contained in:
parent
19530d3e13
commit
fea363554e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1607,68 +1607,68 @@ function __wbg_get_imports() {
|
|||
const ret = wasm.memory;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5127 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper5134 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5128 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper5135 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5129 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper5136 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5130 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper5137 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5131 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_41);
|
||||
imports.wbg.__wbindgen_closure_wrapper5138 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_41);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5132 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_44);
|
||||
imports.wbg.__wbindgen_closure_wrapper5139 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_44);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper5133 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5178, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper5140 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 5180, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper41513 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36242, __wbg_adapter_49);
|
||||
imports.wbg.__wbindgen_closure_wrapper41520 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36244, __wbg_adapter_49);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42768 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper42775 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42769 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_55);
|
||||
imports.wbg.__wbindgen_closure_wrapper42776 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_55);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42770 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_55);
|
||||
imports.wbg.__wbindgen_closure_wrapper42777 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_55);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42771 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_55);
|
||||
imports.wbg.__wbindgen_closure_wrapper42778 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_55);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42772 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_55);
|
||||
imports.wbg.__wbindgen_closure_wrapper42779 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_55);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42773 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_55);
|
||||
imports.wbg.__wbindgen_closure_wrapper42780 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_55);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper42774 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36861, __wbg_adapter_55);
|
||||
imports.wbg.__wbindgen_closure_wrapper42781 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 36863, __wbg_adapter_55);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper45069 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 37354, __wbg_adapter_68);
|
||||
imports.wbg.__wbindgen_closure_wrapper45076 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 37356, __wbg_adapter_68);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,3 +1,4 @@
|
|||
use crate::msg::SoundMessage;
|
||||
use crate::Game;
|
||||
use crate::Player;
|
||||
use fyrox::graph::SceneGraph;
|
||||
|
|
@ -46,6 +47,7 @@ const DAMAGE: f32 = 20.0;
|
|||
const ATTACK_SPEED: f32 = 1.0;
|
||||
const SUPER_DAMAGE: f32 = 30.0;
|
||||
const SUPER_ATTACK_SPEED: f32 = 0.3;
|
||||
const MOAN_TIME: f32 = 3.1;
|
||||
|
||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||
pub struct Archer {
|
||||
|
|
@ -70,6 +72,9 @@ pub struct Archer {
|
|||
attack_damage: f32,
|
||||
attack_timer: f32,
|
||||
attack_speed: f32,
|
||||
|
||||
moan_timer: f32,
|
||||
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
}
|
||||
|
|
@ -83,7 +88,7 @@ impl Archer {
|
|||
return a.round() as i32;
|
||||
}
|
||||
|
||||
pub fn take_damage(&mut self, _damage: &f32) {
|
||||
pub fn take_damage(&mut self, _damage: &f32) {
|
||||
if self.dead {
|
||||
return;
|
||||
}
|
||||
|
|
@ -341,7 +346,9 @@ impl Archer {
|
|||
|
||||
fn move_do(&mut self, context: &mut ScriptContext) {
|
||||
let x_speed = self.get_speed(context);
|
||||
if x_speed > 0.0 {
|
||||
if x_speed != 0.0 {
|
||||
context.message_sender.send_global(SoundMessage::Bones);
|
||||
context.message_sender.send_global(SoundMessage::EnemyWalk);
|
||||
self.fight = false;
|
||||
}
|
||||
let enemy_rigid_body = context.scene.graph[context.handle].cast_mut::<RigidBody>();
|
||||
|
|
@ -396,11 +403,27 @@ impl Archer {
|
|||
if self.attack_timer >= speed {
|
||||
self.attack_player(context, damage);
|
||||
self.attack_timer = 0.0;
|
||||
context.message_sender.send_global(SoundMessage::ArcherBowAttack);
|
||||
return;
|
||||
}
|
||||
// self.fight = false;
|
||||
}
|
||||
|
||||
fn moan(&mut self, context: &mut ScriptContext) {
|
||||
let distance = self.distance_to_player(context);
|
||||
if distance > DISTANCE_TO_VIEW {
|
||||
return;
|
||||
}
|
||||
if self.moan_timer == 0.0 {
|
||||
context.message_sender.send_global(SoundMessage::SkeletonMoan);
|
||||
}
|
||||
self.moan_timer += context.dt;
|
||||
if self.moan_timer >= MOAN_TIME {
|
||||
self.moan_timer = 0.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn animation_do(&mut self, context: &mut ScriptContext) {
|
||||
self.animate_choose(context);
|
||||
let cur_anim = self.current_animation as usize;
|
||||
|
|
@ -486,5 +509,6 @@ impl ScriptTrait for Archer {
|
|||
self.change_orientation(context);
|
||||
self.animation_do(context);
|
||||
self.move_do(context);
|
||||
self.moan(context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ const END_MAP_RIGHT: f32 = 30.0;
|
|||
const SPEED: f32 = 3.1;
|
||||
const DAMAGE: f32 = 100.0;
|
||||
const ATTACK_SPEED: f32 = 0.1;
|
||||
const MOAN_TIME: f32 = 3.1;
|
||||
|
||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||
pub struct Swordman {
|
||||
|
|
@ -69,6 +70,9 @@ pub struct Swordman {
|
|||
attack_damage: f32,
|
||||
attack_timer: f32,
|
||||
attack_speed: f32,
|
||||
|
||||
moan_timer: f32,
|
||||
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
}
|
||||
|
|
@ -340,7 +344,9 @@ impl Swordman {
|
|||
|
||||
fn move_do(&mut self, context: &mut ScriptContext) {
|
||||
let x_speed = self.get_speed(context);
|
||||
if x_speed > 0.0 {
|
||||
if x_speed != 0.0 {
|
||||
context.message_sender.send_global(SoundMessage::Bones);
|
||||
context.message_sender.send_global(SoundMessage::EnemyWalk);
|
||||
self.block = false;
|
||||
}
|
||||
let enemy_rigid_body = context.scene.graph[context.handle].cast_mut::<RigidBody>();
|
||||
|
|
@ -395,11 +401,27 @@ impl Swordman {
|
|||
if self.attack_timer >= self.attack_speed {
|
||||
self.attack_player(context);
|
||||
self.attack_timer = 0.0;
|
||||
context.message_sender.send_global(SoundMessage::SkeletonAttack);
|
||||
return;
|
||||
}
|
||||
self.fight = false;
|
||||
}
|
||||
|
||||
fn moan(&mut self, context: &mut ScriptContext) {
|
||||
let distance = self.distance_to_player(context);
|
||||
if distance > DISTANCE_TO_VIEW {
|
||||
return;
|
||||
}
|
||||
if self.moan_timer == 0.0 {
|
||||
context.message_sender.send_global(SoundMessage::SkeletonMoan);
|
||||
}
|
||||
self.moan_timer += context.dt;
|
||||
if self.moan_timer >= MOAN_TIME {
|
||||
self.moan_timer = 0.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn animation_do(&mut self, context: &mut ScriptContext) {
|
||||
self.animate_choose(context);
|
||||
let cur_anim = self.current_animation as usize;
|
||||
|
|
@ -485,5 +507,6 @@ impl ScriptTrait for Swordman {
|
|||
self.change_orientation(context);
|
||||
self.animation_do(context);
|
||||
self.move_do(context);
|
||||
self.moan(context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ pub enum ScreenSizeMessage {
|
|||
#[derive(Debug, Clone)]
|
||||
pub enum SoundMessage {
|
||||
PlayerWalk,
|
||||
PlayerJump,
|
||||
EnemyWalk,
|
||||
PlayerAttack,
|
||||
ArcherKnifeAttack,
|
||||
ArcherBowAttack,
|
||||
SkeletonAttack,
|
||||
Lose,
|
||||
Win,
|
||||
SkeletonMoan,
|
||||
Bones,
|
||||
}
|
||||
|
|
@ -186,25 +186,12 @@ impl Player {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn key_checker(&mut self, context: &mut ScriptContext, keycode: KeyCode, is_pressed: bool) {
|
||||
pub fn key_checker(&mut self, keycode: KeyCode, is_pressed: bool) {
|
||||
match keycode {
|
||||
KeyCode::ArrowLeft => self.move_left = is_pressed,
|
||||
KeyCode::ArrowRight => self.move_right = is_pressed,
|
||||
KeyCode::ArrowUp => self.jump = is_pressed,
|
||||
KeyCode::Space => {
|
||||
if !is_pressed {
|
||||
self.fight = false;
|
||||
self.start_fight_last = 0.0;
|
||||
return;
|
||||
}
|
||||
if (context.elapsed_time - self.start_fight_last) < 0.1 {
|
||||
self.fight = false;
|
||||
self.start_fight_last = context.elapsed_time;
|
||||
return;
|
||||
}
|
||||
self.start_fight_last = context.elapsed_time;
|
||||
self.fight = is_pressed;
|
||||
}
|
||||
KeyCode::Space => self.fight = is_pressed,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
@ -257,13 +244,15 @@ impl Player {
|
|||
if self.jump && !self.is_in_fly(rigid_data) {
|
||||
self.start_y_position = rigid_data.global_position().y;
|
||||
rigid_data.set_lin_vel(Vector2::new(rigid_data.lin_vel().x, JUMP_HEIGHT));
|
||||
context.message_sender.send_global(SoundMessage::PlayerJump);
|
||||
return;
|
||||
}
|
||||
if rigid_data.lin_vel().y == 0.0 && !self.is_in_fly(rigid_data) {
|
||||
self.start_y_position = rigid_data.global_position().y;
|
||||
}
|
||||
if rigid_data.global_position().y < -10.0 {
|
||||
self.health = 0.0
|
||||
self.health = 0.0;
|
||||
context.message_sender.send_global(SoundMessage::Win);
|
||||
}
|
||||
// Log::info(format!(
|
||||
// "pos {}, dif_height: {}, lin_vel: {}, jump: {}, is_jumping: {}",
|
||||
|
|
@ -373,9 +362,12 @@ impl Player {
|
|||
if let Some(enemy) = enemy_script {
|
||||
enemy.take_damage(&self.damage);
|
||||
}
|
||||
let enemy_script = context.scene.graph.try_get_script_of_mut::<Archer>(d);
|
||||
|
||||
let enemy_script = context.scene.graph.try_get_script_component_of_mut::<Archer>(d);
|
||||
if let Some(enemy) = enemy_script {
|
||||
enemy.take_damage(&self.damage);
|
||||
// TODO: I was defeated by multyborrow context
|
||||
context.message_sender.send_global(SoundMessage::ArcherKnifeAttack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -454,6 +446,7 @@ impl Player {
|
|||
if self.health <= 0.0 {
|
||||
let game = context.plugins.get_mut::<Game>();
|
||||
game.show_menu();
|
||||
context.message_sender.send_global(SoundMessage::Lose);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -527,12 +520,12 @@ impl ScriptTrait for Player {
|
|||
}
|
||||
|
||||
// Called whenever there is an event from OS (mouse click, keypress, etc.)
|
||||
fn on_os_event(&mut self, event: &Event<()>, context: &mut ScriptContext) {
|
||||
fn on_os_event(&mut self, event: &Event<()>, _context: &mut ScriptContext) {
|
||||
if let Event::WindowEvent { event, .. } = event {
|
||||
if let WindowEvent::KeyboardInput { event, .. } = event {
|
||||
if let PhysicalKey::Code(keycode) = event.physical_key {
|
||||
let is_pressed = event.state == ElementState::Pressed;
|
||||
self.key_checker(context, keycode, is_pressed);
|
||||
self.key_checker( keycode, is_pressed);
|
||||
}
|
||||
}
|
||||
if let WindowEvent::Touch(touch) = event {
|
||||
|
|
@ -543,27 +536,27 @@ impl ScriptTrait for Player {
|
|||
touch.location.x, touch.location.y
|
||||
));
|
||||
if touch.location.x > (self.window_width / 2) as f64 {
|
||||
self.key_checker(context, KeyCode::ArrowRight, true);
|
||||
self.key_checker(context, KeyCode::ArrowLeft, false);
|
||||
self.key_checker( KeyCode::ArrowRight, true);
|
||||
self.key_checker( KeyCode::ArrowLeft, false);
|
||||
} else {
|
||||
self.key_checker(context, KeyCode::ArrowLeft, true);
|
||||
self.key_checker(context, KeyCode::ArrowRight, false);
|
||||
self.key_checker( KeyCode::ArrowLeft, true);
|
||||
self.key_checker( KeyCode::ArrowRight, false);
|
||||
}
|
||||
if touch.location.y < (self.window_height / 2) as f64 {
|
||||
self.key_checker(context, KeyCode::ArrowUp, true);
|
||||
self.key_checker( KeyCode::ArrowUp, true);
|
||||
}
|
||||
if touch.location.y > (self.window_height / 2) as f64 {
|
||||
self.key_checker(context, KeyCode::ArrowUp, false);
|
||||
self.key_checker( KeyCode::ArrowUp, false);
|
||||
}
|
||||
}
|
||||
TouchPhase::Ended => {
|
||||
if touch.location.x > (self.window_width / 2) as f64 {
|
||||
self.key_checker(context, KeyCode::ArrowRight, false);
|
||||
self.key_checker( KeyCode::ArrowRight, false);
|
||||
} else {
|
||||
self.key_checker(context, KeyCode::ArrowLeft, false);
|
||||
self.key_checker( KeyCode::ArrowLeft, false);
|
||||
}
|
||||
if touch.location.y < (self.window_height / 2) as f64 {
|
||||
self.key_checker(context, KeyCode::ArrowUp, false);
|
||||
self.key_checker( KeyCode::ArrowUp, false);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,23 @@ use fyrox::{
|
|||
#[derive(Visit, Reflect, Debug, Default, Clone)]
|
||||
pub struct Sound {
|
||||
player_walk: Handle<Node>,
|
||||
player_jump: Handle<Node>,
|
||||
skeleton_walk: Handle<Node>,
|
||||
skeleton_moan: Handle<Node>,
|
||||
skeleton_attack: Handle<Node>,
|
||||
player_attack: Handle<Node>,
|
||||
archer_knife_attack: Handle<Node>,
|
||||
archer_bow_attack: Handle<Node>,
|
||||
archer_moan: Handle<Node>,
|
||||
lose: Handle<Node>,
|
||||
win: Handle<Node>,
|
||||
}
|
||||
|
||||
const FAST_SPEED: f64 = 2.0;
|
||||
const NORMAL_SPEED: f64 = 1.0;
|
||||
const LOW_GAIN: f32 = 0.1;
|
||||
const NORMAL_GAIN: f32 = 0.5;
|
||||
|
||||
uuid_provider!(Sound = "cc671d19-9f1a-4286-8486-add4ebaadaec");
|
||||
|
||||
impl Sound {
|
||||
|
|
@ -30,7 +43,7 @@ impl Sound {
|
|||
RigidBodyBuilder::new(BaseBuilder::new().with_script(sound)).build(graph);
|
||||
}
|
||||
|
||||
fn new_sound(&self, ctx: &mut ScriptMessageContext, name: &str) -> Handle<Node> {
|
||||
fn new_sound(&self, ctx: &mut ScriptMessageContext, name: &str, pitch: f64, gain: f32) -> Handle<Node> {
|
||||
let mut path = "assets/data/sounds/".to_owned();
|
||||
path.push_str(name);
|
||||
let walk_sound = ctx.resource_manager.request::<SoundBuffer>(path);
|
||||
|
|
@ -38,12 +51,12 @@ impl Sound {
|
|||
.with_buffer(Some(walk_sound))
|
||||
.with_status(Status::Playing)
|
||||
.with_play_once(true)
|
||||
.with_gain(0.1)
|
||||
.with_pitch(2.0)
|
||||
.with_gain(gain)
|
||||
.with_pitch(pitch)
|
||||
.build(&mut ctx.scene.graph);
|
||||
}
|
||||
|
||||
fn play_sound(&self, ctx: &mut ScriptMessageContext, name: &str, handle: Handle<Node>) -> Option<Handle<Node>> {
|
||||
fn play_sound(&self, ctx: &mut ScriptMessageContext, name: &str, handle: Handle<Node>, pitch: f64, gain: f32) -> Option<Handle<Node>> {
|
||||
let sound_body = ctx.scene.graph.try_get_mut(handle);
|
||||
if let Some(sound) = sound_body {
|
||||
if sound.as_sound().status() == Status::Stopped {
|
||||
|
|
@ -51,7 +64,7 @@ impl Sound {
|
|||
}
|
||||
return None;
|
||||
}
|
||||
return Some(self.new_sound(ctx, name));
|
||||
return Some(self.new_sound(ctx, name, pitch, gain));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,20 +91,60 @@ impl ScriptTrait for Sound {
|
|||
ctx: &mut ScriptMessageContext,
|
||||
) {
|
||||
if let Some(SoundMessage::PlayerWalk) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "player_walk.ogg", self.player_walk) {
|
||||
if let Some(sound) = self.play_sound(ctx, "player_walk.ogg", self.player_walk, FAST_SPEED, LOW_GAIN) {
|
||||
self.player_walk = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::EnemyWalk) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "skeleton_walk.ogg", self.skeleton_walk) {
|
||||
if let Some(sound) = self.play_sound(ctx, "skeleton_walk.ogg", self.skeleton_walk, FAST_SPEED, LOW_GAIN) {
|
||||
self.skeleton_walk = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::PlayerAttack) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "player_sword.ogg", self.player_attack) {
|
||||
if let Some(sound) = self.play_sound(ctx, "player_sword.ogg", self.player_attack, FAST_SPEED, LOW_GAIN) {
|
||||
self.player_attack = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::SkeletonAttack) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "skeleton_sword.ogg", self.skeleton_attack, FAST_SPEED, LOW_GAIN) {
|
||||
self.skeleton_attack = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::ArcherBowAttack) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "bow-arrow.ogg", self.archer_bow_attack, FAST_SPEED, LOW_GAIN) {
|
||||
self.archer_bow_attack = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::ArcherKnifeAttack) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "skeleton_sword.ogg", self.archer_knife_attack, FAST_SPEED, LOW_GAIN) {
|
||||
self.archer_knife_attack = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::Lose) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "lose.ogg", self.lose, NORMAL_SPEED, NORMAL_GAIN) {
|
||||
self.lose = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::PlayerJump) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "distance-jump-sound.ogg", self.player_jump, FAST_SPEED, LOW_GAIN) {
|
||||
self.player_jump = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::Win) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "win.ogg", self.win, NORMAL_SPEED, NORMAL_GAIN) {
|
||||
self.win = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::SkeletonMoan) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "skeleton-woke-up.ogg", self.skeleton_moan, FAST_SPEED, LOW_GAIN) {
|
||||
self.skeleton_moan = sound;
|
||||
}
|
||||
}
|
||||
if let Some(SoundMessage::Bones) = message.downcast_ref::<SoundMessage>() {
|
||||
if let Some(sound) = self.play_sound(ctx, "the-bone-of-the-skeleton-moves.ogg", self.archer_moan, NORMAL_SPEED, LOW_GAIN) {
|
||||
self.archer_moan = sound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called whenever there is an event from OS (mouse click, keypress, etc.)
|
||||
|
|
|
|||
Loading…
Reference in New Issue