From 6cea0e97e9269e26b3bf9ab08f220ad99003951f Mon Sep 17 00:00:00 2001 From: Jim Date: Tue, 2 Sep 2025 16:08:55 -0400 Subject: [PATCH] add impaler upgrades --- Cargo.lock | 1 + assets/settings/input_map.ron | 8 +-- crates/building_impaler/Cargo.toml | 1 + crates/building_impaler/src/lib.rs | 85 +++++++++++++++++++++++++++++- todo.txt | 4 +- 5 files changed, 92 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e16425..d18057c 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -1671,6 +1671,7 @@ dependencies = [ "combat_damagers", "resources", "state", + "upgrade", ] [[package]] diff --git a/assets/settings/input_map.ron b/assets/settings/input_map.ron index ed21f50..03d50a5 100755 --- a/assets/settings/input_map.ron +++ b/assets/settings/input_map.ron @@ -1,7 +1,7 @@ ( map: { - MouseButton(Middle): [ - CameraOrbitEnable, + KeyCode(ShiftLeft): [ + MultiPlaceTower, ], MouseButton(Right): [ PlaceTower, @@ -9,8 +9,8 @@ MouseButton(Left): [ CameraPanEnable, ], - KeyCode(ShiftLeft): [ - MultiPlaceTower, + MouseButton(Middle): [ + CameraOrbitEnable, ], MouseScroll: [ CameraZoom, diff --git a/crates/building_impaler/Cargo.toml b/crates/building_impaler/Cargo.toml index 41c8a71..fbe8565 100755 --- a/crates/building_impaler/Cargo.toml +++ b/crates/building_impaler/Cargo.toml @@ -11,6 +11,7 @@ combat = { path = "../combat" } building = { path = "../building" } resources = { path = "../resources" } combat_damagers = { path = "../combat_damagers" } +upgrade = { path = "../upgrade" } [lints] workspace = true diff --git a/crates/building_impaler/src/lib.rs b/crates/building_impaler/src/lib.rs index 9b70611..3c85b9b 100755 --- a/crates/building_impaler/src/lib.rs +++ b/crates/building_impaler/src/lib.rs @@ -4,9 +4,10 @@ use bevy::prelude::*; use building::{BuildingInfo, BuildingPreview, PREVIEW_ALPHA, PopulatePlacedBuilding}; -use combat::Health; +use combat::{Defense, Health}; use combat_damagers::ContactDamage; use resources::{Cost, Quantity}; +use upgrade::{Upgrade, UpgradeApplied, UpgradeTree}; pub struct BuildingImpalerPlugin; @@ -48,6 +49,87 @@ fn register( }); let info = commands.spawn_empty().id(); + let tier3 = vec![ + commands + .spawn(( + Name::new("become mega"), + Upgrade { + description: "i will be mega :o".to_string(), + cost: Quantity { + souls: 250, + bones: 50, + }, + unlocks: vec![], + }, + )) + .observe( + |trigger: Trigger, + mut query: Query<(&mut Transform, &mut Health)>| { + if let Ok((mut tf, mut health)) = query.get_mut(trigger.event().building) { + tf.scale *= 2.; + tf.translation.y += 1.5; + *health = Health::new(health.max * 3.); + } + }, + ) + .id(), + ]; + let tier2 = vec![ + commands + .spawn(( + Name::new("grow some more"), + Upgrade { + description: "i grow some more :)".to_string(), + cost: Quantity { + souls: 50, + bones: 10, + }, + unlocks: tier3, + }, + )) + .observe( + |trigger: Trigger, + mut query: Query<(&mut Transform, &mut Health, &mut Defense)>| { + if let Ok((mut tf, mut health, mut defense)) = + query.get_mut(trigger.event().building) + { + tf.scale *= 2.; + tf.translation.y += 0.75; + defense.amount += 3.; + *health = Health::new(health.max * 2.); + } + }, + ) + .id(), + ]; + let upgrades = vec![ + commands + .spawn(( + Name::new("grow"), + Upgrade { + description: "i grow".to_string(), + cost: Quantity { + souls: 10, + bones: 5, + }, + unlocks: tier2, + }, + )) + .observe( + |trigger: Trigger, + mut query: Query<(&mut Transform, &mut Health, &mut Defense)>| { + if let Ok((mut tf, mut health, mut defense)) = + query.get_mut(trigger.event().building) + { + tf.scale *= 1.5; + tf.translation.y += 0.25; + defense.amount += 2.; + *health = Health::new(health.max * 2.); + } + }, + ) + .id(), + ]; let preview = commands .spawn(( BuildingPreview { info }, @@ -62,6 +144,7 @@ fn register( size: SIZE, unlocked: true, }, + UpgradeTree { upgrades }, Cost(Quantity { souls: 5, bones: 0 }), Health::new(20.0), Name::new("Impaler"), diff --git a/todo.txt b/todo.txt index 9a3cc61..feaeb12 100644 --- a/todo.txt +++ b/todo.txt @@ -8,8 +8,8 @@ x improve enemy AI - balance --- IMPORTANT --- -- More towers -- More upgrades +x More towers +x More upgrades x More enemy types x More resource deposit types - Improve wave generation