Compare commits
No commits in common. "384f6756fbafced4bbcfbfbc635617b36de03a7b" and "6b996285a3cd4d9c68f0b1902cd693e43baa6995" have entirely different histories.
384f6756fb
...
6b996285a3
16 changed files with 60 additions and 222 deletions
|
@ -21,9 +21,9 @@ compress/lossy_quality=0.8
|
|||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/repeat=true
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=true
|
||||
|
|
BIN
MLPAssets/ExampleCard/ff6.jpg
Normal file
BIN
MLPAssets/ExampleCard/ff6.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -2,8 +2,8 @@
|
|||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.s3tc.stex"
|
||||
path.etc="res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.etc.stex"
|
||||
path.s3tc="res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.s3tc.stex"
|
||||
path.etc="res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.etc.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc" ],
|
||||
"vram_texture": true
|
||||
|
@ -11,8 +11,8 @@ metadata={
|
|||
|
||||
[deps]
|
||||
|
||||
source_file="res://MLPAssets/Placeholders/unknowncard.jpg"
|
||||
dest_files=[ "res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.s3tc.stex", "res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.etc.stex" ]
|
||||
source_file="res://MLPAssets/ExampleCard/ff6.jpg"
|
||||
dest_files=[ "res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.s3tc.stex", "res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.etc.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
@ -25,7 +25,7 @@ flags/repeat=true
|
|||
flags/filter=true
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
|
@ -1,9 +0,0 @@
|
|||
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://MLPAssets/Placeholders/unknowncard.jpg" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags_unshaded = true
|
||||
albedo_texture = ExtResource( 1 )
|
||||
uv1_scale = Vector3( 0.9, 0.9, 1 )
|
||||
uv1_offset = Vector3( 0.05, 0.05, 0 )
|
Binary file not shown.
Before Width: | Height: | Size: 103 KiB |
|
@ -2,17 +2,15 @@
|
|||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.s3tc.stex"
|
||||
path.etc="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.etc.stex"
|
||||
path="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc" ],
|
||||
"vram_texture": true
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://MLPAssets/Textures/CardBack.png"
|
||||
dest_files=[ "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.s3tc.stex", "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.etc.stex" ]
|
||||
dest_files=[ "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
@ -21,9 +19,9 @@ compress/lossy_quality=0.7
|
|||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/repeat=true
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=true
|
||||
|
|
|
@ -22,12 +22,9 @@ transform = Transform( 1, 0, 0, 0, 0.224381, 0.974502, 0, -0.974502, 0.224381, 0
|
|||
fov = 50.0
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="PlayerHand" type="Spatial" parent="Camera"]
|
||||
[node name="Hand" type="Spatial" parent="Camera"]
|
||||
transform = Transform( 0.4, 0, 0, 0, 2.98023e-008, -0.4, 0, 0.4, 2.98023e-008, 0, -0.6, -1.3 )
|
||||
|
||||
[node name="OppHand" type="Spatial" parent="Camera"]
|
||||
transform = Transform( 0.3, 0, 0, 0, -1.31134e-008, 0.3, 0, -0.3, -1.31134e-008, -2.48878e-016, 0.629771, -1.3 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.001, 0 )
|
||||
mesh = SubResource( 2 )
|
||||
|
@ -37,52 +34,21 @@ material/0 = null
|
|||
|
||||
[node name="Cards" type="Spatial" parent="."]
|
||||
|
||||
[node name="P1Deck" parent="Cards" instance=ExtResource( 5 )]
|
||||
[node name="Deck" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.30889, 0, 3.52858 )
|
||||
title = "Deck"
|
||||
zoneName = "player1.deck"
|
||||
faceDown = true
|
||||
|
||||
[node name="P1Graveyard" parent="Cards" instance=ExtResource( 5 )]
|
||||
[node name="Graveyard" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.23371, 0, 3.52858 )
|
||||
title = "Discard pile"
|
||||
title = "Graveyard"
|
||||
zoneName = "player1.graveyard"
|
||||
|
||||
[node name="P1Banished" parent="Cards" instance=ExtResource( 5 )]
|
||||
[node name="Banished" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.23371, 0, 2.40401 )
|
||||
title = "Banished"
|
||||
zoneName = "player1.banished"
|
||||
|
||||
[node name="P2Deck" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 4.309, 0, -3.529 )
|
||||
title = "Deck"
|
||||
zoneName = "player2.deck"
|
||||
faceDown = true
|
||||
|
||||
[node name="P2Graveyard" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 5.234, 0, -3.529 )
|
||||
title = "Discard pile"
|
||||
zoneName = "player2.graveyard"
|
||||
|
||||
[node name="P2Banished" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 5.234, 0, -2.404 )
|
||||
title = "Banished"
|
||||
zoneName = "player2.banished"
|
||||
|
||||
[node name="P1Problem" 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 )
|
||||
title = "Problem"
|
||||
zoneName = "player1.problem"
|
||||
|
||||
[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 )
|
||||
title = "Problem"
|
||||
zoneName = "player2.problem"
|
||||
[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/P1Banished" to="." method="_card_picked_zone" binds= [ "player1.banished" ]]
|
||||
[connection signal="card_picked" from="Cards/P2Deck" to="." method="_card_picked_zone" binds= [ "player1.deck" ]]
|
||||
[connection signal="card_picked" from="Cards/P2Graveyard" to="." method="_card_picked_zone" binds= [ "player1.graveyard" ]]
|
||||
[connection signal="card_picked" from="Cards/P2Banished" to="." method="_card_picked_zone" binds= [ "player1.banished" ]]
|
||||
[connection signal="card_picked" from="Cards/P1Problem" to="." method="_card_picked_zone" binds= [ "player1.graveyard" ]]
|
||||
[connection signal="card_picked" from="Cards/P2Problem" to="." method="_card_picked_zone" binds= [ "player1.graveyard" ]]
|
||||
[connection signal="card_picked" from="Cards/Deck" to="." method="_card_picked_zone" binds= [ "player1.deck" ]]
|
||||
[connection signal="card_picked" from="Cards/Graveyard" to="." method="_card_picked_zone" binds= [ "player1.graveyard" ]]
|
||||
[connection signal="card_picked" from="Cards/Banished" to="." method="_card_picked_zone" binds= [ "player1.banished" ]]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Scripts/BoardUI.gd" type="Script" id=1]
|
||||
[ext_resource path="res://MLPAssets/Placeholders/unknowncard.jpg" type="Texture" id=2]
|
||||
[ext_resource path="res://MLPAssets/ExampleCard/ff6.jpg" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "fade ui card"
|
||||
length = 0.1
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("CardZoom:visible")
|
||||
tracks/0/path = NodePath("TextureRect:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
|
@ -20,7 +20,7 @@ tracks/0/keys = {
|
|||
"values": [ false, true ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("CardZoom:modulate")
|
||||
tracks/1/path = NodePath("TextureRect:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
|
@ -32,7 +32,7 @@ tracks/1/keys = {
|
|||
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("CardZoom:margin_top")
|
||||
tracks/2/path = NodePath("TextureRect:margin_top")
|
||||
tracks/2/interp = 2
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
|
@ -50,7 +50,7 @@ anchor_bottom = 1.0
|
|||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CardZoom" type="TextureRect" parent="."]
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
modulate = Color( 1, 1, 1, 0 )
|
||||
margin_left = 40.0
|
||||
|
|
|
@ -13,26 +13,13 @@ var clicked := false
|
|||
var exhausted := false
|
||||
var lifted := false
|
||||
var flipped := false
|
||||
var cardID := "" setget set_cardid
|
||||
var cardID := ""
|
||||
var playerID := 0
|
||||
var inHand := false
|
||||
var inZone := false
|
||||
var zoneName = ""
|
||||
var cardMat = preload("res://MLPAssets/Placeholders/CardMat.tres")
|
||||
var ready = false
|
||||
|
||||
onready var animation := $CardModel/Border/AnimationPlayer
|
||||
onready var cardImage := $CardModel/Border/CardImage
|
||||
onready var texture: Texture = cardImage.get_surface_material(0)
|
||||
|
||||
func set_cardid(val: String):
|
||||
cardID = val
|
||||
if ready:
|
||||
Remote.fetch(Remote.IMGURL + val + ".jpg", self, "_card_fetched")
|
||||
|
||||
func _ready():
|
||||
Remote.fetch(Remote.IMGURL + cardID + ".jpg", self, "_card_fetched")
|
||||
ready = true
|
||||
|
||||
func _mouse_hover():
|
||||
emit_signal("card_selected")
|
||||
|
@ -40,7 +27,6 @@ func _mouse_hover():
|
|||
func _mouse_blur():
|
||||
emit_signal("card_unselected")
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _input_event(camera, event, click_position, click_normal, shape_idx):
|
||||
# Mouse motion
|
||||
if clicked and event is InputEventMouseMotion:
|
||||
|
@ -68,18 +54,12 @@ func _input_event(camera, event, click_position, click_normal, shape_idx):
|
|||
var denom := Vector3.UP.dot(direction)
|
||||
var t: float = (-camera.transform.origin).dot(Vector3.UP) / denom;
|
||||
translation = origin + direction * t
|
||||
# Rotate depending on what side of the board it is
|
||||
if translation.z < 0:
|
||||
rotation.y = PI
|
||||
else:
|
||||
rotation.y = 0
|
||||
# Right click
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_RIGHT:
|
||||
# Show menu
|
||||
emit_signal("card_menu")
|
||||
# Left click
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and clickable():
|
||||
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
|
||||
# Update click status
|
||||
clicked = event.pressed
|
||||
|
||||
|
@ -98,12 +78,6 @@ func _input_event(camera, event, click_position, click_normal, shape_idx):
|
|||
animation.play("tap")
|
||||
exhausted = true
|
||||
|
||||
func clickable() -> bool:
|
||||
#TODO Better control over if a card can be taken or not
|
||||
if playerID == 0:
|
||||
return true
|
||||
return false
|
||||
|
||||
func reset_transform():
|
||||
$CardModel.translation = Vector3.ZERO
|
||||
$CardModel.rotation = Vector3.ZERO
|
||||
|
@ -139,23 +113,4 @@ func disableInput():
|
|||
$CollisionShape.disabled = true
|
||||
|
||||
func enableInput():
|
||||
$CollisionShape.disabled = false
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _card_fetched(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray):
|
||||
assert(result == HTTPRequest.RESULT_SUCCESS)
|
||||
var img = Image.new()
|
||||
var err = img.load_jpg_from_buffer(body)
|
||||
assert(err == OK)
|
||||
# Depending if card pic is a problem or not, rotate the card image mesh
|
||||
if img.get_width() > img.get_height():
|
||||
cardImage.scale = Vector3(0.45,1,0.319)
|
||||
cardImage.rotation.y = PI/2
|
||||
else:
|
||||
cardImage.scale = Vector3(0.319,1,0.45)
|
||||
cardImage.rotation.y = 0
|
||||
var mat = cardMat.duplicate()
|
||||
texture = ImageTexture.new()
|
||||
texture.create_from_image(img)
|
||||
mat.albedo_texture = texture
|
||||
cardImage.set_surface_material(0, mat)
|
||||
$CollisionShape.disabled = false
|
|
@ -1,9 +1,9 @@
|
|||
[gd_scene load_steps=13 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Components/Card.gd" type="Script" id=1]
|
||||
[ext_resource path="res://MLPAssets/Models/cardborder.obj" type="ArrayMesh" id=2]
|
||||
[ext_resource path="res://MLPAssets/Models/cardborder.material" type="Material" id=3]
|
||||
[ext_resource path="res://MLPAssets/Placeholders/CardMat.tres" type="Material" id=4]
|
||||
[ext_resource path="res://MLPAssets/ExampleCard/ff6.jpg" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
margin = 0.001
|
||||
|
@ -127,6 +127,12 @@ tracks/0/keys = {
|
|||
|
||||
[sub_resource type="PlaneMesh" id=8]
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=9]
|
||||
flags_unshaded = true
|
||||
albedo_texture = ExtResource( 4 )
|
||||
uv1_scale = Vector3( 0.9, 0.9, 1 )
|
||||
uv1_offset = Vector3( 0.05, 0.05, 0 )
|
||||
|
||||
[node name="Card" type="Area"]
|
||||
input_capture_on_drag = true
|
||||
script = ExtResource( 1 )
|
||||
|
@ -152,7 +158,7 @@ anims/tap = SubResource( 7 )
|
|||
[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 )
|
||||
mesh = SubResource( 8 )
|
||||
material/0 = ExtResource( 4 )
|
||||
material/0 = SubResource( 9 )
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
[connection signal="input_event" from="." to="." method="_input_event"]
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Components/Stack.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
extents = Vector3( 0.424389, 0.024053, 0.546632 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=5]
|
||||
flags_transparent = true
|
||||
flags_unshaded = true
|
||||
flags_vertex_lighting = true
|
||||
flags_do_not_receive_shadows = true
|
||||
flags_disable_ambient_light = true
|
||||
albedo_color = Color( 1, 1, 1, 0.392157 )
|
||||
|
||||
[sub_resource type="DynamicFontData" id=2]
|
||||
font_path = "res://UIAssets/Fonts/Catamaran-Bold.ttf"
|
||||
|
||||
|
@ -32,18 +24,16 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0239744, 0 )
|
|||
shape = SubResource( 1 )
|
||||
|
||||
[node name="CSGBox" type="CSGBox" parent="."]
|
||||
transform = Transform( 0.802373, 0, 0, 0, 1, 0, 0, 0, 0.81647, 0, 0, 0 )
|
||||
width = 0.85
|
||||
transform = Transform( 0.85598, 0, 0, 0, 1, 0, 0, 0, 0.871019, 0, 0, 0 )
|
||||
width = 0.946586
|
||||
height = 0.002
|
||||
depth = 1.15
|
||||
material = SubResource( 5 )
|
||||
depth = 1.18809
|
||||
|
||||
[node name="CSGBox2" type="CSGBox" parent="CSGBox"]
|
||||
transform = Transform( 1.00679, 0, 0, 0, 1.00679, 0, 0, 0, 1.00679, 0, 0, 0 )
|
||||
operation = 2
|
||||
width = 0.8
|
||||
width = 0.891339
|
||||
height = 0.102173
|
||||
depth = 1.1
|
||||
depth = 1.1406
|
||||
|
||||
[node name="CSGBox3" type="CSGBox" parent="CSGBox"]
|
||||
operation = 2
|
||||
|
@ -72,7 +62,7 @@ align = 1
|
|||
valign = 1
|
||||
|
||||
[node name="LabelSprite" 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.5853, 0.810817, -3.54419e-008, 0, -4.37114e-008, -1, -0.810817, 0.5853, -2.55843e-008, 1.05839e-009, 0.0298628, 7.64017e-010 )
|
||||
texture = SubResource( 4 )
|
||||
region_rect = Rect2( 0, 0, 30, 30 )
|
||||
[connection signal="mouse_entered" from="." to="." method="_mouse_entered"]
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
extends Node
|
||||
|
||||
const HOST = "https://mlpccg.zyg.ovh/"
|
||||
const IMGURL = HOST + "images/cards/"
|
||||
|
||||
func res_file_name(url: String) -> String:
|
||||
return "user://" + url.trim_prefix(HOST).replace("/","_")
|
||||
|
||||
func fetch(url: String, cbObj: Object, cbFn: String):
|
||||
# Check for cached resource
|
||||
var file := File.new()
|
||||
var fname := res_file_name(url)
|
||||
# Return cached resource if available
|
||||
if file.file_exists(fname):
|
||||
file.open(fname, File.READ)
|
||||
var flen := file.get_len()
|
||||
var buf := file.get_buffer(flen)
|
||||
cbObj.call(cbFn, HTTPRequest.RESULT_SUCCESS, 200, [], buf)
|
||||
return
|
||||
var req := HTTPRequest.new()
|
||||
add_child(req)
|
||||
req.connect("request_completed", self, "_request_completed", [url, cbObj, cbFn])
|
||||
req.request(url)
|
||||
|
||||
func _request_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray, url: String, cbObj: Object, cbFn: String):
|
||||
# Cache result for later
|
||||
if result == HTTPRequest.RESULT_SUCCESS:
|
||||
# Get file name by trimming the host
|
||||
var file := File.new()
|
||||
file.open(res_file_name(url), File.WRITE)
|
||||
file.store_buffer(body)
|
||||
file.close()
|
||||
# Call callback
|
||||
cbObj.call(cbFn, result, response_code, headers, body)
|
|
@ -1,6 +0,0 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Global/Remote.gd" type="Script" id=1]
|
||||
|
||||
[node name="Remote" type="Node"]
|
||||
script = ExtResource( 1 )
|
|
@ -5,8 +5,7 @@ class_name Board
|
|||
onready var CardTemplate := preload("res://Scenes/Components/Card.tscn")
|
||||
|
||||
onready var camera := $Camera
|
||||
onready var hand := $Camera/PlayerHand
|
||||
onready var oppHand := $Camera/OppHand
|
||||
onready var hand := $Camera/Hand
|
||||
onready var ui := $BoardUI
|
||||
onready var cards := $Cards
|
||||
|
||||
|
@ -20,31 +19,18 @@ var mouseOrigin: Vector2
|
|||
var lastCameraTransform: Transform
|
||||
|
||||
onready var zones: Dictionary = {
|
||||
"player1.deck": $Cards/P1Deck,
|
||||
"player1.banished": $Cards/P1Banished,
|
||||
"player1.graveyard": $Cards/P1Graveyard,
|
||||
"player1.problem": $Cards/P1Problem,
|
||||
"player2.deck": $Cards/P2Deck,
|
||||
"player2.banished": $Cards/P2Banished,
|
||||
"player2.graveyard": $Cards/P2Graveyard,
|
||||
"player2.problem": $Cards/P2Problem
|
||||
"player1.deck": $Cards/Deck,
|
||||
"player1.banished": $Cards/Banished,
|
||||
"player1.graveyard": $Cards/Graveyard
|
||||
}
|
||||
|
||||
func _ready():
|
||||
add_card("pr10", 0, false)
|
||||
add_card("ff33", 0, true)
|
||||
add_card("ff100", 0, true)
|
||||
add_card("ff44", 0, true)
|
||||
add_card("eo11", 0, true)
|
||||
add_card("pr168", 0, true)
|
||||
add_card("ad176", 0, true)
|
||||
|
||||
add_card("ff33", 1, true)
|
||||
add_card("ff33", 1, true)
|
||||
add_card("ff33", 1, true)
|
||||
add_card("ff33", 1, true)
|
||||
reorder_hand(0)
|
||||
reorder_hand(1)
|
||||
add_card("ff36", 0, false)
|
||||
add_card("ff36", 0, true)
|
||||
add_card("ff36", 0, true)
|
||||
add_card("ff36", 0, true)
|
||||
add_card("ff36", 0, true)
|
||||
reorder_hand()
|
||||
|
||||
func _input(event: InputEvent):
|
||||
# Camera zoom
|
||||
|
@ -149,7 +135,7 @@ func reparent(object: Node, from: Node, to: Node):
|
|||
from.remove_child(object)
|
||||
to.add_child(object)
|
||||
object.set_owner(to)
|
||||
reorder_hand(0)
|
||||
reorder_hand()
|
||||
|
||||
func add_card(cardID: String, playerID: int, inHand: bool):
|
||||
var card := CardTemplate.instance()
|
||||
|
@ -165,11 +151,8 @@ func add_card(cardID: String, playerID: int, inHand: bool):
|
|||
card.connect("card_dropped_anim", self, "check_hand_drop", [card])
|
||||
card.connect("card_menu", ui, "show_card_menu", [card])
|
||||
if inHand:
|
||||
# TODO support for >2 players
|
||||
if playerID == 0:
|
||||
hand.add_child(card)
|
||||
else:
|
||||
oppHand.add_child(card)
|
||||
# TODO if player != me, put in opponent's hand
|
||||
hand.add_child(card)
|
||||
else:
|
||||
cards.add_child(card)
|
||||
|
||||
|
@ -177,19 +160,15 @@ func check_hand_drop(card: Card):
|
|||
# Re-order hand as soon as the animation is over
|
||||
if card.inHand:
|
||||
card.reset_transform()
|
||||
reorder_hand(0)
|
||||
reorder_hand()
|
||||
|
||||
const MAX_CARD_DISTANCE := 0.5
|
||||
const HAND_SCREEN_PERC := 0.6
|
||||
const CARD_ROTATION := 0.03
|
||||
const UNITSPERPX := 0.003
|
||||
|
||||
func reorder_hand(playerID: int):
|
||||
var cardsInHand: Array = []
|
||||
if playerID == 0:
|
||||
cardsInHand = hand.get_children()
|
||||
else:
|
||||
cardsInHand = oppHand.get_children()
|
||||
func reorder_hand():
|
||||
var cardsInHand: Array = hand.get_children()
|
||||
cardsInHand.sort_custom(TransformSorter, "sort")
|
||||
var size := cardsInHand.size()
|
||||
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
extends Control
|
||||
|
||||
onready var animation = $AnimationPlayer
|
||||
onready var cardPic = $CardZoom
|
||||
|
||||
var menu: PopupMenu = null
|
||||
|
||||
func _card_selected(card: Card):
|
||||
# TODO Hide card if it shouldn't be visible
|
||||
cardPic.texture = card.texture
|
||||
animation.play("fade ui card")
|
||||
|
||||
func _card_unselected(card: Card):
|
||||
|
|
|
@ -36,10 +36,6 @@ config/name="MLP CARD GAME"
|
|||
run/main_scene="res://Scenes/Board.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
Remote="*res://Scenes/Global/Remote.tscn"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=1280
|
||||
|
|
Loading…
Reference in a new issue