31 lines
749 B
GDScript
31 lines
749 B
GDScript
extends Character
|
|
|
|
func body_entered(body: Node):
|
|
if State != States.Alive:
|
|
return
|
|
if body is GenericProjectile:
|
|
Health -= body.BULLET_DAMAGE
|
|
if Health <= 0:
|
|
die()
|
|
else:
|
|
var audios = [
|
|
preload("res://assets/audio/Sounds/VI_INJR2.xx_vimp.gzp.wav"),
|
|
preload("res://assets/audio/Sounds/VI_INJR1.xx_vimp.gzp.wav")
|
|
]
|
|
var audioindex = randi() % 2
|
|
var audio = audios[audioindex]
|
|
$HitSound.stream = audio
|
|
$HitSound.play()
|
|
|
|
func die():
|
|
State = States.Dead
|
|
var deathaudio = preload("res://assets/audio/Sounds/EX_BDYL2.xx_permanentaliens.gzp.wav")
|
|
$HitSound.stop()
|
|
$HitSound.stream = deathaudio
|
|
$HitSound.play()
|
|
$HitSound.connect("finished", self, "die_sound_finished")
|
|
|
|
|
|
func die_sound_finished():
|
|
queue_free()
|