diff --git a/Scenes/Creeps/Creep.gd b/Scenes/Creeps/Creep.gd index 24573db9a..6925bfcb5 100644 --- a/Scenes/Creeps/Creep.gd +++ b/Scenes/Creeps/Creep.gd @@ -5,6 +5,7 @@ extends Unit # TODO: implement armor signal moved(delta) +signal reached_portal(damage_to_portal) # NOTE: order is important to be able to compare @@ -99,6 +100,10 @@ func adjust_height(height: float, speed: float): Vector2(_visual.position.x, _visual.position.y - height), duration).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT) +func reach_portal(): + var damage_to_portal = get_damage_to_portal() + reached_portal.emit(damage_to_portal) + queue_free() ######################### ### Private ### @@ -222,3 +227,7 @@ func get_display_name() -> String: func set_path(path: Path2D): _path = path position = path.get_curve().get_point_position(0) + path.position + +func get_damage_to_portal(): + # TODO: Implement formula + return 1 diff --git a/Scenes/Creeps/CreepSpawner.gd b/Scenes/Creeps/CreepSpawner.gd index eb4ed48ad..4b3fa9ff9 100644 --- a/Scenes/Creeps/CreepSpawner.gd +++ b/Scenes/Creeps/CreepSpawner.gd @@ -89,6 +89,7 @@ func generate_creep_for_wave(wave: Wave, creep_size) -> Creep: creep.set_category(wave.get_race()) creep.set_base_health(wave.get_base_hp()) creep.death.connect(Callable(wave, "_on_Creep_death")) + creep.reached_portal.connect(Callable(wave, "_on_Creep_reached_portal").bind(creep)) return creep diff --git a/Scenes/Creeps/Wave.gd b/Scenes/Creeps/Wave.gd index 19b159300..1715829fd 100644 --- a/Scenes/Creeps/Wave.gd +++ b/Scenes/Creeps/Wave.gd @@ -63,8 +63,13 @@ func _process(_delta): ######################### func _on_Creep_death(event): + print_debug("Creep [%s] has died." % event.get_target()) _creeps.erase(event.get_target()) +func _on_Creep_reached_portal(damage, creep: Creep): + print_debug("Creep [%s] reached portal. Damage to portal: %s" % [creep, damage]) + _creeps.erase(creep) + ######################### ### Setters / Getters ### diff --git a/Scenes/GameScene.gd b/Scenes/GameScene.gd index daff4178f..f209ba3f7 100644 --- a/Scenes/GameScene.gd +++ b/Scenes/GameScene.gd @@ -18,7 +18,7 @@ func _on_HUD_stop_wave(): func _on_CreepExit_body_entered(body): if body is Creep: - body.queue_free() + body.reach_portal() func _on_CreepSpawner_wave_ended(_wave_index: int):