Update Enemy.gd
This commit is contained in:
parent
378e016df2
commit
077ada5db4
@ -11,8 +11,8 @@ var freeXpStack = 0
|
|||||||
@onready var is_dying: bool = false
|
@onready var is_dying: bool = false
|
||||||
|
|
||||||
@export var level: int = 1
|
@export var level: int = 1
|
||||||
@export var hp: int = 100
|
@export var hp: int = 125
|
||||||
@export var maxhp: int = 100
|
@export var maxhp: int = 125
|
||||||
@export var maxvel: float = 2
|
@export var maxvel: float = 2
|
||||||
@export var experience: int = 0
|
@export var experience: int = 0
|
||||||
@export var state: String = "Idle"
|
@export var state: String = "Idle"
|
||||||
@ -68,6 +68,7 @@ func _process(delta):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if hp <= 0 && !is_dying:
|
if hp <= 0 && !is_dying:
|
||||||
|
is_dead = true
|
||||||
$Death.start()
|
$Death.start()
|
||||||
$Atk_cooldown.stop()
|
$Atk_cooldown.stop()
|
||||||
setAnimState("Die")
|
setAnimState("Die")
|
||||||
@ -75,8 +76,6 @@ func _process(delta):
|
|||||||
is_dying = true
|
is_dying = true
|
||||||
$DeathSnd.play()
|
$DeathSnd.play()
|
||||||
|
|
||||||
if is_dying:
|
|
||||||
is_dead = true
|
|
||||||
if abs(velocity.x) < 1 && abs(velocity.y) < 1 && !is_attacking:
|
if abs(velocity.x) < 1 && abs(velocity.y) < 1 && !is_attacking:
|
||||||
setAnimState("Idle")
|
setAnimState("Idle")
|
||||||
elif !is_attacking:
|
elif !is_attacking:
|
||||||
@ -172,6 +171,8 @@ func setAnimState(newstate):
|
|||||||
|
|
||||||
|
|
||||||
func receive_damage(dmg):
|
func receive_damage(dmg):
|
||||||
|
if is_dying || is_dead:
|
||||||
|
return
|
||||||
$HitSnd.play()
|
$HitSnd.play()
|
||||||
if hitanim.is_emitting():
|
if hitanim.is_emitting():
|
||||||
pass
|
pass
|
||||||
@ -242,6 +243,8 @@ func _on_sprite_animation_looped():
|
|||||||
|
|
||||||
|
|
||||||
func _on_attack_area_body_entered(body):
|
func _on_attack_area_body_entered(body):
|
||||||
|
if is_dead || is_dying:
|
||||||
|
return
|
||||||
if typeof(body) == typeof(TemplateSpawnable):
|
if typeof(body) == typeof(TemplateSpawnable):
|
||||||
body.receive_damage(damage)
|
body.receive_damage(damage)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user