Add counters to stacks

This commit is contained in:
Hamcha 2019-05-27 00:00:15 +02:00
parent 29a72702e5
commit ef6aebf597
Signed by: hamcha
GPG key ID: A40413D21021EAEE
7 changed files with 72 additions and 34 deletions

Binary file not shown.

View file

@ -5,5 +5,5 @@
[resource] [resource]
flags_unshaded = true flags_unshaded = true
albedo_texture = ExtResource( 1 ) albedo_texture = ExtResource( 1 )
uv1_scale = Vector3( 0.9, 0.9, 1 ) uv1_scale = Vector3( 0.9, 0.92, 1 )
uv1_offset = Vector3( 0.05, 0.05, 0 ) uv1_offset = Vector3( 0.05, 0.04, 0 )

View file

@ -80,12 +80,14 @@ transform = Transform( -6.55671e-008, 0, -1.5, 0, 1, 0, 1.5, 0, -6.55671e-008, 2
title = "Problem" title = "Problem"
zoneName = "player1.problem" zoneName = "player1.problem"
offset = -0.01 offset = -0.01
showCounter = false
[node name="P2Problem" parent="Cards" instance=ExtResource( 5 )] [node name="P2Problem" parent="Cards" instance=ExtResource( 5 )]
transform = Transform( -6.55671e-008, 0, 1.5, 0, 1, 0, -1.5, 0, -6.55671e-008, -2.5, 0, 0 ) transform = Transform( -6.55671e-008, 0, 1.5, 0, 1, 0, -1.5, 0, -6.55671e-008, -2.5, 0, 0 )
title = "Problem" title = "Problem"
zoneName = "player2.problem" zoneName = "player2.problem"
offset = -0.01 offset = -0.01
showCounter = false
[connection signal="card_picked" from="Cards/P1Deck" to="." method="_card_picked_zone" binds= [ "player1.deck" ]] [connection signal="card_picked" from="Cards/P1Deck" to="." method="_card_picked_zone" binds= [ "player1.deck" ]]
[connection signal="card_picked" from="Cards/P1Graveyard" to="." method="_card_picked_zone" binds= [ "player1.graveyard" ]] [connection signal="card_picked" from="Cards/P1Graveyard" to="." method="_card_picked_zone" binds= [ "player1.graveyard" ]]
[connection signal="card_picked" from="Cards/P1Banished" to="." method="_card_picked_zone" binds= [ "player1.banished" ]] [connection signal="card_picked" from="Cards/P1Banished" to="." method="_card_picked_zone" binds= [ "player1.banished" ]]

View file

@ -9,7 +9,7 @@
margin = 0.001 margin = 0.001
extents = Vector3( 0.353, 0.001, 0.481 ) extents = Vector3( 0.353, 0.001, 0.481 )
[sub_resource type="Animation" id=3] [sub_resource type="Animation" id=2]
resource_name = "drop-board" resource_name = "drop-board"
length = 0.3 length = 0.3
step = 0.05 step = 0.05
@ -36,7 +36,7 @@ tracks/1/keys = {
"times": PoolRealArray( 0, 0.2, 0.3 ) "times": PoolRealArray( 0, 0.2, 0.3 )
} }
[sub_resource type="Animation" id=4] [sub_resource type="Animation" id=3]
length = 0.1 length = 0.1
step = 0.05 step = 0.05
tracks/0/type = "value" tracks/0/type = "value"
@ -52,7 +52,7 @@ tracks/0/keys = {
"values": [ Vector3( 0, 0.15, 0 ), Vector3( 0, 0, 0 ) ] "values": [ Vector3( 0, 0.15, 0 ), Vector3( 0, 0, 0 ) ]
} }
[sub_resource type="Animation" id=5] [sub_resource type="Animation" id=4]
length = 0.5 length = 0.5
step = 0.05 step = 0.05
tracks/0/type = "value" tracks/0/type = "value"
@ -80,7 +80,7 @@ tracks/1/keys = {
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 180 ) ] "values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 180 ) ]
} }
[sub_resource type="Animation" id=6] [sub_resource type="Animation" id=5]
resource_name = "flip-back" resource_name = "flip-back"
length = 0.5 length = 0.5
step = 0.05 step = 0.05
@ -109,7 +109,7 @@ tracks/1/keys = {
"values": [ Vector3( 0, 0, 180 ), Vector3( 0, 0, 0 ) ] "values": [ Vector3( 0, 0, 180 ), Vector3( 0, 0, 0 ) ]
} }
[sub_resource type="Animation" id=20] [sub_resource type="Animation" id=6]
resource_name = "flip-back-fast" resource_name = "flip-back-fast"
length = 0.25 length = 0.25
step = 0.05 step = 0.05
@ -167,7 +167,7 @@ tracks/1/keys = {
"values": [ Vector3( 0, 0, -150 ), Vector3( 0, 0, -180 ) ] "values": [ Vector3( 0, 0, -150 ), Vector3( 0, 0, -180 ) ]
} }
[sub_resource type="Animation" id=9] [sub_resource type="Animation" id=8]
length = 0.3 length = 0.3
step = 0.05 step = 0.05
tracks/0/type = "value" tracks/0/type = "value"
@ -193,7 +193,7 @@ tracks/1/keys = {
"times": PoolRealArray( 0, 0.112663, 0.3 ) "times": PoolRealArray( 0, 0.112663, 0.3 )
} }
[sub_resource type="Animation" id=10] [sub_resource type="Animation" id=9]
length = 0.3 length = 0.3
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("..:rotation_degrees") tracks/0/path = NodePath("..:rotation_degrees")
@ -208,7 +208,7 @@ tracks/0/keys = {
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, -90, 0 ) ] "values": [ Vector3( 0, 0, 0 ), Vector3( 0, -90, 0 ) ]
} }
[sub_resource type="Animation" id=11] [sub_resource type="Animation" id=10]
length = 0.3 length = 0.3
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("..:rotation_degrees") tracks/0/path = NodePath("..:rotation_degrees")
@ -223,7 +223,7 @@ tracks/0/keys = {
"values": [ Vector3( 0, -90, 0 ), Vector3( 0, 0, 0 ) ] "values": [ Vector3( 0, -90, 0 ), Vector3( 0, 0, 0 ) ]
} }
[sub_resource type="Animation" id=13] [sub_resource type="Animation" id=11]
resource_name = "blur" resource_name = "blur"
length = 0.1 length = 0.1
step = 0.01 step = 0.01
@ -238,7 +238,7 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 0.1 ) "times": PoolRealArray( 0, 0.1 )
} }
[sub_resource type="Animation" id=19] [sub_resource type="Animation" id=12]
length = 0.1 length = 0.1
step = 0.01 step = 0.01
tracks/0/type = "bezier" tracks/0/type = "bezier"
@ -252,7 +252,7 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 0.1 ) "times": PoolRealArray( 0, 0.1 )
} }
[sub_resource type="PlaneMesh" id=12] [sub_resource type="PlaneMesh" id=13]
[node name="Card" type="Area"] [node name="Card" type="Area"]
input_capture_on_drag = true input_capture_on_drag = true
@ -270,23 +270,23 @@ mesh = ExtResource( 2 )
material/0 = ExtResource( 3 ) material/0 = ExtResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="CardModel/Border"] [node name="AnimationPlayer" type="AnimationPlayer" parent="CardModel/Border"]
anims/drop-board = SubResource( 3 ) anims/drop-board = SubResource( 2 )
anims/drop-hand = SubResource( 4 ) anims/drop-hand = SubResource( 3 )
anims/flip = SubResource( 5 ) anims/flip = SubResource( 4 )
anims/flip-back = SubResource( 6 ) anims/flip-back = SubResource( 5 )
anims/flip-back-fast = SubResource( 20 ) anims/flip-back-fast = SubResource( 6 )
anims/flip-fast = SubResource( 7 ) anims/flip-fast = SubResource( 7 )
anims/lift = SubResource( 9 ) anims/lift = SubResource( 8 )
anims/tap = SubResource( 10 ) anims/tap = SubResource( 9 )
anims/tap-back = SubResource( 11 ) anims/tap-back = SubResource( 10 )
[node name="HandAnimPlayer" type="AnimationPlayer" parent="CardModel/Border"] [node name="HandAnimPlayer" type="AnimationPlayer" parent="CardModel/Border"]
anims/blur = SubResource( 13 ) anims/blur = SubResource( 11 )
anims/focus = SubResource( 19 ) anims/focus = SubResource( 12 )
[node name="CardImage" type="MeshInstance" parent="CardModel/Border"] [node name="CardImage" type="MeshInstance" parent="CardModel/Border"]
transform = Transform( 0.318962, 0, 0, 0, 1, 0, 0, 0, 0.450381, 0, 0.009, 0 ) transform = Transform( 0.318962, 0, 0, 0, 1, 0, 0, 0, 0.450381, 0, 0.009, 0 )
mesh = SubResource( 12 ) mesh = SubResource( 13 )
material/0 = ExtResource( 4 ) material/0 = ExtResource( 4 )
[node name="Tween" type="Tween" parent="."] [node name="Tween" type="Tween" parent="."]

