add game_over
This commit is contained in:
parent
1ecd054a31
commit
e9379a6a94
5 changed files with 57 additions and 23 deletions
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
use bevy::prelude::*;
|
||||
use building::{BuildingInfo, BuildingPreview, Core, PREVIEW_ALPHA, PopulatePlacedBuilding};
|
||||
use combat::{Defense, Health, Range};
|
||||
use state::CoreState;
|
||||
use combat::{Defense, Died, Health, Range};
|
||||
use state::{CoreState, GameState};
|
||||
use ui_range_indicator::CustomRangeIndicator;
|
||||
|
||||
pub struct BuildingCorePlugin;
|
||||
|
|
@ -85,17 +85,29 @@ fn populate(
|
|||
if trigger.event().info != res.info_entity {
|
||||
return;
|
||||
}
|
||||
commands.entity(trigger.target()).insert((
|
||||
Core,
|
||||
Mesh3d(res.mesh.clone()),
|
||||
MeshMaterial3d(res.material.clone()),
|
||||
CustomRangeIndicator::new(materials.add(StandardMaterial {
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
base_color: Color::srgba(0.6, 0.2, 0.2, 0.4),
|
||||
unlit: true,
|
||||
double_sided: true,
|
||||
..default()
|
||||
})),
|
||||
));
|
||||
commands
|
||||
.entity(trigger.target())
|
||||
.insert((
|
||||
Core,
|
||||
Mesh3d(res.mesh.clone()),
|
||||
MeshMaterial3d(res.material.clone()),
|
||||
CustomRangeIndicator::new(materials.add(StandardMaterial {
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
base_color: Color::srgba(0.6, 0.2, 0.2, 0.4),
|
||||
unlit: true,
|
||||
double_sided: true,
|
||||
..default()
|
||||
})),
|
||||
))
|
||||
.observe(core_dead);
|
||||
next_core_state.set(CoreState::Placed);
|
||||
}
|
||||
|
||||
fn core_dead(
|
||||
_trigger: Trigger<Died>,
|
||||
mut next_core_state: ResMut<NextState<CoreState>>,
|
||||
mut next_game_state: ResMut<NextState<GameState>>,
|
||||
) {
|
||||
next_core_state.set(CoreState::Dead);
|
||||
next_game_state.set(GameState::GameOver);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue