First_Person_Slapper/Scripts/HurtBox.gd

29 lines
734 B
GDScript3
Raw Permalink Normal View History

2022-10-11 19:11:46 -04:00
class_name HurtBox
extends Area
2022-10-12 09:10:44 -04:00
onready var Slap = $AudioSlap
onready var MegaSlap = $AudioMegaSlap
2022-10-11 19:11:46 -04:00
func _init():
collision_layer = 0
collision_mask = 2
func _ready():
connect("area_entered",self,"_on_area_entered")
func _on_area_entered(hitbox: HitBox):
if hitbox == null:
return
if hitbox.hitbox_type == hitbox.HitboxType.Unassigned:
return
2022-10-12 09:10:44 -04:00
2022-10-11 19:11:46 -04:00
if hitbox.hitbox_type == hitbox.HitboxType.Slap and owner.has_method("get_slapped"):
2022-10-11 21:21:27 -04:00
owner.get_slapped(hitbox.slap_level,hitbox.slap_kill, hitbox.slap_vector)
2022-10-12 09:10:44 -04:00
if hitbox.slap_level >= hitbox.slap_kill:
MegaSlap.play()
else:
Slap.play()
2022-10-11 19:11:46 -04:00
elif hitbox.hitbox_type == hitbox.HitboxType.Projectile and owner.has_method("get_shot"):
2022-10-11 21:21:27 -04:00
owner.get_shot(hitbox.owner)