WIP decks

This commit is contained in:
Hamcha 2019-05-07 00:18:10 +02:00
parent d553492e00
commit 69e0f4ce75
Signed by: hamcha
GPG key ID: A40413D21021EAEE
4 changed files with 15 additions and 5 deletions

View file

@ -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/Board.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Scripts/Camera.gd" type="Script" id=2] [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://MLPAssets/Background/boardbg.jpg" type="Texture" id=3]
[ext_resource path="res://Scenes/BoardUI.tscn" type="PackedScene" id=4] [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] [sub_resource type="SpatialMaterial" id=1]
flags_unshaded = true flags_unshaded = true
@ -17,7 +18,7 @@ size = Vector2( 16, 9 )
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."] [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 ) script = ExtResource( 2 )
[node name="Hand" type="Spatial" parent="Camera"] [node name="Hand" type="Spatial" parent="Camera"]
@ -31,3 +32,5 @@ material/0 = null
[node name="BoardUI" parent="." instance=ExtResource( 4 )] [node name="BoardUI" parent="." instance=ExtResource( 4 )]
[node name="Cards" type="Spatial" parent="."] [node name="Cards" type="Spatial" parent="."]
[node name="Deck" parent="Cards" instance=ExtResource( 5 )]

View file

@ -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: if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
# Update click status # Update click status
clicked = event.pressed clicked = event.pressed
# Check for card dropped # Check for card dropped
if not clicked and lifted: if not clicked and lifted:
emit_signal("card_dropped") emit_signal("card_dropped")
lifted = false lifted = false
# Check double click # Check double click
if event.doubleclick and not inHand and not lifted and not animation.is_playing(): if event.doubleclick and not inHand and not lifted and not animation.is_playing():
if exhausted: if exhausted:

View file

@ -0,0 +1,3 @@
[gd_scene format=2]
[node name="Stack" type="Spatial"]

View file

@ -123,6 +123,10 @@ func reorder_hand():
cardsInHand.sort_custom(TransformSorter, "sort") cardsInHand.sort_custom(TransformSorter, "sort")
var size := cardsInHand.size() 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 # 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 # 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 # 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 distance := min(distancePerc, MAX_CARD_DISTANCE)
var totalWidth := distance * (size-1) var totalWidth := distance * (size-1)
var minX := -totalWidth/2 var minX := -totalWidth/2
# Iterate over all items, keep track of the index # Iterate over all items, keep track of the index
var i := 0 var i := 0
for child in cardsInHand: for child in cardsInHand: