game state and restart, but at what cost?? (my mental health)
This commit is contained in:
parent
4b9101ad2c
commit
002ad4a162
11 changed files with 143 additions and 23 deletions
|
|
@ -4,7 +4,12 @@ use bevy::prelude::*;
|
|||
use rand::distr::slice::Empty;
|
||||
|
||||
use crate::{
|
||||
core::bubble::{Bubble, bubble_spawn_wave},
|
||||
core::{
|
||||
bubble::{Bubble, bubble_spawn_wave},
|
||||
game_state::Resetable,
|
||||
kirby::Kirby,
|
||||
life::Life,
|
||||
},
|
||||
map::map::{BOTTOM, LEFT, RIGHT, TOP},
|
||||
};
|
||||
|
||||
|
|
@ -50,7 +55,7 @@ const GREEN_BUBBLE: BubbleType = BubbleType {
|
|||
|
||||
#[derive(Resource)]
|
||||
pub struct BubbleWaves {
|
||||
pub waves: Vec<Vec<BubbleSplash>>,
|
||||
waves: Vec<Vec<BubbleSplash>>,
|
||||
pub current_wave: usize,
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +80,12 @@ fn get_bubble_waves() -> BubbleWaves {
|
|||
}
|
||||
}
|
||||
|
||||
impl Resetable for BubbleWaves {
|
||||
fn reset(&mut self) {
|
||||
*self = get_bubble_waves();
|
||||
}
|
||||
}
|
||||
|
||||
fn no_ennemy_left(bubble_query: Query<(), With<Bubble>>) -> bool {
|
||||
bubble_query.is_empty()
|
||||
}
|
||||
|
|
@ -88,10 +99,16 @@ fn change_wave(mut bubble_wave: ResMut<BubbleWaves>, mut commands: Commands, ass
|
|||
bubble_spawn_wave(&mut commands, &asset_server, bubble_wave.waves[bubble_wave.current_wave].as_slice());
|
||||
}
|
||||
|
||||
fn heal_kirby(query: Query<&mut Life, With<Kirby>>) {
|
||||
for mut kirby_life in query {
|
||||
kirby_life.heal(f32::MAX);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WavePlugin;
|
||||
|
||||
impl Plugin for WavePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.insert_resource(get_bubble_waves()).add_systems(Update, change_wave.run_if(no_ennemy_left));
|
||||
app.insert_resource(get_bubble_waves()).add_systems(Update, (change_wave, heal_kirby).run_if(no_ennemy_left));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue