card picker can load cards from board of devs (WIP) and will discard post-its that are siblings of the chosen card when selecting the random post
This commit is contained in:
parent
0f75bd1dd3
commit
2afd3876fc
|
|
@ -8,6 +8,8 @@ enum {
|
|||
DONE
|
||||
}
|
||||
|
||||
@onready var debug_board:Control = $"board of devs"
|
||||
|
||||
var selection_state
|
||||
|
||||
var anim_players:Array
|
||||
|
|
@ -31,11 +33,28 @@ var options:Array
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
options = $cards.get_children()
|
||||
for card in options:
|
||||
anim_players.append(card.get_child(1))
|
||||
var card_controls = $cards.get_children()
|
||||
for control in card_controls:
|
||||
options.append(control.get_child(1))
|
||||
anim_players.append(control.get_child(0))
|
||||
selection_state = CARDS
|
||||
|
||||
fill_card_slots()
|
||||
|
||||
func fill_card_slots():
|
||||
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)
|
||||
|
||||
func fill_post_slots():
|
||||
var post_its: Array[PostIt] = []
|
||||
for card in output:
|
||||
post_its.append_array(card.own_postits)
|
||||
print(card.own_postits)
|
||||
|
||||
for i in range(post_its.size()):
|
||||
options[i].replace_with(post_its[i])
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("ui_up") or event.is_action_pressed("ui_left") or event.is_action_pressed("ui_focus_next"):
|
||||
curr_selection_id -= 1
|
||||
|
|
@ -57,11 +76,24 @@ func pick(id: int):
|
|||
var yield_to = anim_players[id].animation_finished
|
||||
output.append(options[id])
|
||||
|
||||
var sibling_id = -1
|
||||
if selection_state == POSTS:
|
||||
|
||||
sibling_id = options.find(options[id].sibling)
|
||||
|
||||
print("yeet sibling ", sibling_id)
|
||||
|
||||
options.remove_at(id)
|
||||
anim_players.remove_at(id)
|
||||
|
||||
randomize()
|
||||
var winning_id = randi() % options.size()
|
||||
|
||||
print("Winning ID ", id)
|
||||
|
||||
if winning_id == sibling_id:
|
||||
winning_id = (winning_id + 1) % options.size()
|
||||
|
||||
output.append(options.pop_at(winning_id))
|
||||
anim_players.pop_at(winning_id).play("shuffle")
|
||||
|
||||
|
|
@ -72,12 +104,15 @@ func pick(id: int):
|
|||
|
||||
if selection_state == CARDS:
|
||||
selection_state = TRANSITION
|
||||
|
||||
options = $postIts.get_children()
|
||||
options = []
|
||||
anim_players = []
|
||||
for post in options:
|
||||
anim_players.append(post.get_child(1))
|
||||
post.get_child(1).play("post")
|
||||
for control in $postIts.get_children():
|
||||
options.append(control.get_child(1))
|
||||
anim_players.append(control.get_child(0))
|
||||
control.get_child(0).play("post")
|
||||
curr_selection_id = -1
|
||||
|
||||
fill_post_slots()
|
||||
|
||||
await anim_players[0].animation_finished
|
||||
selection_state = POSTS
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=61 format=3 uid="uid://brk4hjdf2x81a"]
|
||||
[gd_scene load_steps=62 format=3 uid="uid://brk4hjdf2x81a"]
|
||||
|
||||
[ext_resource type="Script" path="res://logic-scenes/card_picker/card_picker.gd" id="1_pjntm"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="2_dqebt"]
|
||||
[ext_resource type="PackedScene" uid="uid://vkcdj8c3ytbq" path="res://logic-scenes/board/post-it.tscn" id="3_ggbxq"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvowj4l8dtceu" path="res://dev-util/board of devs.tscn" id="4_1kvte"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_dinvx"]
|
||||
length = 0.001
|
||||
|
|
@ -1395,26 +1396,26 @@ offset_right = -317.0
|
|||
offset_bottom = 25.0
|
||||
rotation = -0.109599
|
||||
|
||||
[node name="card" parent="cards/card_1" instance=ExtResource("2_dqebt")]
|
||||
text = "I never put in much effort for homework "
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_1"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_gdxmh")
|
||||
}
|
||||
|
||||
[node name="card" parent="cards/card_1" instance=ExtResource("2_dqebt")]
|
||||
text = "card slot 1"
|
||||
|
||||
[node name="card_2" type="Control" parent="cards"]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
|
||||
[node name="card" parent="cards/card_2" instance=ExtResource("2_dqebt")]
|
||||
text = "I like my teachers more than my classmates "
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_2"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_oxheu")
|
||||
}
|
||||
|
||||
[node name="card" parent="cards/card_2" instance=ExtResource("2_dqebt")]
|
||||
text = "card slot 2"
|
||||
|
||||
[node name="card_3" type="Control" parent="cards"]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
|
|
@ -1424,14 +1425,14 @@ offset_right = 315.0
|
|||
offset_bottom = 22.0
|
||||
rotation = 0.10472
|
||||
|
||||
[node name="card" parent="cards/card_3" instance=ExtResource("2_dqebt")]
|
||||
text = "I can put ages into things I enjoy "
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_3"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_8blxm")
|
||||
}
|
||||
|
||||
[node name="card" parent="cards/card_3" instance=ExtResource("2_dqebt")]
|
||||
text = "card slot 3"
|
||||
|
||||
[node name="postIts" type="Panel" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
|
|
@ -1441,9 +1442,6 @@ anchors_preset = 0
|
|||
offset_top = -150.0
|
||||
offset_bottom = -150.0
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_1" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 1"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="postIts/postIt_1"]
|
||||
root_node = NodePath("../post-it")
|
||||
autoplay = "ini"
|
||||
|
|
@ -1451,15 +1449,15 @@ libraries = {
|
|||
"": SubResource("AnimationLibrary_ga4dm")
|
||||
}
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_1" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 1"
|
||||
|
||||
[node name="postIt_2" type="Control" parent="postIts"]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
offset_top = -50.0
|
||||
offset_bottom = -50.0
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_2" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 2"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="postIts/postIt_2"]
|
||||
root_node = NodePath("../post-it")
|
||||
autoplay = "ini"
|
||||
|
|
@ -1467,15 +1465,15 @@ libraries = {
|
|||
"": SubResource("AnimationLibrary_sxnmi")
|
||||
}
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_2" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 2"
|
||||
|
||||
[node name="postIt_3" type="Control" parent="postIts"]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
offset_top = 50.0
|
||||
offset_bottom = 50.0
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_3" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 3"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="postIts/postIt_3"]
|
||||
root_node = NodePath("../post-it")
|
||||
autoplay = "ini"
|
||||
|
|
@ -1483,18 +1481,25 @@ libraries = {
|
|||
"": SubResource("AnimationLibrary_xs06v")
|
||||
}
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_3" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 3"
|
||||
|
||||
[node name="postIt_4" type="Control" parent="postIts"]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
offset_top = 150.0
|
||||
offset_bottom = 150.0
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_4" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 4"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="postIts/postIt_4"]
|
||||
root_node = NodePath("../post-it")
|
||||
autoplay = "ini"
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_tdl1s")
|
||||
}
|
||||
|
||||
[node name="post-it" parent="postIts/postIt_4" instance=ExtResource("3_ggbxq")]
|
||||
text = "Post 4"
|
||||
|
||||
[node name="board of devs" parent="." instance=ExtResource("4_1kvte")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
|
|
|||
Loading…
Reference in New Issue