item scaling with time

This commit is contained in:
Andrei Stoica 2024-11-21 12:12:05 -05:00
parent e130f91f39
commit d0a788ae59
2 changed files with 6 additions and 6 deletions

View File

@ -41,7 +41,7 @@ impl PlayerStats {
} }
pub fn get_current_price(object: &PurchasableObject, num_owned: &u32) -> f64 { pub fn get_current_price(object: &PurchasableObject, num_owned: &u32) -> f64 {
get_base_price(object) * get_scaling_factor(object) * f64::from(*num_owned) get_base_price(object) * (1.0 + get_scaling_factor(object) * f64::from(*num_owned))
} }
pub fn get_base_price(object: &PurchasableObject) -> f64 { pub fn get_base_price(object: &PurchasableObject) -> f64 {
@ -54,9 +54,9 @@ pub fn get_base_price(object: &PurchasableObject) -> f64 {
pub fn get_scaling_factor(object: &PurchasableObject) -> f64 { pub fn get_scaling_factor(object: &PurchasableObject) -> f64 {
match object { match object {
PurchasableObject::Cookie => 1.10, PurchasableObject::Cookie => 0.10,
PurchasableObject::Cursor => 1.15, PurchasableObject::Cursor => 0.15,
PurchasableObject::Grandma => 1.20, PurchasableObject::Grandma => 0.20,
} }
} }

View File

@ -20,11 +20,11 @@ fn setup(mut commands: Commands) {
}); });
} }
fn get_cash(inv: Query<&Purchased>, mut stats: Query<&mut PlayerStats>) { fn get_cash(time: Res<Time>, inv: Query<&Purchased>, mut stats: Query<&mut PlayerStats>) {
let mut new_cash: f64 = 0.; let mut new_cash: f64 = 0.;
for Purchased { object, count } in &inv { for Purchased { object, count } in &inv {
new_cash += get_base_returns(&object) * f64::from(*count); new_cash += get_base_returns(&object) * f64::from(*count) * f64::from(time.delta_seconds());
} }
stats.single_mut().money += new_cash; stats.single_mut().money += new_cash;