34 lines
638 B
GDScript
34 lines
638 B
GDScript
class_name Boss
|
|
extends Node2D
|
|
|
|
|
|
signal damaged(damage: int)
|
|
signal defeated()
|
|
|
|
|
|
@export var first_phase: BossPhase
|
|
|
|
|
|
var current_phase: BossPhase
|
|
|
|
|
|
func _ready() -> void:
|
|
if first_phase:
|
|
current_phase = first_phase
|
|
current_phase.ended.connect(_on_phase_ended, CONNECT_ONE_SHOT)
|
|
first_phase.start_phase()
|
|
|
|
|
|
func hurt(damage: int = 1) -> void:
|
|
if current_phase:
|
|
CurrentGame.change_score(100)
|
|
current_phase.hurt(damage)
|
|
damaged.emit(damage)
|
|
|
|
|
|
func _on_phase_ended() -> void:
|
|
current_phase = current_phase.next_phase
|
|
if current_phase:
|
|
current_phase.ended.connect(_on_phase_ended, CONNECT_ONE_SHOT)
|
|
else:
|
|
defeated.emit()
|