WIP decks
This commit is contained in:
parent
d553492e00
commit
69e0f4ce75
4 changed files with 15 additions and 5 deletions
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Scripts/Board.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Scenes/Scripts/Camera.gd" type="Script" id=2]
|
||||
[ext_resource path="res://MLPAssets/Background/boardbg.jpg" type="Texture" id=3]
|
||||
[ext_resource path="res://Scenes/BoardUI.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Scenes/Components/Stack.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=1]
|
||||
flags_unshaded = true
|
||||
|
@ -17,7 +18,7 @@ size = Vector2( 16, 9 )
|
|||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Camera" type="Camera" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 0.367808, 0.929902, 0, -0.929902, 0.367808, -0.232958, 4.94606, 3.11883 )
|
||||
transform = Transform( 1, 0, 0, 0, 0.367808, 0.929902, 0, -0.929902, 0.367808, 0, 5.05934, 3.29185 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Hand" type="Spatial" parent="Camera"]
|
||||
|
@ -31,3 +32,5 @@ material/0 = null
|
|||
[node name="BoardUI" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[node name="Cards" type="Spatial" parent="."]
|
||||
|
||||
[node name="Deck" parent="Cards" instance=ExtResource( 5 )]
|
||||
|
|
|
@ -49,12 +49,12 @@ func _input_event(camera, event, click_position, click_normal, shape_idx):
|
|||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
|
||||
# Update click status
|
||||
clicked = event.pressed
|
||||
|
||||
|
||||
# Check for card dropped
|
||||
if not clicked and lifted:
|
||||
emit_signal("card_dropped")
|
||||
lifted = false
|
||||
|
||||
|
||||
# Check double click
|
||||
if event.doubleclick and not inHand and not lifted and not animation.is_playing():
|
||||
if exhausted:
|
||||
|
|
3
Scenes/Components/Stack.tscn
Normal file
3
Scenes/Components/Stack.tscn
Normal file
|
@ -0,0 +1,3 @@
|
|||
[gd_scene format=2]
|
||||
|
||||
[node name="Stack" type="Spatial"]
|
|
@ -123,6 +123,10 @@ func reorder_hand():
|
|||
cardsInHand.sort_custom(TransformSorter, "sort")
|
||||
var size := cardsInHand.size()
|
||||
|
||||
# Check if we have nothing to order
|
||||
if size < 1:
|
||||
return
|
||||
|
||||
# Calculate total width of the player's hand and other things
|
||||
# This is done in two ways, for small hands, MAX_CARD_DISTANCE is usually used
|
||||
# as constant distance between cards, however, as the hand gets larger we don't
|
||||
|
@ -132,7 +136,7 @@ func reorder_hand():
|
|||
var distance := min(distancePerc, MAX_CARD_DISTANCE)
|
||||
var totalWidth := distance * (size-1)
|
||||
var minX := -totalWidth/2
|
||||
|
||||
|
||||
# Iterate over all items, keep track of the index
|
||||
var i := 0
|
||||
for child in cardsInHand:
|
||||
|
|
Loading…
Reference in a new issue