View file

@ -11,15 +11,18 @@ export var zoneName: String
export var faceDown: bool export var faceDown: bool
export var editable: bool export var editable: bool
export var offset: float export var offset: float
export var showCounter: bool
var clicked: bool = false var clicked: bool = false
var cards: Array = [] var cards: Array = []
onready var stackCountLabel := $StackCount
func _ready(): func _ready():
set_title(title) set_title(title)
func set_title(title: String): func set_title(title: String):
$LabelViewport/Label.text = title $StackNameViewport/Label.text = title
func _mouse_entered(): func _mouse_entered():
emit_signal("hover") emit_signal("hover")
@ -57,3 +60,8 @@ func reorder_cards():
for card in cards: for card in cards:
card.translation.y = offset+(count-i)*CARD_DISTANCE card.translation.y = offset+(count-i)*CARD_DISTANCE
i += 1 i += 1
$StackCountViewport/Label.text = str(count)
if showCounter and count > 1:
stackCountLabel.translation.y = offset+0.11+count*CARD_DISTANCE
else:
stackCountLabel.translation.y = -1

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://Scenes/Components/Stack.gd" type="Script" id=1] [ext_resource path="res://Scenes/Components/Stack.gd" type="Script" id=1]
@ -17,16 +17,21 @@ albedo_color = Color( 1, 1, 1, 0.392157 )
font_path = "res://UIAssets/Fonts/Catamaran-Bold.ttf" font_path = "res://UIAssets/Fonts/Catamaran-Bold.ttf"
[sub_resource type="DynamicFont" id=4] [sub_resource type="DynamicFont" id=4]
size = 30
outline_size = 2 outline_size = 2
outline_color = Color( 0, 0, 0, 0.54902 ) outline_color = Color( 0, 0, 0, 0.54902 )
font_data = SubResource( 3 ) font_data = SubResource( 3 )
[sub_resource type="ViewportTexture" id=6]
viewport_path = NodePath("StackNameViewport")
[sub_resource type="ViewportTexture" id=5] [sub_resource type="ViewportTexture" id=5]
viewport_path = NodePath("LabelViewport") viewport_path = NodePath("StackCountViewport")
[node name="Stack" type="Area"] [node name="Stack" type="Area"]
input_ray_pickable = false input_ray_pickable = false
script = ExtResource( 1 ) script = ExtResource( 1 )
showCounter = true
[node name="CollisionShape" type="CollisionShape" parent="."] [node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0526529, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0526529, 0 )
@ -59,21 +64,44 @@ width = 0.650255
height = 0.102173 height = 0.102173
depth = 1.57935 depth = 1.57935
[node name="LabelViewport" type="Viewport" parent="."] [node name="StackNameViewport" type="Viewport" parent="."]
size = Vector2( 300, 300 )
transparent_bg = true
handle_input_locally = false
usage = 0
[node name="Label" type="Label" parent="StackNameViewport"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 100.0
margin_bottom = 100.0
custom_fonts/font = SubResource( 4 )
align = 1
valign = 1
[node name="StackCountViewport" type="Viewport" parent="."]
size = Vector2( 100, 100 ) size = Vector2( 100, 100 )
transparent_bg = true transparent_bg = true
handle_input_locally = false handle_input_locally = false
usage = 0 usage = 0
[node name="Label" type="Label" parent="LabelViewport"] [node name="Label" type="Label" parent="StackCountViewport"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
custom_fonts/font = SubResource( 4 ) custom_fonts/font = SubResource( 4 )
text = "0"
align = 1 align = 1
valign = 1 valign = 1
[node name="LabelSprite" type="Sprite3D" parent="."] [node name="StackName" type="Sprite3D" parent="."]
transform = Transform( 0.5853, 0.810817, -3.54419e-008, 0, -4.37114e-008, -1, -0.810817, 0.5853, -2.55843e-008, 0, 0, 0 ) transform = Transform( 0.29265, 0.405408, -1.7721e-008, 0, -2.18557e-008, -0.5, -0.405408, 0.29265, -1.27921e-008, -0.34215, 0, 0.0641977 )
modulate = Color( 1, 1, 1, 0.392157 )
texture = SubResource( 6 )
region_rect = Rect2( 0, 0, 30, 30 )
[node name="StackCount" type="Sprite3D" parent="."]
transform = Transform( 0.5853, 0.810817, -3.54419e-008, 0, -4.37114e-008, -1, -0.810817, 0.5853, -2.55843e-008, 0, -1, 0 )
modulate = Color( 1, 1, 1, 0.784314 )
texture = SubResource( 5 ) texture = SubResource( 5 )
region_rect = Rect2( 0, 0, 30, 30 ) region_rect = Rect2( 0, 0, 30, 30 )
[connection signal="mouse_entered" from="." to="." method="_mouse_entered"] [connection signal="mouse_entered" from="." to="." method="_mouse_entered"]

View file

@ -88,12 +88,12 @@ func _process(delta: float):
call_deferred("reparent", holdingCard, zones[holdingCard.zoneName], currentZone) call_deferred("reparent", holdingCard, zones[holdingCard.zoneName], currentZone)
holdingCard.zoneName = currentZone.zoneName holdingCard.zoneName = currentZone.zoneName
else: else:
holdingCard.inZone = true
holdingCard.zoneName = currentZone.zoneName
if holdingCard.inHand: if holdingCard.inHand:
call_deferred("reparent", holdingCard, hand, currentZone) call_deferred("reparent", holdingCard, hand, currentZone)
else: else:
call_deferred("reparent", holdingCard, cards, currentZone) call_deferred("reparent", holdingCard, cards, currentZone)
holdingCard.inZone = true
holdingCard.zoneName = currentZone.zoneName
elif holdingCard.inZone: elif holdingCard.inZone:
holdingCard.inZone = false holdingCard.inZone = false
# Move from zone to hand/field # Move from zone to hand/field