|
|
|
|
@ -81,6 +81,7 @@ fn main() {
|
|
|
|
|
damage_on_clear_line.run_if(any_component_removed::<LineBlock>),
|
|
|
|
|
damage_over_time.run_if(on_timer(Duration::from_secs(5))),
|
|
|
|
|
check_level_goal.run_if(resource_changed::<Score>),
|
|
|
|
|
check_level_fail.run_if(any_component_removed::<ShapeBlock>),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
// UI systems
|
|
|
|
|
@ -1056,7 +1057,7 @@ fn add_piece(mut commands: Commands, mut shapes: ResMut<ShapesBuffer>) {
|
|
|
|
|
commands
|
|
|
|
|
.spawn((
|
|
|
|
|
GridPosition {
|
|
|
|
|
y: Y_MAX - shape_layout.height(),
|
|
|
|
|
y: Y_MAX,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
shape_layout,
|
|
|
|
|
@ -1437,3 +1438,16 @@ fn check_level_goal(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn check_level_fail(
|
|
|
|
|
query: Query<&GridPosition, (With<Block>, Without<ShapeBlock>, Without<LineBlock>)>,
|
|
|
|
|
mut next: ResMut<NextState<GameState>>,
|
|
|
|
|
) {
|
|
|
|
|
// Check all blocks that are unassigned
|
|
|
|
|
query.iter().for_each(|gp| {
|
|
|
|
|
// If any block is above the top line, the game is over
|
|
|
|
|
if gp.y >= Y_MAX {
|
|
|
|
|
next.set(GameState::GameOver);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|