add coranth moving towards target and post-attack event
This commit is contained in:
parent
e9790f156d
commit
1f8ecf9a9e
15 changed files with 249 additions and 58 deletions
|
|
@ -10,9 +10,9 @@ use bevy::{
|
|||
render::camera::Exposure,
|
||||
};
|
||||
use building_core::SpawnCore;
|
||||
use building_impaler::{Impaler, SpawnImpaler};
|
||||
use building_impaler::SpawnImpaler;
|
||||
use camera::ControlledCamera;
|
||||
use combat::{Defense, Health};
|
||||
use inhabitant_coranth::SpawnCoranth;
|
||||
use state::AppState;
|
||||
|
||||
pub struct LevelPlugin;
|
||||
|
|
@ -29,6 +29,7 @@ fn setup(
|
|||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
mut core_writer: EventWriter<SpawnCore>,
|
||||
mut impaler_writer: EventWriter<SpawnImpaler>,
|
||||
mut coranth_writer: EventWriter<SpawnCoranth>,
|
||||
) {
|
||||
let level_size = 50.0;
|
||||
// Static physics object with a collision shape
|
||||
|
|
@ -44,35 +45,10 @@ fn setup(
|
|||
})),
|
||||
));
|
||||
|
||||
// Dynamic physics object with a collision shape and initial angular velocity
|
||||
for y in 5..15 {
|
||||
commands
|
||||
.spawn((
|
||||
RigidBody::Dynamic,
|
||||
Collider::cuboid(0.5, 0.5, 0.5),
|
||||
AngularVelocity(Vec3::new(2.5, 3.5, 1.5)),
|
||||
Mesh3d(meshes.add(Cuboid::from_length(0.5))),
|
||||
MeshMaterial3d(materials.add(StandardMaterial {
|
||||
base_color: Color::srgb_u8(220, 156, 86),
|
||||
metallic: 1.0,
|
||||
perceptual_roughness: 0.3,
|
||||
..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>>,
|
||||
target: Single<&GlobalTransform, With<Impaler>>,
|
||||
mut query: Query<(&GlobalTransform, &mut LinearVelocity)>| {
|
||||
if let Ok((gtf, mut v)) = query.get_mut(trigger.target()) {
|
||||
let delta = target.translation() - gtf.translation();
|
||||
v.y += 5.0;
|
||||
v.0 += delta;
|
||||
}
|
||||
},
|
||||
);
|
||||
coranth_writer.write(SpawnCoranth {
|
||||
transform: Transform::from_xyz(y as f32 * 0.25, y as f32 * 1.1, 0.0),
|
||||
});
|
||||
}
|
||||
|
||||
core_writer.write(SpawnCore {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue