add pick logic wip, unified naming convention

This commit is contained in:
betalars 2023-05-25 10:39:39 +02:00
parent 94ba90b73a
commit 7e3677befd
2 changed files with 175 additions and 92 deletions

View File

@ -0,0 +1,83 @@
extends CenterContainer
enum {
INI,
CARDS,
TRANSITION,
POSTS,
DONE
}
var selection_state
var anim_players:Array
var curr_selection_id: int = -1:
set(new_id):
if selection_state == CARDS or selection_state == POSTS:
if not curr_selection_id == -1: anim_players[curr_selection_id].play("deselect")
if new_id > options.size() -1: curr_selection_id = 0
elif new_id < 0: curr_selection_id = options.size() - 1
else: curr_selection_id = new_id
anim_players[curr_selection_id].play("select")
else:
curr_selection_id = new_id
print(curr_selection_id)
var output:Array
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))
selection_state = CARDS
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
elif event.is_action_pressed("ui_down") or event.is_action_pressed("ui_right") or event.is_action_pressed("ui_focus_prev"):
curr_selection_id += 1
if event.is_action_pressed("ui_accept"):
pick(curr_selection_id)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func pick(id: int):
print("meep")
if id == -1:
curr_selection_id = 0
return
anim_players[id].play("pick")
var yield_to = anim_players[id].animation_finished
output.append(options[id])
options.remove_at(id)
anim_players.remove_at(id)
var winning_id = randi() % options.size()
output.append(options.pop_at(winning_id))
anim_players.pop_at(winning_id).play("shuffle")
for anim in anim_players:
anim.play("unshuffle")
await yield_to
if selection_state == CARDS:
selection_state = TRANSITION
options = $postIts.get_children()
anim_players = []
for post in options:
anim_players.append(post.get_child(1))
post.get_child(1).play("post")
curr_selection_id = -1
await anim_players[0].animation_finished
selection_state == POSTS

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=61 format=3 uid="uid://brk4hjdf2x81a"]
[ext_resource type="Script" path="res://dev-util/card_picker_animation-debug.gd" id="1_8ab1e"]
[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"]
@ -139,8 +139,36 @@ tracks/2/keys = {
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1.2, 1.2)]
}
[sub_resource type="Animation" id="Animation_d68d2"]
resource_name = "unshuffle"
length = 3.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5, 1.4, 1.7, 2.5),
"transitions": PackedFloat32Array(0.450625, 1, 0.233258, 1),
"update": 0,
"values": [Vector2(-317, 25), Vector2(9.00003, 191), Vector2(58, 223), Vector2(242, -866)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:rotation")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.5, 1.6, 2.5),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [-0.109599, 0.5044, 3.4924]
}
[sub_resource type="Animation" id="Animation_76klu"]
resource_name = "take"
resource_name = "pick"
length = 4.0
tracks/0/type = "value"
tracks/0/imported = false
@ -179,41 +207,13 @@ tracks/2/keys = {
"values": [Vector2(-317, 25), Vector2(-336, -127), Vector2(-12, 0), Vector2(-12, 0), Vector2(-12, 0), Vector2(0, 968)]
}
[sub_resource type="Animation" id="Animation_d68d2"]
resource_name = "unshuffle"
length = 3.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5, 1.4, 1.7, 2.5),
"transitions": PackedFloat32Array(0.450625, 1, 0.233258, 1),
"update": 0,
"values": [Vector2(-317, 25), Vector2(9.00003, 191), Vector2(58, 223), Vector2(242, -866)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:rotation")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.5, 1.6, 2.5),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [-0.109599, 0.5044, 3.4924]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_gdxmh"]
_data = {
"RESET": SubResource("Animation_dinvx"),
"deselect": SubResource("Animation_4dp1g"),
"pick": SubResource("Animation_76klu"),
"select": SubResource("Animation_ldr2c"),
"shuffle": SubResource("Animation_abihp"),
"take": SubResource("Animation_76klu"),
"unshuffle": SubResource("Animation_d68d2")
}
@ -328,8 +328,36 @@ tracks/2/keys = {
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1.2, 1.2)]
}
[sub_resource type="Animation" id="Animation_sa974"]
resource_name = "unshuffle"
length = 3.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5, 1.4, 1.7, 2.4),
"transitions": PackedFloat32Array(0.63728, 1, 0.392292, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(-20, 195), Vector2(28, 213), Vector2(322, -781)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:rotation")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.5, 1.5, 2.5),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.0, 0.0436332, 3.22362]
}
[sub_resource type="Animation" id="Animation_16dsw"]
resource_name = "take"
resource_name = "pick"
length = 4.0
tracks/0/type = "value"
tracks/0/imported = false
@ -368,41 +396,13 @@ tracks/2/keys = {
"values": [Vector2(0, 0), Vector2(-10.0001, -123), Vector2(0, 0), Vector2(0, 0), Vector2(0, 0), Vector2(0, 1000)]
}
[sub_resource type="Animation" id="Animation_sa974"]
resource_name = "unshuffle"
length = 3.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5, 1.4, 1.7, 2.4),
"transitions": PackedFloat32Array(0.63728, 1, 0.392292, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(-20, 195), Vector2(28, 213), Vector2(322, -781)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:rotation")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.5, 1.5, 2.5),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.0, 0.0436332, 3.22362]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_oxheu"]
_data = {
"RESET": SubResource("Animation_pcher"),
"deselect": SubResource("Animation_5q97d"),
"pick": SubResource("Animation_16dsw"),
"select": SubResource("Animation_2c94q"),
"shuffle": SubResource("Animation_pdic8"),
"take": SubResource("Animation_16dsw"),
"unshuffle": SubResource("Animation_sa974")
}
@ -541,8 +541,36 @@ tracks/2/keys = {
"values": [Vector2(1, 1), Vector2(1, 1), Vector2(1.2, 1.2)]
}
[sub_resource type="Animation" id="Animation_mj8e0"]
resource_name = "unshuffle"
length = 3.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5, 1.4, 2.1),
"transitions": PackedFloat32Array(0.435275, 0.392292, 1),
"update": 0,
"values": [Vector2(315, 22), Vector2(28, 213), Vector2(322, -781)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:rotation")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.5, 1.4, 2.1),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.10472, 0.0436332, 3.22362]
}
[sub_resource type="Animation" id="Animation_wp0c8"]
resource_name = "take"
resource_name = "pick"
length = 4.0
tracks/0/type = "value"
tracks/0/imported = false
@ -581,41 +609,13 @@ tracks/2/keys = {
"values": [Vector2(315, 22), Vector2(350, -123), Vector2(0, 0), Vector2(0, 0), Vector2(0, 0), Vector2(0, 1000)]
}
[sub_resource type="Animation" id="Animation_mj8e0"]
resource_name = "unshuffle"
length = 3.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.5, 1.4, 2.1),
"transitions": PackedFloat32Array(0.435275, 0.392292, 1),
"update": 0,
"values": [Vector2(315, 22), Vector2(28, 213), Vector2(322, -781)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:rotation")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.5, 1.4, 2.1),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.10472, 0.0436332, 3.22362]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8blxm"]
_data = {
"RESET": SubResource("Animation_pf55g"),
"deselect": SubResource("Animation_6ar8x"),
"pick": SubResource("Animation_wp0c8"),
"select": SubResource("Animation_pcu23"),
"shuffle": SubResource("Animation_vu874"),
"take": SubResource("Animation_wp0c8"),
"unshuffle": SubResource("Animation_mj8e0")
}
@ -1369,7 +1369,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_8ab1e")
script = ExtResource("1_pjntm")
[node name="label" type="Label" parent="."]
layout_mode = 2