feat: 添加生命值回复事件,组件,浮动文字
This commit is contained in:
@@ -2,6 +2,7 @@ extends Node
|
|||||||
|
|
||||||
signal on_create_block_text(unit: Node2D)
|
signal on_create_block_text(unit: Node2D)
|
||||||
signal on_create_damage_text(unit: Node2D, hitbox: HitboxComponent)
|
signal on_create_damage_text(unit: Node2D, hitbox: HitboxComponent)
|
||||||
|
signal on_create_heal_text(unit: Node2D, heal: float)
|
||||||
|
|
||||||
signal on_upgrade_selected
|
signal on_upgrade_selected
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ damage_increase_per_wave = 0.0
|
|||||||
luck = 5.0
|
luck = 5.0
|
||||||
block_chance = 50.0
|
block_chance = 50.0
|
||||||
gold_drop = 0
|
gold_drop = 0
|
||||||
|
hp_regen = 1.0
|
||||||
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
metadata/_custom_type_script = "uid://dgjdpmaiufhs6"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ metadata/_custom_type_script = "uid://rw3gxqh858sr"
|
|||||||
script = ExtResource("1_cx7cn")
|
script = ExtResource("1_cx7cn")
|
||||||
from = 1
|
from = 1
|
||||||
to = 5
|
to = 5
|
||||||
wave_time = 5.0
|
wave_time = 15.0
|
||||||
units = Array[ExtResource("2_78wao")]([SubResource("Resource_3lh5k"), SubResource("Resource_aei4b"), SubResource("Resource_w8f67")])
|
units = Array[ExtResource("2_78wao")]([SubResource("Resource_3lh5k"), SubResource("Resource_aei4b"), SubResource("Resource_w8f67")])
|
||||||
spawn_type = 0
|
spawn_type = 0
|
||||||
fixed_spawn_time = 0.5
|
fixed_spawn_time = 0.5
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ func _ready() -> void:
|
|||||||
Global.on_create_block_text.connect(_on_create_block_text)
|
Global.on_create_block_text.connect(_on_create_block_text)
|
||||||
Global.on_create_damage_text.connect(_on_create_damage_text)
|
Global.on_create_damage_text.connect(_on_create_damage_text)
|
||||||
Global.on_upgrade_selected.connect(_on_upgrade_selected)
|
Global.on_upgrade_selected.connect(_on_upgrade_selected)
|
||||||
|
Global.on_create_heal_text.connect(_on_create_heal_text)
|
||||||
|
|
||||||
spawner.start_wave()
|
spawner.start_wave()
|
||||||
|
|
||||||
@@ -57,6 +58,9 @@ func _on_create_damage_text(unit: Node2D, hitbox: HitboxComponent) -> void:
|
|||||||
var color := critical_color if hitbox.critical else normal_color
|
var color := critical_color if hitbox.critical else normal_color
|
||||||
text.setup(str(hitbox.damage), color)
|
text.setup(str(hitbox.damage), color)
|
||||||
|
|
||||||
|
func _on_create_heal_text(unit: Node2D, heal: float) -> void:
|
||||||
|
var text := crteat_floating_text(unit)
|
||||||
|
text.setup("+ %s" % heal, hp_color)
|
||||||
|
|
||||||
func _on_upgrade_selected() -> void:
|
func _on_upgrade_selected() -> void:
|
||||||
upgrade_panel.hide()
|
upgrade_panel.hide()
|
||||||
|
|||||||
@@ -107,3 +107,12 @@ func _on_dash_timer_timeout() -> void:
|
|||||||
move_dir = Vector2.ZERO
|
move_dir = Vector2.ZERO
|
||||||
collision.set_deferred("disabled", false)
|
collision.set_deferred("disabled", false)
|
||||||
dash_cooldown_timer.start()
|
dash_cooldown_timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_hp_regen_timer_timeout() -> void:
|
||||||
|
if health_component.current_health <= 0:
|
||||||
|
return
|
||||||
|
if health_component.current_health < stats.health:
|
||||||
|
var heal := stats.hp_regen
|
||||||
|
health_component.heal(heal)
|
||||||
|
Global.on_create_heal_text.emit(self, heal)
|
||||||
|
|||||||
@@ -152,5 +152,10 @@ shape = SubResource("CircleShape2D_ht2l1")
|
|||||||
back_color = Color(0.13725491, 0.019607844, 0.02745098, 1)
|
back_color = Color(0.13725491, 0.019607844, 0.02745098, 1)
|
||||||
fill_color = Color(1, 0.2901961, 0.45490196, 1)
|
fill_color = Color(1, 0.2901961, 0.45490196, 1)
|
||||||
|
|
||||||
|
[node name="HPRegenTimer" type="Timer" parent="." index="11" unique_id=884883148]
|
||||||
|
wait_time = 3.0
|
||||||
|
autostart = true
|
||||||
|
|
||||||
[connection signal="timeout" from="DashTimer" to="." method="_on_dash_timer_timeout"]
|
[connection signal="timeout" from="DashTimer" to="." method="_on_dash_timer_timeout"]
|
||||||
[connection signal="timeout" from="TrailTimer" to="Visuals/Trail" method="_on_trail_timer_timeout"]
|
[connection signal="timeout" from="TrailTimer" to="Visuals/Trail" method="_on_trail_timer_timeout"]
|
||||||
|
[connection signal="timeout" from="HPRegenTimer" to="." method="_on_hp_regen_timer_timeout"]
|
||||||
|
|||||||
Reference in New Issue
Block a user