22 lines
588 B
GDScript
22 lines
588 B
GDScript
extends Panel
|
|
|
|
const BattleHelper = preload("res://helpers/battle.gd")
|
|
|
|
func _ready():
|
|
create_hero_units()
|
|
|
|
func find_free_anchor(anchor_type: String):
|
|
for anchor in get_tree().get_nodes_in_group("anchors"):
|
|
if anchor.anchor_type == anchor_type and anchor.is_empty():
|
|
return anchor
|
|
return null
|
|
|
|
func create_hero_unit(name: String, anchor_type: String):
|
|
var anchor = find_free_anchor(anchor_type)
|
|
if anchor:
|
|
BattleHelper.spawn_unit("heroes/" + name, anchor)
|
|
|
|
func create_hero_units():
|
|
create_hero_unit("tomahawk", "attack_start")
|
|
create_hero_unit("rhino", "defend_start")
|