fix: card burner loads cards and singes them with correct highlight
This commit is contained in:
parent
ba20ce5180
commit
6e3be3b78b
|
|
@ -19,39 +19,52 @@ var focused: bool = false:
|
|||
@onready var cursor: CandleCursor = %CandleCursor
|
||||
@onready var ancors: Array[Control] = [%Ancor1, %Ancor2, %Ancor3, %Ancor4]
|
||||
|
||||
signal card_burned
|
||||
|
||||
|
||||
func _ready():
|
||||
# Note: burn_cards is now called directly by the transition system, not via register_scene_actor
|
||||
%SkipButton.pressed.connect(card_burned.emit)
|
||||
|
||||
func burn_cards(_id: int, _repeat: bool = false) -> void:
|
||||
# Get all card names from the board (excluding stickies which start with "p")
|
||||
|
||||
## Main play coroutine - simple linear flow for burning a card
|
||||
func play() -> void:
|
||||
print_debug("CardBurner: Starting card burning sequence")
|
||||
|
||||
# 1. Get all card names from the board (excluding stickies which start with "p")
|
||||
var card_names: Array[StringName] = []
|
||||
for item_name in State.save_game.board_positions.keys():
|
||||
if not item_name.begins_with("p"):
|
||||
card_names.append(item_name)
|
||||
|
||||
# Get card instances and shuffle them
|
||||
print_debug("CardBurner: Found %d cards to choose from" % card_names.size())
|
||||
|
||||
# 2. Get card instances and shuffle them
|
||||
var random_cards: Array = HardCards.get_cards_by_name_array(card_names)["cards"]
|
||||
random_cards.shuffle()
|
||||
|
||||
for ancor:Control in ancors:
|
||||
if random_cards.size() > 0:
|
||||
ancor.get_child(0).queue_free()
|
||||
var new_child: Card = random_cards.pop_front()
|
||||
ancor.add_child(new_child)
|
||||
new_child.owner = self
|
||||
new_child.has_burned.connect(card_burned.emit)
|
||||
# 3. Populate the 4 anchor slots with random cards
|
||||
for ancor: Control in ancors:
|
||||
var new_card: Card = random_cards.pop_front()
|
||||
ancor.add_child(new_card)
|
||||
new_card.owner = self
|
||||
new_card.has_burned.connect(card_burned.emit)
|
||||
print_debug("CardBurner: Added card '%s' to anchor" % new_card.name)
|
||||
|
||||
# 4. Wait for player to burn a card (or skip)
|
||||
print_debug("CardBurner: Waiting for player to burn a card...")
|
||||
await card_burned
|
||||
|
||||
# 5. Play vanish animation and wait for completion
|
||||
print_debug("CardBurner: Card burned, playing vanish animation")
|
||||
$AnimationPlayer.play("vanish")
|
||||
await $AnimationPlayer.animation_finished
|
||||
|
||||
signal card_burned
|
||||
print_debug("CardBurner: Sequence complete")
|
||||
|
||||
func handle_hover(to_handle: Area2D):
|
||||
if to_handle is Card:
|
||||
if to_handle.burn_state == Card.burned.NOT:
|
||||
to_handle.burn_state = Card.burned.SINGED
|
||||
func handle_hover(card: Draggable):
|
||||
if not card is Card: return
|
||||
card.highlighted = card.mouse_over
|
||||
card.burn_state = Card.burned.SINGED if card.mouse_over else Card.burned.NOT
|
||||
|
||||
func handle_mouse_button(event: InputEventMouseButton, card: Card):
|
||||
if event.button_index == MOUSE_BUTTON_MASK_LEFT and event.is_pressed() and not event.is_echo():
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
[ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="4_x6cxt"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="5_ckmi5"]
|
||||
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_x6cxt"]
|
||||
[sub_resource type="InputEventKey" id="InputEventKey_ckmi5"]
|
||||
device = -1
|
||||
physical_keycode = 88
|
||||
unicode = 120
|
||||
|
||||
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_23lqb"]
|
||||
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_x6cxt"]
|
||||
device = -1
|
||||
button_index = 2
|
||||
pressed = true
|
||||
|
|
@ -176,7 +176,7 @@ stretch_mode = 5
|
|||
script = ExtResource("4_x6cxt")
|
||||
action = "skip"
|
||||
icon = 0
|
||||
events = Array[InputEvent]([null, SubResource("InputEventKey_x6cxt"), SubResource("InputEventJoypadButton_23lqb")])
|
||||
events = Array[InputEvent]([null, SubResource("InputEventKey_ckmi5"), SubResource("InputEventJoypadButton_x6cxt")])
|
||||
metadata/_custom_type_script = "uid://bbs1u7ojno7xo"
|
||||
|
||||
[node name="SkipButton" type="Button" parent="Control/HSplitContainer"]
|
||||
|
|
@ -200,53 +200,41 @@ libraries = {
|
|||
}
|
||||
|
||||
[node name="Card1" parent="." instance=ExtResource("5_ckmi5")]
|
||||
picked_random = null
|
||||
wiggle_strength = null
|
||||
wiggle_speed = null
|
||||
scale_bump = null
|
||||
bounce_speed = null
|
||||
highlighted = null
|
||||
is_dragable = null
|
||||
diameter = null
|
||||
burn_progress = null
|
||||
burn_state = null
|
||||
direction = null
|
||||
|
||||
[node name="Card2" parent="." instance=ExtResource("5_ckmi5")]
|
||||
picked_random = null
|
||||
wiggle_strength = null
|
||||
wiggle_speed = null
|
||||
scale_bump = null
|
||||
bounce_speed = null
|
||||
highlighted = null
|
||||
is_dragable = null
|
||||
diameter = null
|
||||
burn_progress = null
|
||||
burn_state = null
|
||||
direction = null
|
||||
|
||||
[node name="Card3" parent="." instance=ExtResource("5_ckmi5")]
|
||||
picked_random = null
|
||||
wiggle_strength = null
|
||||
wiggle_speed = null
|
||||
scale_bump = null
|
||||
bounce_speed = null
|
||||
highlighted = null
|
||||
is_dragable = null
|
||||
diameter = null
|
||||
burn_progress = null
|
||||
burn_state = null
|
||||
direction = null
|
||||
|
||||
[node name="Card4" parent="." instance=ExtResource("5_ckmi5")]
|
||||
picked_random = null
|
||||
wiggle_strength = null
|
||||
wiggle_speed = null
|
||||
scale_bump = null
|
||||
bounce_speed = null
|
||||
highlighted = null
|
||||
is_dragable = null
|
||||
diameter = null
|
||||
burn_progress = null
|
||||
burn_state = null
|
||||
direction = null
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ func play_story() -> void:
|
|||
Scenes.player_enable.emit(true)
|
||||
expand()
|
||||
|
||||
|
||||
func play_board() -> void:
|
||||
canvas_layer.show()
|
||||
|
||||
|
|
@ -139,26 +140,33 @@ func play_board() -> void:
|
|||
expand()
|
||||
|
||||
|
||||
func play_burner() -> void:
|
||||
canvas_layer.show()
|
||||
|
||||
# Play the board (handles mouse visibility and waits for close)
|
||||
await interaction_ui.play()
|
||||
|
||||
# Hide the CanvasLayer when done
|
||||
canvas_layer.hide()
|
||||
|
||||
|
||||
func interact() -> void:
|
||||
Scenes.player_enable.emit(false)
|
||||
shown = false
|
||||
await collapse()
|
||||
collected = true
|
||||
|
||||
# collapse other interactables BEFORE showing canvas
|
||||
get_tree().call_group("interactables", "collapse")
|
||||
|
||||
# Show the CanvasLayer so the story is visible full-screen
|
||||
canvas_layer.show()
|
||||
|
||||
if interaction_ui is StoryPlayable:
|
||||
await play_story()
|
||||
|
||||
if interaction_ui is CardBoard:
|
||||
await play_board()
|
||||
|
||||
canvas_layer.hide()
|
||||
collected = true
|
||||
Scenes.player_enable.emit(true)
|
||||
if interaction_ui is CardBurner:
|
||||
await play_burner()
|
||||
|
||||
|
||||
## Updates caption label based on the instantiated interaction_ui
|
||||
|
|
@ -166,8 +174,10 @@ func _update_caption() -> void:
|
|||
if interaction_ui is StoryPlayable:
|
||||
var story := interaction_ui as StoryPlayable
|
||||
caption.text = I18n.get_story_caption(story.scene_id)
|
||||
elif interaction_ui is CardBoard:
|
||||
if interaction_ui is CardBoard:
|
||||
caption.text = TranslationServer.translate("Mind Board")
|
||||
if interaction_ui is CardBurner:
|
||||
caption.text = TranslationServer.translate("leave")
|
||||
|
||||
## Updates prompt label based on the interaction type and collected state
|
||||
func _update_prompt() -> void:
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ class_name Playable
|
|||
|
||||
## Awaitable that encapsulates the core interaction with this Playable
|
||||
func play() -> void:
|
||||
push_warning("Playeable[base].play() not overridden")
|
||||
await get_tree().process_frame # Dummy wait so this is a coroutine
|
||||
|
||||
func handle_hover(area: Draggable):
|
||||
prints("Playable[base].handle_hover", area, area.name)
|
||||
func handle_hover(_area: Draggable):
|
||||
#prints("Playable[base].handle_hover", _area, _area.name)
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in New Issue