extends Node2D @onready var path_2d: Path2D = $Path2D const FORKMAN = preload("res://Game/Mobs/forkman.tscn") const ORK = preload("res://Game/Mobs/ork.tscn") const COBOLD = preload("res://Game/Mobs/cobold.tscn") const enemies = [FORKMAN, COBOLD, ORK] func _ready() -> void: get_node("SidePanel").Update_Lifes(20) get_node("SidePanel").Update_Coins(200) func _on_timer_timeout() -> void: spawnMonster() func spawnMonster(): var path = PathFollow2D.new() var monster = enemies.pick_random().instantiate() path.add_child(monster) path_2d.add_child(path) func decrease_life(damage) -> void: get_node("SidePanel").Update_Lifes(-damage) if get_node("SidePanel").get_Lifes() <= 0: game_over() func game_over()-> void: get_node("Timer").stop() var enemy = get_node("Path2D").get_children() for i in enemy: i.get_children()[0].set_process(false)