integrating card_picker script with room scene

This commit is contained in:
betalars 2023-07-15 01:08:42 +02:00
parent 56f36b0148
commit baf07a3269
1 changed files with 17 additions and 6 deletions

View File

@ -15,15 +15,15 @@ var has_stage = false:
set(focus):
if not focus == has_stage:
if focus:
for player in anim_players: player.play("reveal")
selection_state = CARDS # fixme
if selection_state == INI or CARDS:
for player in anim_players: player.play("reveal")
self.show()
self.mouse_filter = Control.MOUSE_FILTER_IGNORE
else:
self.mouse_filter = Control.MOUSE_FILTER_STOP
self.hide()
has_stage = focus
visible = has_stage
var selection_state = INI
var input_locked = true
@ -56,14 +56,14 @@ func _ready():
options.append(control.get_child(1))
anim_players.append(control.get_child(0))
fill_card_slots()
fill_card_slots(0)
input_locked = false
func fill_card_slots():
func fill_card_slots(id: int):
for i in range($cards.get_child_count()):
var card:Card = $cards.get_child(i).get_child(1)
card.replace_with(debug_board.get_child(0).get_child(i) as Card)
card.replace_with(debug_board.get_child(id).get_child(i) as Card)
card.connect("mouse_entered", Callable(self, "get_highlight"))
func fill_post_slots():
@ -83,6 +83,8 @@ func _unhandled_input(event):
curr_selection_id += 1
if event.is_action_pressed("ui_accept"):
pick(curr_selection_id)
if event.is_action_pressed("ui_end"):
scene_finished(1)
func pick(id: int):
if id == -1:
@ -151,3 +153,12 @@ func handle_mouse_button(new_selection: Node, button_event: InputEventMouseButto
if not input_locked:
if button_event.button_index == MOUSE_BUTTON_LEFT and button_event.pressed:
pick(options.find(new_selection))
func scene_finished(id: int):
fill_card_slots(id)
State.transition_stage_to(self)
selection_state = CARDS
func play_scene(_id):
pass