added wave viewer which required adding determinism to wave generation

This commit is contained in:
2025-11-06 22:16:59 +11:00
parent 19b5589b27
commit 3cb37faf4b
38 changed files with 438 additions and 312 deletions

View File

@@ -7,9 +7,17 @@ extends Control
const CELL_HEALTH: int = 9
var fading_enabled: bool = true
var health: int = 144
var current_cell_health: int = CELL_HEALTH
var fade_tween: Tween
var cell_tweens: Array[Tween] = []
func _ready() -> void:
for x: int in cells.size():
cell_tweens.append(null)
fade_timer.start()
func take_damage(damage: int) -> void:
@@ -24,6 +32,8 @@ func take_damage(damage: int) -> void:
current_cell_health -= damage_to_deal_with
var cell_level: int = health % 9
if remaining_damage > 0: ## This cell should be empty because the damage overran the cell
if cell_tweens[current_cell - 1]:
cell_tweens[current_cell - 1].kill()
cell_level = 3
current_cell_health = CELL_HEALTH
change_cell_color(current_cell - 1, cell_level)
@@ -39,24 +49,29 @@ func take_damage(damage: int) -> void:
else: ## This cell should be full health
cell_level = 0
hit_glow.texture.region.position.x = 66.0 * (16 - current_cell)
var tween: Tween = create_tween()
tween.tween_callback(func() -> void: hit_glow.visible = true)
tween.tween_interval(0.07)
tween.tween_callback(func() -> void: hit_glow.visible = false)
tween.tween_interval(0.07)
tween.tween_callback(func() -> void: hit_glow.visible = true)
tween.tween_callback(change_cell_color.bind(current_cell - 1, cell_level))
tween.tween_interval(0.07)
tween.tween_callback(func() -> void: hit_glow.visible = false)
if cell_tweens[current_cell - 1]:
cell_tweens[current_cell - 1].kill()
cell_tweens[current_cell - 1] = create_tween()
cell_tweens[current_cell - 1].tween_callback(func() -> void: hit_glow.visible = true)
cell_tweens[current_cell - 1].tween_interval(0.07)
cell_tweens[current_cell - 1].tween_callback(func() -> void: hit_glow.visible = false)
cell_tweens[current_cell - 1].tween_interval(0.07)
cell_tweens[current_cell - 1].tween_callback(func() -> void: hit_glow.visible = true)
cell_tweens[current_cell - 1].tween_callback(change_cell_color.bind(current_cell - 1, cell_level))
cell_tweens[current_cell - 1].tween_interval(0.07)
cell_tweens[current_cell - 1].tween_callback(func() -> void: hit_glow.visible = false)
fade_timer.start()
func change_cell_color(cell: int, color: int) -> void:
cells[15 - cell].texture.region.position.x = 66.0 * color
var cell_to_change: int = 15 - cell
if cell_to_change >= 0 and cell_to_change < cells.size():
cells[15 - cell].texture.region.position.x = 66.0 * color
func fade_out() -> void:
if fade_tween:
fade_tween.kill()
fade_tween = create_tween()
fade_tween.tween_property(self, "modulate", Color8(255, 255, 255, 0), 1.0)
if fading_enabled:
fade_tween = create_tween()
fade_tween.tween_property(self, "modulate", Color8(255, 255, 255, 0), 1.0)

View File

@@ -74,7 +74,6 @@ atlas = ExtResource("4_yanml")
region = Rect2(0, 0, 66, 66)
[node name="ShieldUI" type="Control" node_paths=PackedStringArray("cells", "hit_glow", "fade_timer")]
modulate = Color(1, 1, 1, 0)
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_aa64g")