combat system
This commit is contained in:
parent
928faf9570
commit
f5d022d1d0
8 changed files with 150 additions and 10 deletions
|
|
@ -5,9 +5,11 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
bevy = { workspace = true }
|
||||
avian3d = { workspace = true }
|
||||
|
||||
state = { path = "../state" }
|
||||
camera = { path = "../camera" }
|
||||
avian3d = { workspace = true }
|
||||
combat = { path = "../combat" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use bevy::{
|
|||
render::camera::Exposure,
|
||||
};
|
||||
use camera::ControlledCamera;
|
||||
use combat::{Attacked, Defense, Health};
|
||||
use state::AppState;
|
||||
|
||||
pub struct LevelPlugin;
|
||||
|
|
@ -53,12 +54,20 @@ fn setup(
|
|||
..default()
|
||||
})),
|
||||
Transform::from_xyz(0.0, y as f32 * 1.1, 0.0),
|
||||
Health::new(5.0),
|
||||
Defense::new(y as f32 - 5.0),
|
||||
))
|
||||
.observe(
|
||||
|trigger: Trigger<Pointer<Click>>, mut query: Query<&mut LinearVelocity>| {
|
||||
|trigger: Trigger<Pointer<Click>>,
|
||||
mut query: Query<&mut LinearVelocity>,
|
||||
mut commands: Commands| {
|
||||
if let Ok(mut v) = query.get_mut(trigger.target()) {
|
||||
v.y += 3.0;
|
||||
v.y += 5.0;
|
||||
}
|
||||
commands.entity(trigger.target()).trigger(Attacked {
|
||||
attacker: None,
|
||||
amount: 8.,
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue