summaryrefslogtreecommitdiff
path: root/UI
diff options
context:
space:
mode:
Diffstat (limited to 'UI')
-rw-r--r--UI/Camera.gd46
-rw-r--r--UI/Camera.tscn7
-rw-r--r--UI/CollisionVisibilityArea.tscn11
-rw-r--r--UI/HPBar.tscn78
-rw-r--r--UI/HUD.gd7
-rw-r--r--UI/HUD.tscn233
-rw-r--r--UI/Lobby.gd11
-rw-r--r--UI/Lobby.tscn28
-rw-r--r--UI/SpawnButton.tscn12
-rw-r--r--UI/collision_visibility_area.gd40
-rw-r--r--UI/hp_bar.gd48
-rw-r--r--UI/spawn_button.gd14
12 files changed, 535 insertions, 0 deletions
diff --git a/UI/Camera.gd b/UI/Camera.gd
new file mode 100644
index 0000000..4e02662
--- /dev/null
+++ b/UI/Camera.gd
@@ -0,0 +1,46 @@
+extends Camera2D
+
+
+var is_in_drag_mode = false
+var drag_anchor = Vector2.ZERO
+
+@export var speed = 5
+
+@export_group("Zoom", "zoom")
+@export var zoom_min: float = 0.5
+@export var zoom_max: float = 3
+@export var zoom_step: float = 0.01
+
+
+func _input(event):
+ if event.is_action("camera_zoom_out"):
+ var new_zoom = max(zoom.x - zoom_step, zoom_min)
+ zoom = Vector2(new_zoom, new_zoom)
+ if event.is_action("camera_zoom_in"):
+ var new_zoom = min(zoom.x + zoom_step, zoom_max)
+ zoom = Vector2(new_zoom, new_zoom)
+ #global_position -= (global_position + (get_viewport_rect().size/2) - get_global_mouse_position())
+
+ if event.is_action_pressed("camera_drag"):
+ is_in_drag_mode = true
+ drag_anchor = get_global_mouse_position()
+ elif event.is_action_released("camera_drag"):
+ is_in_drag_mode = false
+
+
+func _process(_delta):
+ if is_in_drag_mode:
+ global_position += drag_anchor - get_global_mouse_position()
+
+ var direction_h = Input.get_axis("ui_left", "ui_right")
+ var direction_v = Input.get_axis("ui_up", "ui_down")
+ global_position += Vector2(direction_h * speed, direction_v * speed)
+
+
+func get_rect():
+ var viewport = get_viewport_rect()
+
+ return Rect2(
+ global_position,
+ viewport.size * Vector2(1 / zoom.x, 1 / zoom.y)
+ )
diff --git a/UI/Camera.tscn b/UI/Camera.tscn
new file mode 100644
index 0000000..7080711
--- /dev/null
+++ b/UI/Camera.tscn
@@ -0,0 +1,7 @@
+[gd_scene load_steps=2 format=3 uid="uid://t8feyd2giabm"]
+
+[ext_resource type="Script" path="res://UI/Camera.gd" id="1_yiia3"]
+
+[node name="Camera" type="Camera2D"]
+anchor_mode = 0
+script = ExtResource("1_yiia3")
diff --git a/UI/CollisionVisibilityArea.tscn b/UI/CollisionVisibilityArea.tscn
new file mode 100644
index 0000000..8ddcb01
--- /dev/null
+++ b/UI/CollisionVisibilityArea.tscn
@@ -0,0 +1,11 @@
+[gd_scene load_steps=2 format=3 uid="uid://cddsncmdb8g2j"]
+
+[ext_resource type="Script" path="res://UI/collision_visibility_area.gd" id="1_8fa5c"]
+
+[node name="CollisionVisibilityArea" type="Area2D"]
+script = ExtResource("1_8fa5c")
+
+[connection signal="area_entered" from="." to="." method="_on_area_entered"]
+[connection signal="area_exited" from="." to="." method="_on_area_exited"]
+[connection signal="body_entered" from="." to="." method="_on_body_entered"]
+[connection signal="body_exited" from="." to="." method="_on_body_exited"]
diff --git a/UI/HPBar.tscn b/UI/HPBar.tscn
new file mode 100644
index 0000000..fdd0542
--- /dev/null
+++ b/UI/HPBar.tscn
@@ -0,0 +1,78 @@
+[gd_scene load_steps=8 format=3 uid="uid://bjcrf4o4a80iv"]
+
+[ext_resource type="Script" path="res://UI/hp_bar.gd" id="1_63fia"]
+
+[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_c6ayl"]
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vcf16"]
+bg_color = Color(0, 0.477847, 0.151762, 1)
+
+[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_e46p5"]
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pys7d"]
+bg_color = Color(0.94075, 0.401118, 0.409345, 1)
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3xpcd"]
+bg_color = Color(0, 0, 0, 0.666667)
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_c7wcx"]
+bg_color = Color(0.500551, 0.0341227, 0.119353, 1)
+
+[node name="HPBar" type="Control"]
+layout_mode = 3
+anchors_preset = 0
+offset_right = 128.0
+offset_bottom = 4.0
+script = ExtResource("1_63fia")
+
+[node name="HealthBar" type="ProgressBar" parent="."]
+z_index = 3
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_styles/background = SubResource("StyleBoxEmpty_c6ayl")
+theme_override_styles/fill = SubResource("StyleBoxFlat_vcf16")
+value = 30.0
+show_percentage = false
+
+[node name="ImmediateDamageBar" type="ProgressBar" parent="."]
+z_index = 2
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_styles/background = SubResource("StyleBoxEmpty_e46p5")
+theme_override_styles/fill = SubResource("StyleBoxFlat_pys7d")
+value = 50.0
+show_percentage = false
+
+[node name="TotalDamageBar" type="ProgressBar" parent="."]
+z_index = 1
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme_override_styles/background = SubResource("StyleBoxFlat_3xpcd")
+theme_override_styles/fill = SubResource("StyleBoxFlat_c7wcx")
+value = 60.0
+show_percentage = false
+
+[node name="ImmediateDamageTimer" type="Timer" parent="."]
+wait_time = 0.5
+one_shot = true
+
+[node name="TotalDamageTimer" type="Timer" parent="."]
+wait_time = 0.2
+one_shot = true
+
+[connection signal="changed" from="HealthBar" to="." method="_on_health_bar_changed"]
+[connection signal="value_changed" from="HealthBar" to="." method="_on_health_bar_value_changed"]
+[connection signal="timeout" from="ImmediateDamageTimer" to="." method="_on_immediate_damage_timer_timeout"]
+[connection signal="timeout" from="TotalDamageTimer" to="." method="_on_total_damage_timer_timeout"]
diff --git a/UI/HUD.gd b/UI/HUD.gd
new file mode 100644
index 0000000..7674ce3
--- /dev/null
+++ b/UI/HUD.gd
@@ -0,0 +1,7 @@
+class_name HUD
+extends CanvasLayer
+
+
+@onready var score: Label = %Score
+@onready var tower: Label = %Tower
+@onready var spawn_box: Control = %SpawnBox
diff --git a/UI/HUD.tscn b/UI/HUD.tscn
new file mode 100644
index 0000000..b73fc34
--- /dev/null
+++ b/UI/HUD.tscn
@@ -0,0 +1,233 @@
+[gd_scene load_steps=17 format=3 uid="uid://bylx30cweulmk"]
+
+[ext_resource type="Script" path="res://UI/HUD.gd" id="1_2bu0v"]
+[ext_resource type="Texture2D" uid="uid://c7ntdvxvv16io" path="res://Assets/UI/key_e.png" id="1_d2guw"]
+[ext_resource type="Texture2D" uid="uid://hljlcokgys6y" path="res://Assets/UI/key_r.png" id="2_b00ni"]
+[ext_resource type="PackedScene" uid="uid://x6kohecnw7f5" path="res://UI/SpawnButton.tscn" id="3_7eaea"]
+[ext_resource type="Texture2D" uid="uid://up1rtweit3ut" path="res://Assets/Mobs/angesnow-menu01.png" id="4_w7sef"]
+[ext_resource type="Texture2D" uid="uid://dq2i36oe1wj0m" path="res://Assets/Mobs/mob-pressed.png" id="5_xcxr8"]
+[ext_resource type="Texture2D" uid="uid://dnkr5y0cfxu68" path="res://Assets/Mobs/mob-hovered.png" id="6_4go2d"]
+[ext_resource type="Texture2D" uid="uid://dsy7k2v5fhh6v" path="res://Assets/Mobs/angesnow-front.png" id="7_ba5tw"]
+[ext_resource type="Texture2D" uid="uid://dsui46tcf0pys" path="res://Assets/Mobs/banling-menu01.png" id="8_wmbg8"]
+[ext_resource type="Texture2D" uid="uid://d3modiw2b30kh" path="res://Assets/Mobs/banling-front.png" id="9_nmd8t"]
+[ext_resource type="Texture2D" uid="uid://75o7x0jadi08" path="res://Assets/Mobs/firomenis-menu01.png" id="10_daowa"]
+[ext_resource type="Texture2D" uid="uid://bxr5ckrvhyp1t" path="res://Assets/Mobs/firomenis-front.png" id="11_yxcwt"]
+[ext_resource type="Texture2D" uid="uid://byrx3c087exvb" path="res://Assets/Mobs/windeye-menu01.png" id="12_20egp"]
+[ext_resource type="Texture2D" uid="uid://coiiq1yaonxeg" path="res://Assets/Mobs/windeye-front.png" id="13_iq5a7"]
+[ext_resource type="Texture2D" uid="uid://dr02nqmrnciy0" path="res://Assets/Mobs/mob.png" id="14_t3qlu"]
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3rjde"]
+bg_color = Color(0, 0, 0, 0.54902)
+
+[node name="HUD" type="CanvasLayer"]
+script = ExtResource("1_2bu0v")
+
+[node name="Panel" type="PanelContainer" parent="."]
+anchors_preset = 10
+anchor_right = 1.0
+offset_bottom = 29.0
+grow_horizontal = 2
+theme_override_styles/panel = SubResource("StyleBoxFlat_3rjde")
+
+[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
+layout_mode = 2
+
+[node name="Container" type="HBoxContainer" parent="Panel/VBoxContainer"]
+layout_mode = 2
+
+[node name="GridContainer" type="GridContainer" parent="Panel/VBoxContainer/Container"]
+layout_mode = 2
+columns = 2
+
+[node name="MarginContainer" type="MarginContainer" parent="Panel/VBoxContainer/Container/GridContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 4
+theme_override_constants/margin_top = 4
+theme_override_constants/margin_right = 4
+theme_override_constants/margin_bottom = 4
+
+[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer/Container/GridContainer/MarginContainer"]
+layout_mode = 2
+
+[node name="BuildModeButton" type="TextureRect" parent="Panel/VBoxContainer/Container/GridContainer/MarginContainer/HBoxContainer"]
+custom_minimum_size = Vector2(24, 24)
+layout_mode = 2
+texture = ExtResource("1_d2guw")
+expand_mode = 1
+
+[node name="Label" type="Label" parent="Panel/VBoxContainer/Container/GridContainer/MarginContainer/HBoxContainer"]
+layout_mode = 2
+text = "Build Mode"
+
+[node name="MarginContainer2" type="MarginContainer" parent="Panel/VBoxContainer/Container/GridContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 4
+theme_override_constants/margin_top = 4
+theme_override_constants/margin_right = 4
+theme_override_constants/margin_bottom = 4
+
+[node name="HBoxContainer2" type="HBoxContainer" parent="Panel/VBoxContainer/Container/GridContainer/MarginContainer2"]
+layout_mode = 2
+
+[node name="SpawnerBoxButton" type="TextureRect" parent="Panel/VBoxContainer/Container/GridContainer/MarginContainer2/HBoxContainer2"]
+custom_minimum_size = Vector2(24, 24)
+layout_mode = 2
+texture = ExtResource("2_b00ni")
+expand_mode = 1
+
+[node name="Label" type="Label" parent="Panel/VBoxContainer/Container/GridContainer/MarginContainer2/HBoxContainer2"]
+layout_mode = 2
+text = "Spawn Box"
+
+[node name="Control" type="Control" parent="Panel/VBoxContainer/Container"]
+layout_mode = 2
+size_flags_horizontal = 3
+
+[node name="MarginContainer" type="MarginContainer" parent="Panel/VBoxContainer/Container"]
+layout_mode = 2
+theme_override_constants/margin_right = 8
+
+[node name="Score" type="Label" parent="Panel/VBoxContainer/Container/MarginContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+text = "0"
+
+[node name="ColorRect" type="ColorRect" parent="Panel/VBoxContainer"]
+custom_minimum_size = Vector2(0, 1)
+layout_mode = 2
+
+[node name="CenterContainer" type="CenterContainer" parent="."]
+anchors_preset = 12
+anchor_top = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 0
+
+[node name="Tower" type="Label" parent="CenterContainer"]
+unique_name_in_owner = true
+layout_mode = 2
+
+[node name="SpawnBox" type="PanelContainer" parent="."]
+unique_name_in_owner = true
+anchors_preset = 3
+anchor_left = 1.0
+anchor_top = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_left = -40.0
+offset_top = -40.0
+grow_horizontal = 0
+grow_vertical = 0
+
+[node name="MarginContainer" type="MarginContainer" parent="SpawnBox"]
+layout_mode = 2
+theme_override_constants/margin_left = 8
+theme_override_constants/margin_top = 8
+theme_override_constants/margin_right = 8
+theme_override_constants/margin_bottom = 8
+
+[node name="GridContainer" type="GridContainer" parent="SpawnBox/MarginContainer"]
+layout_mode = 2
+theme_override_constants/h_separation = 12
+theme_override_constants/v_separation = 12
+columns = 4
+
+[node name="SpawnButton" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("4_w7sef")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+texture = ExtResource("7_ba5tw")
+
+[node name="SpawnButton2" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("8_wmbg8")
+texture_hover = ExtResource("6_4go2d")
+texture = ExtResource("9_nmd8t")
+
+[node name="SpawnButton3" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("10_daowa")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+texture = ExtResource("11_yxcwt")
+
+[node name="SpawnButton4" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("12_20egp")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+texture = ExtResource("13_iq5a7")
+
+[node name="SpawnButton5" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton6" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton7" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton8" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton9" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton10" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton11" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton12" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton13" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton14" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton15" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
+
+[node name="SpawnButton16" parent="SpawnBox/MarginContainer/GridContainer" instance=ExtResource("3_7eaea")]
+layout_mode = 2
+texture_normal = ExtResource("14_t3qlu")
+texture_pressed = ExtResource("5_xcxr8")
+texture_hover = ExtResource("6_4go2d")
diff --git a/UI/Lobby.gd b/UI/Lobby.gd
new file mode 100644
index 0000000..d4eb7c2
--- /dev/null
+++ b/UI/Lobby.gd
@@ -0,0 +1,11 @@
+extends Control
+
+
+func _on_button_pressed() -> void:
+ Network.host_game()
+ get_tree().change_scene_to_file("res://Stages/world.tscn")
+
+
+func _on_button_2_pressed() -> void:
+ Network.join_game()
+ get_tree().change_scene_to_file("res://Stages/world.tscn")
diff --git a/UI/Lobby.tscn b/UI/Lobby.tscn
new file mode 100644
index 0000000..64bfc97
--- /dev/null
+++ b/UI/Lobby.tscn
@@ -0,0 +1,28 @@
+[gd_scene load_steps=2 format=3 uid="uid://bcbxer883ygg7"]
+
+[ext_resource type="Script" path="res://UI/Lobby.gd" id="1_f10dr"]
+
+[node name="Lobby" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_f10dr")
+
+[node name="Button" type="Button" parent="."]
+layout_mode = 0
+offset_right = 8.0
+offset_bottom = 8.0
+text = "Host"
+
+[node name="Button2" type="Button" parent="."]
+layout_mode = 0
+offset_top = 32.0
+offset_right = 38.0
+offset_bottom = 63.0
+text = "Join"
+
+[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
+[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
diff --git a/UI/SpawnButton.tscn b/UI/SpawnButton.tscn
new file mode 100644
index 0000000..ec2423b
--- /dev/null
+++ b/UI/SpawnButton.tscn
@@ -0,0 +1,12 @@
+[gd_scene load_steps=2 format=3 uid="uid://x6kohecnw7f5"]
+
+[ext_resource type="Script" path="res://UI/spawn_button.gd" id="1_ayei4"]
+
+[node name="SpawnButton" type="TextureButton"]
+offset_left = 2.0
+offset_top = 2.0
+offset_right = 38.0
+offset_bottom = 38.0
+script = ExtResource("1_ayei4")
+
+[connection signal="pressed" from="." to="." method="_on_pressed"]
diff --git a/UI/collision_visibility_area.gd b/UI/collision_visibility_area.gd
new file mode 100644
index 0000000..a049432
--- /dev/null
+++ b/UI/collision_visibility_area.gd
@@ -0,0 +1,40 @@
+extends Area2D
+
+
+@onready var collision_shape = get_child(0) as CollisionShape2D
+
+var colliding_nodes = []
+
+@export var not_colliding_color: Color
+@export var colliding_color: Color
+
+
+func _draw():
+ var shape = collision_shape.shape as RectangleShape2D
+ draw_rect(
+ Rect2(
+ Vector2.ZERO,
+ shape.size.snapped(Client.stage.map.tile_set.tile_size)
+ ),
+ colliding_color if colliding_nodes else not_colliding_color
+ )
+
+
+func _on_area_entered(area: Area2D) -> void:
+ colliding_nodes.append(area)
+ queue_redraw()
+
+
+func _on_area_exited(area: Area2D) -> void:
+ colliding_nodes.remove_at(colliding_nodes.find(area))
+ queue_redraw()
+
+
+func _on_body_entered(body: Node2D) -> void:
+ colliding_nodes.append(body)
+ queue_redraw()
+
+
+func _on_body_exited(body: Node2D) -> void:
+ colliding_nodes.remove_at(colliding_nodes.find(body))
+ queue_redraw()
diff --git a/UI/hp_bar.gd b/UI/hp_bar.gd
new file mode 100644
index 0000000..9df85e8
--- /dev/null
+++ b/UI/hp_bar.gd
@@ -0,0 +1,48 @@
+extends Control
+
+
+var value_difference = 0
+
+
+func init(health):
+ $HealthBar.max_value = health
+ $HealthBar.value = health
+
+ $ImmediateDamageBar.max_value = health
+ $ImmediateDamageBar.value = health
+
+ $TotalDamageBar.max_value = health
+ $TotalDamageBar.value = health
+
+
+func set_value(value):
+ value_difference = $HealthBar.value - value
+ $HealthBar.value = value
+
+ if $HealthBar.max_value == $HealthBar.value:
+ visible = false
+ else:
+ visible = true
+
+
+func _on_health_bar_value_changed(value: float) -> void:
+ if not $ImmediateDamageTimer.is_stopped():
+ $ImmediateDamageBar.value = $HealthBar.value + value_difference
+
+ $ImmediateDamageTimer.start()
+
+
+func _on_immediate_damage_timer_timeout() -> void:
+ var tween = get_tree().create_tween()
+ tween.tween_property($ImmediateDamageBar, "value", $HealthBar.value, 0.2)
+ $TotalDamageTimer.start()
+
+
+func _on_total_damage_timer_timeout() -> void:
+ var tween = get_tree().create_tween()
+ tween.tween_property(
+ $TotalDamageBar,
+ "value",
+ $HealthBar.value,
+ 0.3
+ )
diff --git a/UI/spawn_button.gd b/UI/spawn_button.gd
new file mode 100644
index 0000000..e623874
--- /dev/null
+++ b/UI/spawn_button.gd
@@ -0,0 +1,14 @@
+extends TextureButton
+
+
+@export var texture: Texture2D
+
+
+func _on_pressed() -> void:
+ var unit = preload("res://Units/Unit.tscn").instantiate() as Unit
+
+ if texture:
+ unit.get_node("Sprite2D").texture = texture
+ unit.get_node("Sprite2D").scale = Vector2(32,32) / texture.get_size()
+
+ Client.spawn_unit(unit, Client.stage.spawn)