31 lines
600 B
GDScript
31 lines
600 B
GDScript
class_name Obstacle extends CharacterBody2D
|
|
|
|
@onready var sprite = $Sprite2D
|
|
@onready var lifeTimeTimer = $lifeTimeTimer
|
|
|
|
@export var damage: int = 10
|
|
@export var health: int = 1
|
|
@export var minHealth: int = 1
|
|
@export var maxHealth: int = 1
|
|
@export var lifeTime: int = 600
|
|
|
|
func _ready() -> void:
|
|
lifeTimeTimer.start(lifeTime)
|
|
health += damage
|
|
|
|
func spawn(damage: int):
|
|
pass
|
|
|
|
|
|
func _on_hurt_area_hurt(amount: int) -> void:
|
|
hurt(amount)
|
|
|
|
func hurt(amount: int):
|
|
if health - amount <= minHealth:
|
|
queue_free()
|
|
else:
|
|
health -= amount
|
|
|
|
|
|
func _on_life_time_timer_timeout() -> void:
|
|
queue_free()
|