the boss!

This commit is contained in:
Haze Weathers 2026-01-03 12:34:28 -06:00
parent 1e618d8cd4
commit abd45d7d64
14 changed files with 445 additions and 2 deletions

34
systems/boss/boss.gd Normal file
View file

@ -0,0 +1,34 @@
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()

1
systems/boss/boss.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://b6ae108uhk7hk

View file

@ -0,0 +1,62 @@
class_name BossPhase
extends Node
signal started()
signal ended()
signal damaged(damage: int)
## Amount of HP this boss stage has. If 0, the boss is invulnerable during
## this phase and must survive until time runs out or [method end_phase] is called.
@export_range(0, 1, 1, "or_greater") var hp: int = 0
## "Survival Time" of the phase. The phase will end when time is up, whether
## HP has been depleted or not.
@export_range(0.0, 1.0, 0.01, "or_greater", "suffix:s") var time: float = INF
## The phase to automatically proceed to when this phase ends.
@export var next_phase: BossPhase
## [code]true[/code] if the phase is currently active.
var active: bool = false
var hp_left: int:
set(value):
hp_left = value
if active and hp_left <= 0 and hp > 0:
end_phase()
var time_left: float = INF:
set(value):
time_left = value
if active and time_left <= 0.0:
end_phase()
func _physics_process(delta: float) -> void:
if active:
time_left -= delta
func start_phase() -> void:
if not active:
hp_left = hp
time_left = time
active = true
started.emit()
func end_phase() -> void:
if active:
active = false
ended.emit()
if next_phase:
next_phase.start_phase()
func hurt(damage: int) -> void:
if active:
hp_left = maxi(0, hp_left - damage)
damaged.emit(damage)

View file

@ -0,0 +1 @@
uid://nyslrh651s8u

View file

@ -0,0 +1,19 @@
class_name DanmakuEmitter
extends Node2D
@export var spawn_parent: Node2D
@export var preset: BulletPreset
func spawn_preset() -> void:
var bullet_set = BulletSet.new()
bullet_set.preset = preset
bullet_set.global_position = global_position
bullet_set.global_rotation = global_rotation
spawn_parent.add_child(bullet_set)
func clear_bullets() -> void:
for child in spawn_parent.get_children():
child.queue_free()

View file

@ -0,0 +1 @@
uid://df8w64703kw0c