From 8720727609f7a4d8ce647b6f410c7baffbb832ca Mon Sep 17 00:00:00 2001 From: 3002102 <3002102@stud.hs-mannheim.de> Date: Wed, 15 Apr 2026 18:19:32 +0200 Subject: [PATCH] add feature to wave logic for boss wave --- scripts/StageEntry.gd | 1 + scripts/spawn_control.gd | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/StageEntry.gd b/scripts/StageEntry.gd index 4ecffca..e6d7747 100644 --- a/scripts/StageEntry.gd +++ b/scripts/StageEntry.gd @@ -5,3 +5,4 @@ class_name StageEntry @export var count_at_start: int = 0 @export var count_at_end: int = 20 @export var min_interval: float = 0.3 +@export var max_spawns: int = -1 # -1 = unlimited diff --git a/scripts/spawn_control.gd b/scripts/spawn_control.gd index a9872c9..2f0330b 100644 --- a/scripts/spawn_control.gd +++ b/scripts/spawn_control.gd @@ -29,7 +29,7 @@ func _ready() -> void: for si in stages.size(): for ei in stages[si].entries.size(): - _state[Vector2i(si, ei)] = { "timer": 0.0, "alive": 0 } + _state[Vector2i(si, ei)] = { "timer": 0.0, "alive": 0, "spawned_total": 0 } func _load_stages(path: String) -> void: var file = FileAccess.open(path, FileAccess.READ) @@ -50,6 +50,7 @@ func _load_stages(path: String) -> void: entry.count_at_start = int(ed["count_at_start"]) entry.count_at_end = int(ed["count_at_end"]) entry.min_interval = float(ed["min_interval"]) + entry.max_spawns = int(ed.get("max_spawns", -1)) stage.entries.append(entry) stages.append(stage) @@ -94,6 +95,9 @@ func _process(delta: float) -> void: var entry: StageEntry = stage.entries[ei] var state: Dictionary = _state[Vector2i(si, ei)] + if entry.max_spawns != -1 and state["spawned_total"] >= entry.max_spawns: + continue + var target: int = roundi(lerpf(float(entry.count_at_start), float(entry.count_at_end), t)) var deficit: int = target - state["alive"] if deficit <= 0: @@ -108,5 +112,6 @@ func _spawn_one(entry: StageEntry, state: Dictionary) -> void: var enemy = entry.enemy.instantiate() enemy.global_position = get_spawn_position() state["alive"] += 1 + state["spawned_total"] += 1 enemy.tree_exited.connect(func(): state["alive"] -= 1) add_child(enemy) -- 2.43.0