Added more flexible player damage from enemies and cleaned up some code
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user