item scaling with time
This commit is contained in:
parent
e130f91f39
commit
d0a788ae59
|
|
@ -41,7 +41,7 @@ impl PlayerStats {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
@ -54,9 +54,9 @@ pub fn get_base_price(object: &PurchasableObject) -> f64 {
|
|||
|
||||
pub fn get_scaling_factor(object: &PurchasableObject) -> f64 {
|
||||
match object {
|
||||
PurchasableObject::Cookie => 1.10,
|
||||
PurchasableObject::Cursor => 1.15,
|
||||
PurchasableObject::Grandma => 1.20,
|
||||
PurchasableObject::Cookie => 0.10,
|
||||
PurchasableObject::Cursor => 0.15,
|
||||
PurchasableObject::Grandma => 0.20,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.;
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue