Adds action queuing and ATB charging
parent
d421821fbe
commit
7e599a5f97
@ -1,18 +1,40 @@
|
||||
extends Sprite2D
|
||||
|
||||
@onready var ATB = $battle_menu/ATB
|
||||
@onready var ActionState = $battle_menu/ActionState
|
||||
var NextAction
|
||||
var ActionReady = false
|
||||
|
||||
func _ready():
|
||||
var menu = $battle_menu
|
||||
menu.add_action($Combatant/Actions/attack).action_selected.connect(do_action)
|
||||
menu.add_action($Combatant/Actions/spin_attack).action_selected.connect(do_action)
|
||||
var item = menu.add_action($Combatant/Actions/attack)
|
||||
item.action_selected.connect(do_action)
|
||||
item.action.action_finished.connect(action_done)
|
||||
item = menu.add_action($Combatant/Actions/spin_attack)
|
||||
item.action_selected.connect(do_action)
|
||||
item.action.action_finished.connect(action_done)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
||||
var combatant = $Combatant
|
||||
if ActionReady and ATB.value == 100:
|
||||
NextAction.execute()
|
||||
ActionState.text = "Action Executing: %s" % NextAction.ActionName
|
||||
combatant.ATBCurrent = 0
|
||||
ATB.value = 0
|
||||
ActionReady = false
|
||||
return
|
||||
|
||||
|
||||
combatant.tick_atb(delta)
|
||||
ATB.value = combatant.ATBCurrent
|
||||
|
||||
|
||||
func do_action(action):
|
||||
print("Player selected: %s" % action.ActionName)
|
||||
ActionState.text = "Action Queued: %s" % action.ActionName
|
||||
NextAction = action
|
||||
ActionReady = true
|
||||
|
||||
func action_done():
|
||||
ActionState.text = ""
|
||||
|
||||
@ -1,6 +1,16 @@
|
||||
extends Action
|
||||
|
||||
|
||||
|
||||
var timer
|
||||
func execute():
|
||||
print("Test Player Attacking!")
|
||||
timer = Timer.new()
|
||||
timer.timeout.connect(done)
|
||||
timer.wait_time = 1
|
||||
add_child(timer)
|
||||
timer.start()
|
||||
print("Executing Attack!")
|
||||
|
||||
func done():
|
||||
timer.queue_free()
|
||||
action_finished.emit()
|
||||
|
||||
|
||||
@ -1,4 +1,14 @@
|
||||
extends Action
|
||||
|
||||
var timer
|
||||
func execute():
|
||||
print("Test Player uses Spin Attack!")
|
||||
timer = Timer.new()
|
||||
timer.timeout.connect(done)
|
||||
timer.wait_time = 1
|
||||
add_child(timer)
|
||||
timer.start()
|
||||
print("Executing Spin Attack!")
|
||||
|
||||
func done():
|
||||
timer.queue_free()
|
||||
action_finished.emit()
|
||||
|
||||
Loading…
Reference in New Issue