add difficulty settings, increase drops
This commit is contained in:
parent
d35344f910
commit
dccd6d319e
9 changed files with 57 additions and 17 deletions
|
|
@ -24,7 +24,27 @@ impl Plugin for CombatPlugin {
|
|||
tick_invulnerability.in_set(GameSystemSet::StatusEffects),
|
||||
)
|
||||
.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>,
|
||||
>,
|
||||
names: Query<&Name>,
|
||||
difficulty: Res<Difficulty>,
|
||||
) {
|
||||
let Ok((mut health, invulnerability, opt_defense, opt_team)) =
|
||||
attacked_query.get_mut(trigger.target())
|
||||
|
|
@ -177,7 +198,16 @@ fn on_attack(
|
|||
return;
|
||||
}
|
||||
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;
|
||||
health.current = (old_health - damage_taken).max(0.0);
|
||||
info!(
|
||||
|
|
@ -220,7 +250,7 @@ fn on_die(
|
|||
mut commands: Commands,
|
||||
) {
|
||||
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()) {
|
||||
info!(
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ state = { path = "../state" }
|
|||
combat = { path = "../combat" }
|
||||
building = { path = "../building" }
|
||||
inhabitant = { path = "../inhabitant" }
|
||||
resources = { path = "../resources" }
|
||||
combat_damagers = { path = "../combat_damagers" }
|
||||
ui_health_bar = { path = "../ui_health_bar" }
|
||||
inhabitant_simbert = { path = "../inhabitant_simbert" }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use combat::{Defense, Health, Team};
|
|||
use combat_damagers::ContactDamage;
|
||||
use inhabitant::Inhabitant;
|
||||
use inhabitant_simbert::SpawnSimbert;
|
||||
use resources::{Drops, Quantity};
|
||||
use state::{BasePhaseState, GameSystemSet};
|
||||
use ui_health_bar::BarSettings;
|
||||
|
||||
|
|
@ -83,6 +84,10 @@ fn spawn(
|
|||
spawn_timer: Timer::from_seconds(2.0, TimerMode::Repeating),
|
||||
spawn_count: 10,
|
||||
},
|
||||
Drops(Quantity {
|
||||
souls: 50,
|
||||
bones: 25,
|
||||
}),
|
||||
transform.clone(),
|
||||
Health::new(2000.0 + 100. * phase.get().phase_count() as f32),
|
||||
Defense::new(5.),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ state = { path = "../state" }
|
|||
combat = { path = "../combat" }
|
||||
building = { path = "../building" }
|
||||
inhabitant = { path = "../inhabitant" }
|
||||
resources = { path = "../resources" }
|
||||
combat_damagers = { path = "../combat_damagers" }
|
||||
|
||||
[lints]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use building::Building;
|
|||
use combat::{GaveDamage, Health, Team};
|
||||
use combat_damagers::ContactDamage;
|
||||
use inhabitant::Inhabitant;
|
||||
use resources::{Drops, Quantity};
|
||||
use state::{BasePhaseState, GameSystemSet};
|
||||
|
||||
pub struct InhabitantSimbertPlugin;
|
||||
|
|
@ -68,12 +69,13 @@ fn spawn(
|
|||
res: Res<SimbertResources>,
|
||||
) {
|
||||
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),
|
||||
ContactDamage::new(6.0),
|
||||
transform.with_scale(transform.scale * res.mega_scale),
|
||||
res.mega_material.clone(),
|
||||
Drops(Quantity { souls: 3, bones: 0 }),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
|
|
@ -81,6 +83,7 @@ fn spawn(
|
|||
ContactDamage::new(3.0),
|
||||
transform.clone(),
|
||||
res.material.clone(),
|
||||
Drops::default(),
|
||||
)
|
||||
};
|
||||
commands
|
||||
|
|
@ -91,6 +94,7 @@ fn spawn(
|
|||
MeshMaterial3d(material),
|
||||
MaxLinearSpeed(25.),
|
||||
Simbert,
|
||||
drops,
|
||||
transform,
|
||||
health,
|
||||
damage,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::time::Duration;
|
|||
use avian3d::{math::PI, prelude::*};
|
||||
use bevy::{
|
||||
core_pipeline::{bloom::Bloom, experimental::taa::TemporalAntiAliasing},
|
||||
math::VectorSpace,
|
||||
pbr::{Atmosphere, ScreenSpaceAmbientOcclusion, light_consts::lux},
|
||||
prelude::*,
|
||||
render::camera::Exposure,
|
||||
|
|
|
|||
|
|
@ -108,13 +108,11 @@ impl std::ops::Sub<Quantity> for Quantity {
|
|||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Drops {
|
||||
pub souls: u32,
|
||||
}
|
||||
pub struct Drops(pub Quantity);
|
||||
|
||||
impl Default for Drops {
|
||||
fn default() -> Self {
|
||||
Self { souls: 1 }
|
||||
Self(Quantity { souls: 1, bones: 0 })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue