baddle
This commit is contained in:
@@ -1,25 +1,40 @@
|
||||
class_name ActionBox extends GridContainer
|
||||
|
||||
enum Action {
|
||||
ATTACK,
|
||||
MAGIC,
|
||||
ITEM,
|
||||
BACK
|
||||
}
|
||||
|
||||
@export var btnAttack:Button
|
||||
@export var btnMagic:Button
|
||||
@export var btnItem:Button
|
||||
@export var btnBack:Button
|
||||
|
||||
signal decisionMade(move:BattleDecision)
|
||||
signal action(action:Action)
|
||||
|
||||
func _ready() -> void:
|
||||
btnAttack.pressed.connect(onAttackPressed)
|
||||
btnMagic.pressed.connect(onMagicPressed)
|
||||
btnItem.pressed.connect(onItemPressed)
|
||||
btnAttack.pressed.connect(func():
|
||||
action.emit(Action.ATTACK)
|
||||
)
|
||||
btnMagic.pressed.connect(func():
|
||||
action.emit(Action.MAGIC)
|
||||
)
|
||||
btnItem.pressed.connect(func():
|
||||
action.emit(Action.ITEM)
|
||||
)
|
||||
btnBack.pressed.connect(func():
|
||||
action.emit(Action.BACK)
|
||||
)
|
||||
self.visible = false
|
||||
|
||||
func onAttackPressed() -> void:
|
||||
print("Attack button pressed")
|
||||
decisionMade.emit(BattleDecision.new(BattleMove.MOVE_PUNCH, null, null))
|
||||
|
||||
func onMagicPressed() -> void:
|
||||
print("Magic button pressed")
|
||||
decisionMade.emit(BattleDecision.new(BattleMove.MOVE_FIRE1, null, null))
|
||||
func getAction(fighter:BattleFighter) -> Action:
|
||||
btnAttack.disabled = fighter.movePrimary == null || !fighter.movePrimary.canFighterUse(fighter)
|
||||
btnMagic.disabled = fighter.movesMagical.size() == 0
|
||||
btnItem.disabled = false # TODO: check if items available?
|
||||
|
||||
func onItemPressed() -> void:
|
||||
print("Item button pressed")
|
||||
decisionMade.emit(null)
|
||||
# TODO: Update cursor position to first enabled button
|
||||
|
||||
var act = await action
|
||||
return act
|
||||
|
||||
Reference in New Issue
Block a user