revo-jailbreak/objects/enemy/enemy.gd

39 lines
1.2 KiB
GDScript

extends Node2D
###
### IMPORTANT: enemy's hitbox must be in the group "enemy_hitbox" to be killed
### it should also be named "Hitbox" for easier (2 click) signal connection
### as the reciever function has been renamed with that in mind
###
const DeathParticles = preload("res://objects/enemy/death_particles.tscn")
### these variables have been replaced with groups to put on the hitbox
### - "blocks_arrow"
### - "blocks_sword"
### if an enemy's hitbox is not in those groups, it will be killed by them
#export var can_be_killed_by_sword = true
#export var can_be_killed_by_arrow = true
#export var can_be_squashed = true
export var score_for_killing = 0
export var blood = true
var death_sound = Game.a_die
var death_blood_offset = Vector2.ZERO
func _on_Hitbox_area_entered(area):
#Kill player
if area.is_in_group("player"):
area.get_parent().die()
func die():
if blood:
var death_particles = DeathParticles.instance()
death_particles.global_position = global_position + death_blood_offset
death_particles.emitting = true
get_parent().add_child(death_particles)
Game.play_sound(death_sound, Game.ac_die)
Game.score += score_for_killing
queue_free()