33 lines
678 B
GDScript
33 lines
678 B
GDScript
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]
|
|
|
|
var lives = 20
|
|
|
|
func _ready() -> void:
|
|
get_node("SidePanel").Update_Lives(lives)
|
|
|
|
|
|
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:
|
|
lives -= damage
|
|
get_node("SidePanel").Update_Lives(lives)
|
|
if lives == 0:
|
|
print("DEAD")
|
|
|