CyberTower/scripts/enemy.gd

20 lines
279 B
GDScript3
Raw Normal View History

2024-02-16 12:35:30 +00:00
class_name Enemy
extends CharacterBody2D
2024-02-16 15:35:39 +00:00
signal enemy_defeat
2024-02-16 12:35:30 +00:00
@export var damage = 8.0
@export var max_health = 20
var health: float
func _ready():
health = max_health
func take_damage(amount: float):
health -= amount
if health <= 0:
2024-02-16 15:35:39 +00:00
enemy_defeat.emit()
2024-02-16 12:35:30 +00:00
queue_free()