diff options
author | David <david003@gmx.net> | 2022-07-16 21:02:56 +0200 |
---|---|---|
committer | David <david003@gmx.net> | 2022-07-16 21:02:56 +0200 |
commit | f561a1f69d5fda68e0a23ab04f448e9364b2968c (patch) | |
tree | 193175713911f4813e3fd5e1b44ac0af65d932e1 | |
parent | d1bac1c41a75fdf901e1f7c5f604783f0685190a (diff) | |
download | 2022-f561a1f69d5fda68e0a23ab04f448e9364b2968c.tar.gz 2022-f561a1f69d5fda68e0a23ab04f448e9364b2968c.tar.bz2 2022-f561a1f69d5fda68e0a23ab04f448e9364b2968c.zip |
deactivate ball after 5s
-rw-r--r-- | godot/scenes/objects/Player.tscn | 1 | ||||
-rwxr-xr-x | lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so | bin | 30388072 -> 30387968 bytes | |||
-rw-r--r-- | rust/src/basic_die.rs | 20 |
3 files changed, 18 insertions, 3 deletions
diff --git a/godot/scenes/objects/Player.tscn b/godot/scenes/objects/Player.tscn index aeb8f51..8cfdd6e 100644 --- a/godot/scenes/objects/Player.tscn +++ b/godot/scenes/objects/Player.tscn @@ -12,6 +12,7 @@ shooting/up_angle = 0.3 shooting/stopping_velocity = 0.003 input/camera_mouse_sensitivity = Vector2( 0.003, 0.002 ) input/shoot_sensitivity = 0.1 +input/current_buff_index = 5 [node name="W8" parent="." instance=ExtResource( 1 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0 ) diff --git a/lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so b/lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so Binary files differindex 78eca51..962bdb5 100755 --- a/lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so +++ b/lib/x86_64-unknown-linux-gnu/libcode_with_your_friends2022.so diff --git a/rust/src/basic_die.rs b/rust/src/basic_die.rs index dc425b4..dbcccc8 100644 --- a/rust/src/basic_die.rs +++ b/rust/src/basic_die.rs @@ -13,7 +13,7 @@ enum InputState { Shooting, Moving } - + type SpatialRef = Option<Ref<Spatial>>; @@ -37,7 +37,7 @@ pub struct BasicDie { #[property(path="input/shoot_sensitivity")] shoot_sensitivity: f32, #[property(path="input/current_buff_index")] - current_buff_index: i8, + current_buff_index: i32, all_buffs: [Option<Box<dyn Buff>>; 5], @@ -144,6 +144,7 @@ impl BasicDie { Some(Box::new(BuffExtra ::new())), ]; + godot_print!("Current Buff: {}", self.current_buff_index); godot_print!("Player is ready"); } @@ -166,8 +167,19 @@ impl BasicDie { } } - // detect if the die stops moving let delta_ms = OS::godot_singleton().get_ticks_msec() - self.last_shot_time; + + // deactivate the Ball Buff after 5 seconds + if matches!(self.input_state, InputState::Moving) + && delta_ms > 5000 + && self.current_buff_index == 1 { + match self.all_buffs[1] { + Some(ref mut buff) => buff.revert_buff(), + None => {} + } + } + + // detect if the die stops moving if matches!(self.input_state, InputState::Moving) && (delta_ms > self.stopping_min_ms) { @@ -178,6 +190,7 @@ impl BasicDie { godot_print!("Die stopped moving at velocity {} after {} ms", current_vel, delta_ms); //deactivate the old buff + godot_print!("Current Buff: {}", self.current_buff_index); match self.all_buffs[self.current_buff_index as usize] { Some(ref mut buff) => buff.revert_buff(), None => {} @@ -349,6 +362,7 @@ impl BasicDie { }; // apply the current buff + godot_print!("Current Buff: {}", self.current_buff_index); match self.all_buffs[self.current_buff_index as usize] { Some(ref mut buff) => buff.execute_buff(), None => {} |