feat: refactoring score calculation
This commit is contained in:
parent
b71342d4c7
commit
51cc90b1e4
5 changed files with 8 additions and 7 deletions
|
|
@ -16,5 +16,5 @@ void DestructableObject::damaged(int level) {
|
|||
get_tree()->get_current_scene()->add_child(instance);
|
||||
}
|
||||
get_owner()->queue_free();
|
||||
LevelStatus::get_instance()->notify_object_destroyed(this->point_value * level);
|
||||
LevelStatus::get_instance()->notify_object_destroyed(get_defense());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ protected:
|
|||
|
||||
private:
|
||||
Ref<PackedScene> destroyed_object{};
|
||||
int point_value{ 10 };
|
||||
|
||||
public:
|
||||
GET_SET_FNS(Ref<PackedScene>, destroyed_object);
|
||||
GET_SET_FNS(int, point_value);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ void LevelStatus::_notification(int what) {
|
|||
}
|
||||
|
||||
void LevelStatus::notify_object_destroyed(int value) {
|
||||
double style_value{ 1 + (this->max_time_between > this->time_since_last ? this->max_time_between - this->time_since_last : 0.0) };
|
||||
this->style += this->base_style_per_object * style_value;
|
||||
this->score += value * (1 + this->style);
|
||||
double style_value{ 1 + (this->max_time_between > this->time_since_last ? (this->max_time_between - this->time_since_last) : 0.0) };
|
||||
this->time_since_last = 0.0;
|
||||
this->style += this->base_style_per_object * style_value * this->max_style_mult;
|
||||
this->score += value * (1 + this->style) * style_value * this->max_score_mult;
|
||||
emit_signal(sig_object_destroyed, this->style, this->score);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ private:
|
|||
int score{};
|
||||
double base_style_per_object{ 0.25 };
|
||||
double time_since_last{ Math::INF };
|
||||
int max_score_mult{ 5 };
|
||||
int max_style_mult{ 1 };
|
||||
double max_time_between{ 1.f };
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func _ready():
|
|||
on_object_destroyed(0, 0)
|
||||
|
||||
func on_object_destroyed(_style, score):
|
||||
text = \"%d\" % score
|
||||
text = \"%d\" % (score * 10)
|
||||
"
|
||||
|
||||
[node name="HUD" type="Control"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue