49 lines
1.3 KiB
GDScript
49 lines
1.3 KiB
GDScript
class_name BattleScene extends Node3D
|
|
|
|
@export var actionBox:ActionBox = null
|
|
|
|
signal neverEmitted
|
|
|
|
func _init() ->void:
|
|
BATTLE.battleScene = self
|
|
BATTLE.battleStarted.connect(onBattleStarted)
|
|
|
|
func onBattleStarted() -> void:
|
|
pass
|
|
|
|
func getBattleDecisions(fighters:Array[BattleFighter]) -> Array[BattleDecision]:
|
|
var decisions:Array[BattleDecision] = []
|
|
|
|
while fighters.size() > decisions.size():
|
|
var fighter = fighters[decisions.size()]
|
|
var decision:BattleDecision = null
|
|
|
|
# Simulate walking forward animation like in Final Fantasy
|
|
await get_tree().create_timer(0.5).timeout
|
|
|
|
# Until decision made...
|
|
while decision == null:
|
|
# Get the selected action
|
|
actionBox.visible = true
|
|
var action = await self.actionBox.getAction(fighter)
|
|
|
|
# Go back to previous fighter
|
|
if action == ActionBox.Action.BACK:
|
|
decisions.pop_back()
|
|
actionBox.visible = false
|
|
break
|
|
elif action == ActionBox.Action.ATTACK:
|
|
var targets = await _getTargets(fighter, fighter.movePrimary)
|
|
|
|
actionBox.visible = false
|
|
|
|
if decision != null:
|
|
decisions.append(decision)
|
|
|
|
# Return the made decision
|
|
return decisions
|
|
|
|
func _getTargets(fighter:BattleFighter, move:BattleAction) -> Array[BattleFighter]:
|
|
print("Determining target")
|
|
await neverEmitted
|
|
return [] |