game: add enemy taunt on death
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
class_name Enemy
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var target: CollisionObject2D
|
||||
@@ -12,6 +13,7 @@ var move_speed: float
|
||||
var health: float
|
||||
var max_health: float
|
||||
var god_mode: bool = false
|
||||
var is_dead: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
move_speed = default_move_speed
|
||||
@@ -33,6 +35,9 @@ func take_damage(value: float):
|
||||
if god_mode:
|
||||
return
|
||||
health -= value
|
||||
var dm = preload("res://scenes/damage_numbers.tscn").instantiate()
|
||||
dm.damage_taken = value
|
||||
add_child(dm)
|
||||
if health <= 0:
|
||||
die()
|
||||
|
||||
@@ -43,10 +48,21 @@ func deal_damage():
|
||||
contact_damage_cd.start()
|
||||
|
||||
func die():
|
||||
queue_free()
|
||||
if is_dead:
|
||||
return
|
||||
is_dead = true
|
||||
target = null
|
||||
velocity = Vector2.ZERO
|
||||
animation_player.play("die")
|
||||
animation_player.animation_finished.connect(_on_die_anim_finished)
|
||||
|
||||
func cheer_anim():
|
||||
animation_player.play("jump")
|
||||
if not animation_player.is_playing():
|
||||
animation_player.play("jump")
|
||||
|
||||
func enemy_god_mode_toggle(toggle_on: bool) -> void:
|
||||
god_mode = toggle_on
|
||||
|
||||
func _on_die_anim_finished(name: String):
|
||||
visible = false
|
||||
queue_free()
|
||||
|
Reference in New Issue
Block a user