Added more flexible player damage from enemies and cleaned up some code

This commit is contained in:
VoidTwo
2021-12-05 14:55:47 -06:00
parent 9101bf2f65
commit b8cb1fa69b
7 changed files with 32 additions and 11 deletions

View File

@@ -65,11 +65,21 @@ func _on_Inventory_update_currency(amount: int) -> void:
func _on_hitbox_area_entered(area: Area2D) -> void:
if not 'enemy_hitbox' in area.get_groups():
var hit: int = 0
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
hit = 1
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
hit = 2
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
hit = 3
else:
return
if health_index != 0:
health_index -= 1
health_index -= hit
if health_index < 0:
health_index = 0
hud.update_health(HEALTH_SLICES[health_index])
return