spawnable tests and hpbar for bebittes
This commit is contained in:
@@ -2,9 +2,16 @@ extends Control
|
||||
|
||||
@onready var healthBar : ProgressBar = $HealthBar
|
||||
@onready var hpLabel : Label = $HealthBar/HP
|
||||
@onready var timer : Timer = $Timer
|
||||
|
||||
func setHP(currentHp, maxHp):
|
||||
healthBar.min_value = 0
|
||||
healthBar.max_value = maxHp
|
||||
healthBar.value = currentHp
|
||||
hpLabel.text = str(currentHp) + "/" + str(maxHp)
|
||||
timer.start()
|
||||
visible = true
|
||||
|
||||
|
||||
func _on_timer_timeout():
|
||||
visible = false
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://fojbwshce7ah"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://fojbwshce7ah"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Spawnables/UI/SpawnableUI.gd" id="1_en1j6"]
|
||||
[ext_resource type="Theme" uid="uid://dr1h7to56a2pv" path="res://Themes/base_theme.tres" id="2_ouwgg"]
|
||||
|
||||
[node name="SpawnableUI" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -18,6 +19,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_ouwgg")
|
||||
min_value = 100.0
|
||||
step = 1.0
|
||||
value = 100.0
|
||||
@@ -36,7 +38,11 @@ offset_right = 15.5
|
||||
offset_bottom = 7.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = "100/100"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
|
||||
@@ -95,6 +95,7 @@ func receive_damage(dmg):
|
||||
spawnableUI.setHP(currentHp, maxHp)
|
||||
|
||||
func die():
|
||||
enemy.remove_foe(self)
|
||||
bodyCollision.disabled = true
|
||||
damageCollision.disabled = true
|
||||
spawnableUI.visible = false
|
||||
@@ -103,7 +104,6 @@ func die():
|
||||
animatedSprite.play("death")
|
||||
animatedSprite.disconnect("animation_finished", endAttack)
|
||||
animatedSprite.connect("animation_finished", fadeOut)
|
||||
enemy.remove_foe(self)
|
||||
|
||||
func fadeOut():
|
||||
var tween = get_tree().create_tween()
|
||||
|
||||
@@ -232,8 +232,8 @@ height = 24.0
|
||||
radius = 8.0
|
||||
|
||||
[node name="TemplateSpawnable" type="CharacterBody2D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
collision_layer = 6
|
||||
collision_mask = 6
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_rkej7")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user