Add instakill condition to Stats and a Fall Limit Area

Use the FallLimitArea.tscn to visually set a height in the level that will trigger an instakill.

Closes: #173
This commit is contained in:
Henrique Campos 2020-01-24 10:27:51 -03:00
parent c59526cd1b
commit c88269743c
2 changed files with 20 additions and 3 deletions

View file

@ -26,7 +26,12 @@ func _ready() -> void:
func take_damage(hit: Hit) -> void:
if invulnerable:
return
# Damages with value of -1 mean instakill
if hit.damage == -1:
emit_signal("health_depleted")
return
var old_health = health
health -= hit.damage
emit_signal("damage_taken")
@ -58,8 +63,8 @@ func remove_modifier(id: int) -> void:
func set_invulnerable_for_seconds(time: float) -> void:
invulnerable = true
var timer := get_tree().create_timer(time)
yield(timer, "timeout")
invulnerable = false

View file

@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/Combat/DamageSource.tscn" type="PackedScene" id=1]
[sub_resource type="LineShape2D" id=1]
[node name="FallLimitArea" instance=ExtResource( 1 )]
position = Vector2( 0, -2.93628 )
damage = -1
[node name="CollisionShape2D" parent="." index="0"]
shape = SubResource( 1 )