@@ -34,7 +34,9 @@ use crate::{
34
34
EndConditionSystem
35
35
} ,
36
36
movement:: {
37
- PenguinMovementSystem ,
37
+ EasyPenguinMovementSystem ,
38
+ Difficulty ,
39
+ MediumPenguinMovementSystem ,
38
40
PlayerMovementSystem
39
41
}
40
42
} ,
@@ -58,6 +60,7 @@ use crate::{
58
60
}
59
61
} ;
60
62
use std:: collections:: HashMap ;
63
+ use crate :: systems:: movement:: HardPenguinMovementSystem ;
61
64
62
65
/// Run State
63
66
///
@@ -70,7 +73,8 @@ pub struct RunState<'a, 'b> {
70
73
progress_counter : ProgressCounter ,
71
74
coin_texture_handle : Option < Handle < SpriteSheet > > ,
72
75
penguin_texture_handle : Option < Handle < SpriteSheet > > ,
73
- player_texture_handle : Option < Handle < SpriteSheet > >
76
+ player_texture_handle : Option < Handle < SpriteSheet > > ,
77
+ difficulty : Difficulty
74
78
}
75
79
76
80
impl < ' a , ' b > SimpleState for RunState < ' a , ' b > {
@@ -127,7 +131,8 @@ impl<'a, 'b> RunState<'a, 'b> {
127
131
progress_counter : ProgressCounter :: new ( ) ,
128
132
coin_texture_handle : None ,
129
133
penguin_texture_handle : None ,
130
- player_texture_handle : None
134
+ player_texture_handle : None ,
135
+ difficulty : Difficulty :: Easy
131
136
}
132
137
}
133
138
@@ -137,9 +142,15 @@ impl<'a, 'b> RunState<'a, 'b> {
137
142
138
143
fn initialize_dispatcher ( & mut self , world : & mut World ) {
139
144
let mut dispatcher_builder = DispatcherBuilder :: new ( ) ;
140
- dispatcher_builder. add ( CoinRotationSystem , "coin_rotation_system" , & [ ] ) ;
141
145
dispatcher_builder. add ( PlayerMovementSystem , "player_movement_system" , & [ ] ) ;
142
- dispatcher_builder. add ( PenguinMovementSystem , "penguin_movement_system" , & [ "player_movement_system" ] ) ;
146
+
147
+ match self . difficulty {
148
+ Difficulty :: Easy => dispatcher_builder. add ( EasyPenguinMovementSystem , "penguin_movement_system" , & [ "player_movement_system" ] ) ,
149
+ Difficulty :: Medium => dispatcher_builder. add ( MediumPenguinMovementSystem , "penguin_movement_system" , & [ "player_movement_system" ] ) ,
150
+ Difficulty :: Hard => dispatcher_builder. add ( HardPenguinMovementSystem , "penguin_movement_system" , & [ "player_movement_system" ] )
151
+ }
152
+
153
+ dispatcher_builder. add ( CoinRotationSystem , "coin_rotation_system" , & [ ] ) ;
143
154
dispatcher_builder. add ( CoinCollectionSystem , "coin_collection_system" , & [ "player_movement_system" ] ) ;
144
155
dispatcher_builder. add ( EndConditionSystem , "end_condition_system" , & [ "penguin_movement_system" , "coin_collection_system" ] ) ;
145
156
@@ -221,6 +232,10 @@ impl<'a, 'b> RunState<'a, 'b> {
221
232
. with ( EndConditionComponent :: default ( ) )
222
233
. build ( ) ;
223
234
}
235
+
236
+ pub fn set_difficulty ( & mut self , difficulty : Difficulty ) {
237
+ self . difficulty = difficulty;
238
+ }
224
239
}
225
240
226
241
impl < ' a , ' b > Default for RunState < ' a , ' b > {
0 commit comments