add difficulty settings, increase drops
This commit is contained in:
parent
d35344f910
commit
dccd6d319e
9 changed files with 57 additions and 17 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -3095,6 +3095,7 @@ dependencies = [
|
||||||
"combat_damagers",
|
"combat_damagers",
|
||||||
"inhabitant",
|
"inhabitant",
|
||||||
"inhabitant_simbert",
|
"inhabitant_simbert",
|
||||||
|
"resources",
|
||||||
"state",
|
"state",
|
||||||
"ui_health_bar",
|
"ui_health_bar",
|
||||||
]
|
]
|
||||||
|
|
@ -3109,6 +3110,7 @@ dependencies = [
|
||||||
"combat",
|
"combat",
|
||||||
"combat_damagers",
|
"combat_damagers",
|
||||||
"inhabitant",
|
"inhabitant",
|
||||||
|
"resources",
|
||||||
"state",
|
"state",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
(
|
(
|
||||||
map: {
|
map: {
|
||||||
|
MouseButton(Middle): [
|
||||||
|
CameraOrbitEnable,
|
||||||
|
],
|
||||||
KeyCode(ShiftLeft): [
|
KeyCode(ShiftLeft): [
|
||||||
MultiPlaceTower,
|
MultiPlaceTower,
|
||||||
],
|
],
|
||||||
|
KeyCode(F1): [
|
||||||
|
ToggleDebugUI,
|
||||||
|
],
|
||||||
MouseButton(Right): [
|
MouseButton(Right): [
|
||||||
PlaceTower,
|
PlaceTower,
|
||||||
],
|
],
|
||||||
MouseButton(Left): [
|
|
||||||
CameraPanEnable,
|
|
||||||
],
|
|
||||||
MouseButton(Middle): [
|
|
||||||
CameraOrbitEnable,
|
|
||||||
],
|
|
||||||
MouseScroll: [
|
MouseScroll: [
|
||||||
CameraZoom,
|
CameraZoom,
|
||||||
],
|
],
|
||||||
KeyCode(F1): [
|
MouseButton(Left): [
|
||||||
ToggleDebugUI,
|
CameraPanEnable,
|
||||||
],
|
],
|
||||||
MouseMovementX: [
|
MouseMovementX: [
|
||||||
CameraYaw,
|
CameraYaw,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,27 @@ impl Plugin for CombatPlugin {
|
||||||
tick_invulnerability.in_set(GameSystemSet::StatusEffects),
|
tick_invulnerability.in_set(GameSystemSet::StatusEffects),
|
||||||
)
|
)
|
||||||
.register_type::<Team>()
|
.register_type::<Team>()
|
||||||
.register_type::<Health>();
|
.register_type::<Health>()
|
||||||
|
.insert_resource(Difficulty::Chill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub enum Difficulty {
|
||||||
|
Chill,
|
||||||
|
Casual,
|
||||||
|
Standard,
|
||||||
|
Intense,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Difficulty {
|
||||||
|
pub fn core_damage_taken_mult(&self) -> f32 {
|
||||||
|
match self {
|
||||||
|
Difficulty::Chill => 0.65,
|
||||||
|
Difficulty::Casual => 0.8,
|
||||||
|
Difficulty::Standard => 1.0,
|
||||||
|
Difficulty::Intense => 1.2,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,6 +184,7 @@ fn on_attack(
|
||||||
Without<Invulnerable>,
|
Without<Invulnerable>,
|
||||||
>,
|
>,
|
||||||
names: Query<&Name>,
|
names: Query<&Name>,
|
||||||
|
difficulty: Res<Difficulty>,
|
||||||
) {
|
) {
|
||||||
let Ok((mut health, invulnerability, opt_defense, opt_team)) =
|
let Ok((mut health, invulnerability, opt_defense, opt_team)) =
|
||||||
attacked_query.get_mut(trigger.target())
|
attacked_query.get_mut(trigger.target())
|
||||||
|
|
@ -177,7 +198,16 @@ fn on_attack(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let defense = opt_defense.cloned().unwrap_or_default();
|
let defense = opt_defense.cloned().unwrap_or_default();
|
||||||
let damage_taken = defense.calc_damage(trigger.event().amount);
|
let damage_amount = if matches!(opt_team, Some(Team::Core)) {
|
||||||
|
info!(
|
||||||
|
"reduced damage by {:?}",
|
||||||
|
difficulty.core_damage_taken_mult()
|
||||||
|
);
|
||||||
|
trigger.event().amount * difficulty.core_damage_taken_mult()
|
||||||
|
} else {
|
||||||
|
trigger.event().amount
|
||||||
|
};
|
||||||
|
let damage_taken = defense.calc_damage(damage_amount);
|
||||||
let old_health = health.current;
|
let old_health = health.current;
|
||||||
health.current = (old_health - damage_taken).max(0.0);
|
health.current = (old_health - damage_taken).max(0.0);
|
||||||
info!(
|
info!(
|
||||||
|
|
@ -220,7 +250,7 @@ fn on_die(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
) {
|
) {
|
||||||
if let Ok(drop) = drops.get(trigger.target()) {
|
if let Ok(drop) = drops.get(trigger.target()) {
|
||||||
resources.souls += drop.souls;
|
resources.0 = resources.0 + drop.0;
|
||||||
}
|
}
|
||||||
if let Ok(mut ec) = commands.get_entity(trigger.target()) {
|
if let Ok(mut ec) = commands.get_entity(trigger.target()) {
|
||||||
info!(
|
info!(
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ state = { path = "../state" }
|
||||||
combat = { path = "../combat" }
|
combat = { path = "../combat" }
|
||||||
building = { path = "../building" }
|
building = { path = "../building" }
|
||||||
inhabitant = { path = "../inhabitant" }
|
inhabitant = { path = "../inhabitant" }
|
||||||
|
resources = { path = "../resources" }
|
||||||
combat_damagers = { path = "../combat_damagers" }
|
combat_damagers = { path = "../combat_damagers" }
|
||||||
ui_health_bar = { path = "../ui_health_bar" }
|
ui_health_bar = { path = "../ui_health_bar" }
|
||||||
inhabitant_simbert = { path = "../inhabitant_simbert" }
|
inhabitant_simbert = { path = "../inhabitant_simbert" }
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use combat::{Defense, Health, Team};
|
||||||
use combat_damagers::ContactDamage;
|
use combat_damagers::ContactDamage;
|
||||||
use inhabitant::Inhabitant;
|
use inhabitant::Inhabitant;
|
||||||
use inhabitant_simbert::SpawnSimbert;
|
use inhabitant_simbert::SpawnSimbert;
|
||||||
|
use resources::{Drops, Quantity};
|
||||||
use state::{BasePhaseState, GameSystemSet};
|
use state::{BasePhaseState, GameSystemSet};
|
||||||
use ui_health_bar::BarSettings;
|
use ui_health_bar::BarSettings;
|
||||||
|
|
||||||
|
|
@ -83,6 +84,10 @@ fn spawn(
|
||||||
spawn_timer: Timer::from_seconds(2.0, TimerMode::Repeating),
|
spawn_timer: Timer::from_seconds(2.0, TimerMode::Repeating),
|
||||||
spawn_count: 10,
|
spawn_count: 10,
|
||||||
},
|
},
|
||||||
|
Drops(Quantity {
|
||||||
|
souls: 50,
|
||||||
|
bones: 25,
|
||||||
|
}),
|
||||||
transform.clone(),
|
transform.clone(),
|
||||||
Health::new(2000.0 + 100. * phase.get().phase_count() as f32),
|
Health::new(2000.0 + 100. * phase.get().phase_count() as f32),
|
||||||
Defense::new(5.),
|
Defense::new(5.),
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ state = { path = "../state" }
|
||||||
combat = { path = "../combat" }
|
combat = { path = "../combat" }
|
||||||
building = { path = "../building" }
|
building = { path = "../building" }
|
||||||
inhabitant = { path = "../inhabitant" }
|
inhabitant = { path = "../inhabitant" }
|
||||||
|
resources = { path = "../resources" }
|
||||||
combat_damagers = { path = "../combat_damagers" }
|
combat_damagers = { path = "../combat_damagers" }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use building::Building;
|
||||||
use combat::{GaveDamage, Health, Team};
|
use combat::{GaveDamage, Health, Team};
|
||||||
use combat_damagers::ContactDamage;
|
use combat_damagers::ContactDamage;
|
||||||
use inhabitant::Inhabitant;
|
use inhabitant::Inhabitant;
|
||||||
|
use resources::{Drops, Quantity};
|
||||||
use state::{BasePhaseState, GameSystemSet};
|
use state::{BasePhaseState, GameSystemSet};
|
||||||
|
|
||||||
pub struct InhabitantSimbertPlugin;
|
pub struct InhabitantSimbertPlugin;
|
||||||
|
|
@ -68,12 +69,13 @@ fn spawn(
|
||||||
res: Res<SimbertResources>,
|
res: Res<SimbertResources>,
|
||||||
) {
|
) {
|
||||||
for SpawnSimbert { transform, mega } in reader.read() {
|
for SpawnSimbert { transform, mega } in reader.read() {
|
||||||
let (health, damage, transform, material) = if *mega {
|
let (health, damage, transform, material, drops) = if *mega {
|
||||||
(
|
(
|
||||||
Health::new(5.0 + 1.5 * phase.get().phase_count() as f32),
|
Health::new(5.0 + 1.5 * phase.get().phase_count() as f32),
|
||||||
ContactDamage::new(6.0),
|
ContactDamage::new(6.0),
|
||||||
transform.with_scale(transform.scale * res.mega_scale),
|
transform.with_scale(transform.scale * res.mega_scale),
|
||||||
res.mega_material.clone(),
|
res.mega_material.clone(),
|
||||||
|
Drops(Quantity { souls: 3, bones: 0 }),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
|
|
@ -81,6 +83,7 @@ fn spawn(
|
||||||
ContactDamage::new(3.0),
|
ContactDamage::new(3.0),
|
||||||
transform.clone(),
|
transform.clone(),
|
||||||
res.material.clone(),
|
res.material.clone(),
|
||||||
|
Drops::default(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
commands
|
commands
|
||||||
|
|
@ -91,6 +94,7 @@ fn spawn(
|
||||||
MeshMaterial3d(material),
|
MeshMaterial3d(material),
|
||||||
MaxLinearSpeed(25.),
|
MaxLinearSpeed(25.),
|
||||||
Simbert,
|
Simbert,
|
||||||
|
drops,
|
||||||
transform,
|
transform,
|
||||||
health,
|
health,
|
||||||
damage,
|
damage,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use std::time::Duration;
|
||||||
use avian3d::{math::PI, prelude::*};
|
use avian3d::{math::PI, prelude::*};
|
||||||
use bevy::{
|
use bevy::{
|
||||||
core_pipeline::{bloom::Bloom, experimental::taa::TemporalAntiAliasing},
|
core_pipeline::{bloom::Bloom, experimental::taa::TemporalAntiAliasing},
|
||||||
math::VectorSpace,
|
|
||||||
pbr::{Atmosphere, ScreenSpaceAmbientOcclusion, light_consts::lux},
|
pbr::{Atmosphere, ScreenSpaceAmbientOcclusion, light_consts::lux},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::camera::Exposure,
|
render::camera::Exposure,
|
||||||
|
|
|
||||||
|
|
@ -108,13 +108,11 @@ impl std::ops::Sub<Quantity> for Quantity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Drops {
|
pub struct Drops(pub Quantity);
|
||||||
pub souls: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Drops {
|
impl Default for Drops {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { souls: 1 }
|
Self(Quantity { souls: 1, bones: 0 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue