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

@@ -1,20 +1,27 @@
class_name EnemyBox
extends HBoxContainer
class_name EnemyRow
extends VBoxContainer
@export var wave_label: Label
@export var enemy_hbox: HBoxContainer
func set_wave(wave: int) -> void:
$WaveLabel.text = tr("LABEL_WAVE").format({Wave_Number = str(wave)})
wave_label.text = tr("LABEL_WAVE").format({Wave_Number = str(wave)})
func add_enemy_tag(enemy: Enemy, num: int) -> void:
for x: int in num:
var enemy_tex: TextureRect = TextureRect.new()
enemy_tex.texture = enemy.sprite
enemy_tex.custom_minimum_size = Vector2(80, 80)
add_child(enemy_tex)
#var name_label: Label = Label.new()
#name_label.text = enemy.title
#var num_label: Label = Label.new()
#num_label.text = str(num)
#add_child(name_label)
#add_child(num_label)
var container: MarginContainer = MarginContainer.new()
enemy_hbox.add_child(container)
var enemy_tex: TextureRect = TextureRect.new()
enemy_tex.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
enemy_tex.texture = enemy.icon
enemy_tex.custom_minimum_size = Vector2(32, 32)
enemy_tex.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
container.add_child(enemy_tex)
var amount_label: Label = Label.new()
amount_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
amount_label.size_flags_vertical = Control.SIZE_EXPAND_FILL
amount_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
amount_label.vertical_alignment = VERTICAL_ALIGNMENT_BOTTOM
amount_label.text = str(num)
container.add_child(amount_label)

View File

@@ -2,9 +2,19 @@
[ext_resource type="Script" uid="uid://b0h5oewxd48lv" path="res://UI/Menus/GameEndScreen/enemy_row.gd" id="1_th4b3"]
[node name="EnemyRow" type="HBoxContainer"]
[node name="EnemyRow" type="VBoxContainer" node_paths=PackedStringArray("wave_label", "enemy_hbox")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_th4b3")
wave_label = NodePath("WaveLabel")
enemy_hbox = NodePath("Enemies")
[node name="WaveLabel" type="Label" parent="."]
layout_mode = 2
text = "LABEL_WAVE"
[node name="Enemies" type="HBoxContainer" parent="."]
layout_mode = 2

View File

@@ -23,7 +23,7 @@ func _ready() -> void:
func set_wave() -> void:
for wave_key: int in game_manager.stats.enemies_undefeated:
var spawned_box: EnemyBox = box.instantiate() as EnemyBox
var spawned_box: EnemyRow = box.instantiate() as EnemyRow
undefeated_enemies.add_child(spawned_box)
spawned_box.set_wave(wave_key)
for enemy_key: Enemy in game_manager.stats.enemies_undefeated[wave_key]:

View File

@@ -10,13 +10,11 @@ streams_count = 1
stream_0/stream = ExtResource("3_ro1yg")
[node name="GameEndScreen" type="PanelContainer" node_paths=PackedStringArray("outcome_label", "winrate_label", "total_games_label", "total_wins_label", "total_losses_label", "undefeated_enemies")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 150.0
offset_top = 100.0
offset_right = -150.0
offset_bottom = -100.0
anchors_preset = -1
anchor_left = 0.05
anchor_top = 0.05
anchor_right = 0.95
anchor_bottom = 0.95
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_oa7nq")
@@ -26,14 +24,13 @@ winrate_label = NodePath("VBoxContainer/Labels/VBoxContainer/HBoxContainer/WinRa
total_games_label = NodePath("VBoxContainer/Labels/VBoxContainer/HBoxContainer2/WinRateLabel3")
total_wins_label = NodePath("VBoxContainer/Labels/VBoxContainer/HBoxContainer3/WinRateLabel4")
total_losses_label = NodePath("VBoxContainer/Labels/VBoxContainer/HBoxContainer4/WinRateLabel5")
undefeated_enemies = NodePath("VBoxContainer/UndefeatedEnemies")
undefeated_enemies = NodePath("VBoxContainer/ScrollContainer/UndefeatedEnemies")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
[node name="Labels" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
alignment = 1
[node name="OutcomeLabel" type="Label" parent="VBoxContainer/Labels"]
@@ -114,7 +111,11 @@ text = "0"
horizontal_alignment = 2
vertical_alignment = 1
[node name="UndefeatedEnemies" type="VBoxContainer" parent="VBoxContainer"]
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="UndefeatedEnemies" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
layout_mode = 2
size_flags_vertical = 3

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")

View File

@@ -0,0 +1,7 @@
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://c1xm8bkvho3vl"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_466t2"]
[resource]
atlas = ExtResource("1_466t2")
region = Rect2(79, 1, 8, 8)

View File

@@ -0,0 +1,7 @@
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://cuwhoitu6ybba"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_74qo4"]
[resource]
atlas = ExtResource("1_74qo4")
region = Rect2(62, 1, 8, 8)

View File

@@ -0,0 +1,15 @@
[gd_resource type="StyleBoxTexture" load_steps=3 format=3 uid="uid://duopp63rij323"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_73g4w"]
[sub_resource type="AtlasTexture" id="AtlasTexture_okcqu"]
atlas = ExtResource("1_73g4w")
region = Rect2(62, 10, 8, 8)
[resource]
texture = SubResource("AtlasTexture_okcqu")
texture_margin_left = 2.0
texture_margin_top = 4.0
texture_margin_right = 2.0
texture_margin_bottom = 4.0
region_rect = Rect2(0, 0, 8, 8)

View File

@@ -0,0 +1,15 @@
[gd_resource type="StyleBoxTexture" load_steps=3 format=3 uid="uid://dlnw55uearhrg"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_xum1s"]
[sub_resource type="AtlasTexture" id="AtlasTexture_noue1"]
atlas = ExtResource("1_xum1s")
region = Rect2(62, 1, 8, 8)
[resource]
texture = SubResource("AtlasTexture_noue1")
texture_margin_left = 2.0
texture_margin_right = 2.0
expand_margin_left = 2.0
expand_margin_right = 2.0
region_rect = Rect2(0, 0, 8, 8)

View File

@@ -0,0 +1,14 @@
[gd_resource type="StyleBoxTexture" load_steps=3 format=3 uid="uid://co6ouoi7ieawj"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_slo62"]
[sub_resource type="AtlasTexture" id="AtlasTexture_xobyj"]
atlas = ExtResource("1_slo62")
region = Rect2(10, 10, 9, 9)
[resource]
texture = SubResource("AtlasTexture_xobyj")
texture_margin_left = 3.0
texture_margin_top = 3.0
texture_margin_right = 3.0
texture_margin_bottom = 3.0

View File

@@ -1,4 +1,4 @@
[gd_resource type="Theme" load_steps=36 format=3 uid="uid://jn4qqx5hxc5i"]
[gd_resource type="Theme" load_steps=42 format=3 uid="uid://jn4qqx5hxc5i"]
[ext_resource type="StyleBox" uid="uid://doxcjij1w2ot7" path="res://UI/Themes/Scale1/button_disabled.tres" id="1_ts3pc"]
[ext_resource type="StyleBox" uid="uid://buu2yn08s4wc7" path="res://UI/Themes/Scale1/button_focus.tres" id="1_vnhdr"]
@@ -10,9 +10,16 @@
[ext_resource type="StyleBox" uid="uid://bfuea1sjymo8g" path="res://UI/Themes/Scale1/pane_style_box.tres" id="6_w151p"]
[ext_resource type="StyleBox" uid="uid://jnnnhb3i2265" path="res://UI/Themes/Scale1/switch_side_b_style_box.tres" id="7_w8nmj"]
[ext_resource type="StyleBox" uid="uid://cm3wsvk3woory" path="res://UI/Themes/Scale1/switch_side_a_style_box.tres" id="8_8j1wx"]
[ext_resource type="StyleBox" uid="uid://dlnw55uearhrg" path="res://UI/Themes/Scale1/h_scroll_grabber.tres" id="8_b5n6m"]
[ext_resource type="StyleBox" uid="uid://bss3dp7k18rx0" path="res://UI/Themes/Scale1/grabber_area.tres" id="8_o6p3e"]
[ext_resource type="Texture2D" uid="uid://cuwhoitu6ybba" path="res://UI/Themes/Scale1/grabber_tex.tres" id="8_t2hcr"]
[ext_resource type="Texture2D" uid="uid://c1xm8bkvho3vl" path="res://UI/Themes/Scale1/grabber_disabled_tex.tres" id="9_n5i54"]
[ext_resource type="StyleBox" uid="uid://bpowvv8e13flg" path="res://UI/Themes/Scale1/slider.tres" id="9_w151p"]
[ext_resource type="StyleBox" uid="uid://8s0fgx46n145" path="res://UI/Themes/Scale1/scroll_grabber.tres" id="13_w151p"]
[ext_resource type="StyleBox" uid="uid://duopp63rij323" path="res://UI/Themes/Scale1/h_scroll_bar.tres" id="9_xqncf"]
[ext_resource type="Texture2D" uid="uid://d3bbst30pgfgy" path="res://UI/Themes/Scale1/slider_tick_tex.tres" id="10_08ul3"]
[ext_resource type="StyleBox" uid="uid://co6ouoi7ieawj" path="res://UI/Themes/Scale1/popup_item_hover.tres" id="16_xqncf"]
[ext_resource type="StyleBox" uid="uid://8s0fgx46n145" path="res://UI/Themes/Scale1/v_scroll_grabber.tres" id="18_nis8m"]
[ext_resource type="StyleBox" uid="uid://c4cljq7yl78eg" path="res://UI/Themes/Scale1/v_scroll_bar.tres" id="19_aggbr"]
[sub_resource type="AtlasTexture" id="AtlasTexture_845oj"]
atlas = ExtResource("6_43i8g")
@@ -26,27 +33,35 @@ region = Rect2(46, 1, 15, 8)
base_font = ExtResource("5_o6p3e")
baseline_offset = 0.15
[sub_resource type="AtlasTexture" id="AtlasTexture_w8nmj"]
atlas = ExtResource("6_43i8g")
region = Rect2(62, 1, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_t2hcr"]
atlas = ExtResource("6_43i8g")
region = Rect2(79, 1, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_8j1wx"]
atlas = ExtResource("6_43i8g")
region = Rect2(62, 1, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_w151p"]
atlas = ExtResource("6_43i8g")
region = Rect2(75, 4, 2, 2)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_t2hcr"]
[sub_resource type="AtlasTexture" id="AtlasTexture_noue1"]
atlas = ExtResource("6_43i8g")
region = Rect2(98, 4, 8, 5)
[sub_resource type="FontVariation" id="FontVariation_inyly"]
base_font = ExtResource("5_o6p3e")
[sub_resource type="AtlasTexture" id="AtlasTexture_k1p2l"]
atlas = ExtResource("6_43i8g")
region = Rect2(62, 1, 8, 8)
[sub_resource type="AtlasTexture" id="AtlasTexture_qa24s"]
atlas = ExtResource("6_43i8g")
region = Rect2(62, 10, 8, 8)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xqncf"]
content_margin_left = 2.0
content_margin_top = 2.0
content_margin_right = 2.0
content_margin_bottom = 2.0
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_nis8m"]
content_margin_left = 2.0
content_margin_top = 2.0
content_margin_right = 2.0
content_margin_bottom = 2.0
[sub_resource type="AtlasTexture" id="AtlasTexture_n5i54"]
atlas = ExtResource("6_43i8g")
region = Rect2(98, 4, 8, 5)
@@ -82,18 +97,6 @@ region = Rect2(89, 7, 8, 5)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ts3pc"]
content_margin_top = 2.0
[sub_resource type="AtlasTexture" id="AtlasTexture_okcqu"]
atlas = ExtResource("6_43i8g")
region = Rect2(62, 10, 8, 8)
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_qa24s"]
texture = SubResource("AtlasTexture_okcqu")
texture_margin_left = 4.0
texture_margin_top = 2.0
texture_margin_right = 4.0
texture_margin_bottom = 2.0
region_rect = Rect2(0, 0, 8, 8)
[resource]
Button/colors/font_color = Color(0.85490197, 0.8784314, 0.91764706, 1)
Button/colors/font_disabled_color = Color(0.85882354, 0.6431373, 0.3882353, 1)
@@ -109,10 +112,14 @@ CheckButton/icons/unchecked = SubResource("AtlasTexture_o6p3e")
Control/constants/outline_size = 4
Control/font_sizes/font_size = 8
Control/fonts/font = SubResource("FontVariation_b02pe")
HSlider/icons/grabber = SubResource("AtlasTexture_w8nmj")
HSlider/icons/grabber_disabled = SubResource("AtlasTexture_t2hcr")
HSlider/icons/grabber_highlight = SubResource("AtlasTexture_8j1wx")
HSlider/icons/tick = SubResource("AtlasTexture_w151p")
HScrollBar/styles/grabber = ExtResource("8_b5n6m")
HScrollBar/styles/grabber_highlight = ExtResource("8_b5n6m")
HScrollBar/styles/grabber_pressed = ExtResource("8_b5n6m")
HScrollBar/styles/scroll = ExtResource("9_xqncf")
HSlider/icons/grabber = ExtResource("8_t2hcr")
HSlider/icons/grabber_disabled = ExtResource("9_n5i54")
HSlider/icons/grabber_highlight = ExtResource("8_t2hcr")
HSlider/icons/tick = ExtResource("10_08ul3")
HSlider/styles/grabber_area = ExtResource("8_o6p3e")
HSlider/styles/grabber_area_highlight = ExtResource("8_o6p3e")
HSlider/styles/slider = ExtResource("9_w151p")
@@ -121,13 +128,19 @@ Label/font_sizes/font_size = 8
Label/fonts/font = ExtResource("5_o6p3e")
LineEdit/styles/focus = ExtResource("1_vnhdr")
LineEdit/styles/normal = SubResource("StyleBoxEmpty_t2hcr")
OptionButton/icons/arrow = SubResource("AtlasTexture_noue1")
PanelContainer/styles/panel = ExtResource("6_w151p")
PopupMenu/constants/outline_size = 4
PopupMenu/font_sizes/font_size = 8
PopupMenu/fonts/font = SubResource("FontVariation_inyly")
PopupMenu/icons/radio_checked = SubResource("AtlasTexture_k1p2l")
PopupMenu/icons/radio_unchecked = SubResource("AtlasTexture_qa24s")
PopupMenu/styles/hover = ExtResource("16_xqncf")
PopupMenu/styles/panel = ExtResource("6_w151p")
RichTextLabel/font_sizes/normal_font_size = 8
RichTextLabel/fonts/normal_font = ExtResource("5_o6p3e")
RichTextLabel/styles/normal = SubResource("StyleBoxEmpty_xqncf")
ScrollContainer/styles/panel = SubResource("StyleBoxEmpty_nis8m")
SideCheckButton/base_type = &"Button"
SideCheckButton/colors/font_color = Color(0.8392157, 0.8392157, 0.8392157, 1)
SideCheckButton/colors/font_hover_color = Color(1, 1, 1, 1)
@@ -155,10 +168,17 @@ TabContainer/styles/tab_focus = ExtResource("1_vnhdr")
TabContainer/styles/tab_hovered = ExtResource("2_ts3pc")
TabContainer/styles/tab_selected = ExtResource("4_845oj")
TabContainer/styles/tab_unselected = ExtResource("3_43i8g")
VScrollBar/styles/grabber = ExtResource("13_w151p")
VScrollBar/styles/grabber_highlight = ExtResource("13_w151p")
VScrollBar/styles/grabber_pressed = ExtResource("13_w151p")
VScrollBar/styles/scroll = SubResource("StyleBoxTexture_qa24s")
VScrollBar/styles/grabber = ExtResource("18_nis8m")
VScrollBar/styles/grabber_highlight = ExtResource("18_nis8m")
VScrollBar/styles/grabber_pressed = ExtResource("18_nis8m")
VScrollBar/styles/scroll = ExtResource("19_aggbr")
VSlider/icons/grabber = ExtResource("8_t2hcr")
VSlider/icons/grabber_disabled = ExtResource("9_n5i54")
VSlider/icons/grabber_highlight = ExtResource("8_t2hcr")
VSlider/icons/tick = ExtResource("10_08ul3")
VSlider/styles/grabber_area = ExtResource("8_o6p3e")
VSlider/styles/grabber_area_highlight = ExtResource("8_o6p3e")
VSlider/styles/slider = ExtResource("9_w151p")
VersionLabel/base_type = &"Label"
VersionLabel/colors/font_color = Color(0.85, 0.85, 0.85, 0.7)
VersionLabel/font_sizes/font_size = 8

View File

@@ -8,6 +8,7 @@ region = Rect2(75, 4, 2, 2)
[resource]
content_margin_top = 2.0
content_margin_right = 2.0
texture = SubResource("AtlasTexture_uj2su")
axis_stretch_horizontal = 1
axis_stretch_vertical = 1

View File

@@ -0,0 +1,7 @@
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://d3bbst30pgfgy"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_gfpkm"]
[resource]
atlas = ExtResource("1_gfpkm")
region = Rect2(75, 4, 2, 2)

View File

@@ -0,0 +1,15 @@
[gd_resource type="StyleBoxTexture" load_steps=3 format=3 uid="uid://c4cljq7yl78eg"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_qpij5"]
[sub_resource type="AtlasTexture" id="AtlasTexture_okcqu"]
atlas = ExtResource("1_qpij5")
region = Rect2(62, 10, 8, 8)
[resource]
texture = SubResource("AtlasTexture_okcqu")
texture_margin_left = 4.0
texture_margin_top = 2.0
texture_margin_right = 4.0
texture_margin_bottom = 2.0
region_rect = Rect2(0, 0, 8, 8)

View File

@@ -1,9 +1,9 @@
[gd_resource type="StyleBoxTexture" load_steps=3 format=3 uid="uid://8s0fgx46n145"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_pfcbc"]
[ext_resource type="Texture2D" uid="uid://b5h32okh8yu6f" path="res://ui_atlas.png" id="1_6syfe"]
[sub_resource type="AtlasTexture" id="AtlasTexture_noue1"]
atlas = ExtResource("1_pfcbc")
atlas = ExtResource("1_6syfe")
region = Rect2(62, 1, 8, 8)
[resource]

View File

@@ -24,7 +24,6 @@ text = "LABEL_CARD_DESCRIPTION"
[node name="DescriptionText" type="RichTextLabel" parent="."]
auto_translate_mode = 2
clip_contents = false
layout_mode = 2
size_flags_vertical = 3
bbcode_enabled = true