extends Area2D var hp: int = 6 : set(value): hp = value Game.boss_hp_changed.emit(hp) func _ready() -> void: Game.boss_initialized.emit(hp) func _process(_delta: float) -> void: # TODO: spawn apples # TODO: blow wind pass func blow_wind(): $BlinkTimer.paused = true for i in range(3): $Mouth.play("mouth_shoot") var shot = preload("res://air_shot.tscn").instantiate() as Area2D shot.global_position = $Mouth.global_position + Vector2(0, randi() % 8) shot.direction = -1 shot.collision_layer = 0 shot.set_collision_layer_value(2, true) shot.set_collision_layer_value(10, true) shot.collision_mask = 0 shot.set_collision_mask_value(1, true) shot.add_to_group("enemy") get_tree().current_scene.add_child(shot) shot.hit.connect(func(_node): if is_instance_valid(shot): shot.queue_free() ) shot.end_of_life.connect(func(): await get_tree().create_timer(0.2).timeout if is_instance_valid(shot): shot.queue_free() ) await get_tree().create_timer(0.25).timeout $Mouth.play("hole_idle") await get_tree().create_timer(0.25).timeout $BlinkTimer.paused = false func hit_by_projectile(hit_position: Vector2): var effect_star_scene := preload("res://effect_star.tscn") for direction in [Vector2(1, 1), Vector2(1, -1), Vector2(-1, -1), Vector2(-1, 1)]: var effect_star := effect_star_scene.instantiate() effect_star.global_position = hit_position get_tree().current_scene.add_child(effect_star) var effect_tween := get_tree().create_tween() effect_tween.tween_property( effect_star, "global_position", effect_star.global_position + direction * 16, 0.1 ) effect_tween.tween_callback(func(): effect_star.queue_free() ) SoundManager.play_sound("Hurt") hp -= 1 $EyeLeft.play("eye_closed") $EyeRight.play("eye_closed") $Tear.visible = true var tween = get_tree().create_tween() tween.tween_property(self, "modulate", Color(1, 1, 1, 0.2), 0.1) tween.tween_property(self, "modulate", Color(1, 1, 1, 0.8), 0.1) tween.tween_property(self, "modulate", Color(1, 1, 1, 0.2), 0.1) tween.tween_property(self, "modulate", Color(1, 1, 1, 0.8), 0.1) if hp > 0: tween.tween_callback(func(): modulate = Color(1, 1, 1, 1.0) $EyeLeft.play("hole_idle") $EyeRight.play("hole_idle") $Tear.visible = false ) elif hp <= 0: Game.boss_defeated.emit() func _on_blink_timer_timeout() -> void: $EyeLeft.play("blink") $EyeRight.play("blink") await $EyeRight.animation_finished $EyeLeft.play("hole_idle") $EyeRight.play("hole_idle") blow_wind()