33 lines
1006 B
GDScript3
33 lines
1006 B
GDScript3
|
extends Control
|
||
|
|
||
|
|
||
|
var enemies = Array()
|
||
|
|
||
|
|
||
|
func _on_button_instantiate_pressed() -> void:
|
||
|
var middleX := get_viewport_rect().size.x/2
|
||
|
var upperY := get_viewport_rect().size.y/4
|
||
|
var middleY := get_viewport_rect().size.y/2
|
||
|
for enemy in enemies:
|
||
|
remove_child(enemy)
|
||
|
|
||
|
enemies = []
|
||
|
var numEnemies = randi_range(1, 5)
|
||
|
for i in range(numEnemies):
|
||
|
enemies.append(load("res://scenes/npc.tscn").instantiate())
|
||
|
add_child(enemies[i])
|
||
|
var posX := int(round((i + 1)*get_viewport_rect().size.x/(numEnemies + 1)))
|
||
|
enemies[i].position = Vector2(posX, middleY)
|
||
|
enemies[0].get_node("%NPCNameLabel").text = "Test"
|
||
|
var bossEnemy = load("res://scenes/npc.tscn").instantiate()
|
||
|
bossEnemy.npcDifficulty = NPC.npcDifficulties.BOSS
|
||
|
add_child(bossEnemy)
|
||
|
bossEnemy.position = Vector2(middleX, upperY)
|
||
|
#print(bossEnemy.npcDifficulty)
|
||
|
bossEnemy.scale = Vector2.ONE*1.6
|
||
|
|
||
|
|
||
|
func _on_button_exit_pressed() -> void:
|
||
|
get_tree().quit()
|
||
|
|