65 lines
1.8 KiB
GDScript3
65 lines
1.8 KiB
GDScript3
|
|
@tool
|
||
|
|
extends VBoxContainer
|
||
|
|
class_name TroopMaker
|
||
|
|
|
||
|
|
|
||
|
|
signal troopDeleted
|
||
|
|
signal troopChanged
|
||
|
|
|
||
|
|
|
||
|
|
var troop : Troop
|
||
|
|
var troopNumber : int
|
||
|
|
|
||
|
|
|
||
|
|
@onready var delayEdit : CustomLineEdit = $HBC/DelayEdit
|
||
|
|
@onready var qtyEdit : CustomLineEdit = $HBC3/Quantity
|
||
|
|
@onready var enemySelect : CustomOptionButton = $HBC3/EnemySelect
|
||
|
|
@onready var spawnSelect : CustomOptionButton = $HBC4/SpawnSelect
|
||
|
|
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
$HBC2/RemoveButton.pressed.connect(troopDeleted.emit)
|
||
|
|
$HBC5/SplitTroopButton.pressed.connect(delayHasChanged.bind(1))
|
||
|
|
delayEdit.valueHasChanged.connect(delayHasChanged)
|
||
|
|
qtyEdit.valueHasChanged.connect(func(value): troop.number_to_spawn = value)
|
||
|
|
enemySelect.onValueChanged.connect(func(value): troop.enemy = value)
|
||
|
|
spawnSelect.onValueChanged.connect(func(value): troop.lane_to_spawn = int(value))
|
||
|
|
|
||
|
|
initTrop.call_deferred()
|
||
|
|
|
||
|
|
|
||
|
|
func delayHasChanged(newTime : float) -> void:
|
||
|
|
$HBC5.visible = newTime == 0
|
||
|
|
$HBC.visible = !$HBC5.visible
|
||
|
|
var oldTime : float = troop.spawn_delay
|
||
|
|
troop.spawn_delay = newTime
|
||
|
|
if !newTime || !oldTime:
|
||
|
|
troopChanged.emit()
|
||
|
|
|
||
|
|
|
||
|
|
func setTroop(_troop : Troop, _troopNumber : int) -> void:
|
||
|
|
troop = _troop
|
||
|
|
troopNumber = _troopNumber + 1
|
||
|
|
|
||
|
|
|
||
|
|
func initTrop():
|
||
|
|
delayEdit.setValue(troop.spawn_delay)
|
||
|
|
$HBC2/TroopLabel.text = "Troop N°" + str(troopNumber)
|
||
|
|
qtyEdit.setValue(troop.number_to_spawn)
|
||
|
|
print(troop.spawn_delay == 0)
|
||
|
|
$HBC5.visible = troop.spawn_delay == 0
|
||
|
|
$HBC.visible = !$HBC5.visible
|
||
|
|
|
||
|
|
var mainMenu : WaveMaker = EditorInterface.get_editor_main_screen().get_node("Menu")
|
||
|
|
mainMenu.spawnQtyChanged.connect(createSpawnOptions)
|
||
|
|
createSpawnOptions(mainMenu.level.laneCount)
|
||
|
|
enemySelect.setOptions(mainMenu.enemies)
|
||
|
|
|
||
|
|
|
||
|
|
func createSpawnOptions(laneCount : int) -> void:
|
||
|
|
spawnSelect.clear()
|
||
|
|
$HBC4.visible = laneCount > 1
|
||
|
|
if laneCount - 1:
|
||
|
|
for i in laneCount:
|
||
|
|
spawnSelect.addOption(str(i), str(i + 1))
|