Compare commits
2 commits
6b996285a3
...
384f6756fb
Author | SHA1 | Date | |
---|---|---|---|
384f6756fb | |||
0feb249439 |
16 changed files with 222 additions and 60 deletions
|
@ -21,9 +21,9 @@ compress/lossy_quality=0.8
|
|||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=true
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
9
MLPAssets/Placeholders/CardMat.tres
Normal file
9
MLPAssets/Placeholders/CardMat.tres
Normal file
|
@ -0,0 +1,9 @@
|
|||
[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 )
|
BIN
MLPAssets/Placeholders/unknowncard.jpg
Normal file
BIN
MLPAssets/Placeholders/unknowncard.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 KiB |
|
@ -2,8 +2,8 @@
|
|||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.s3tc.stex"
|
||||
path.etc="res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.etc.stex"
|
||||
path.s3tc="res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.s3tc.stex"
|
||||
path.etc="res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.etc.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc" ],
|
||||
"vram_texture": true
|
||||
|
@ -11,8 +11,8 @@ metadata={
|
|||
|
||||
[deps]
|
||||
|
||||
source_file="res://MLPAssets/ExampleCard/ff6.jpg"
|
||||
dest_files=[ "res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.s3tc.stex", "res://.import/ff6.jpg-e066dece7da740f732cd9a31f65091eb.etc.stex" ]
|
||||
source_file="res://MLPAssets/Placeholders/unknowncard.jpg"
|
||||
dest_files=[ "res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.s3tc.stex", "res://.import/unknowncard.jpg-ff165d2aeb957f4e1010ac777150182d.etc.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
@ -25,7 +25,7 @@ flags/repeat=true
|
|||
flags/filter=true
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
|
@ -2,15 +2,17 @@
|
|||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.stex"
|
||||
path.s3tc="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.s3tc.stex"
|
||||
path.etc="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.etc.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": [ "s3tc", "etc" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://MLPAssets/Textures/CardBack.png"
|
||||
dest_files=[ "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.stex" ]
|
||||
dest_files=[ "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.s3tc.stex", "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.etc.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
@ -19,9 +21,9 @@ compress/lossy_quality=0.7
|
|||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=true
|
||||
|
|
|
@ -22,9 +22,12 @@ transform = Transform( 1, 0, 0, 0, 0.224381, 0.974502, 0, -0.974502, 0.224381, 0
|
|||
fov = 50.0
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Hand" type="Spatial" parent="Camera"]
|
||||
[node name="PlayerHand" 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 )
|
||||
|
@ -34,21 +37,52 @@ material/0 = null
|
|||
|
||||
[node name="Cards" type="Spatial" parent="."]
|
||||
|
||||
[node name="Deck" parent="Cards" instance=ExtResource( 5 )]
|
||||
[node name="P1Deck" 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="Graveyard" parent="Cards" instance=ExtResource( 5 )]
|
||||
[node name="P1Graveyard" parent="Cards" instance=ExtResource( 5 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.23371, 0, 3.52858 )
|
||||
title = "Graveyard"
|
||||
title = "Discard pile"
|
||||
zoneName = "player1.graveyard"
|
||||
|
||||
[node name="Banished" parent="Cards" instance=ExtResource( 5 )]
|
||||
[node name="P1Banished" 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"
|
||||
[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" ]]
|
||||
|
||||
[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" ]]
|
||||
|
|
|
@ -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/ExampleCard/ff6.jpg" type="Texture" id=2]
|
||||
[ext_resource path="res://MLPAssets/Placeholders/unknowncard.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("TextureRect:visible")
|
||||
tracks/0/path = NodePath("CardZoom: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("TextureRect:modulate")
|
||||
tracks/1/path = NodePath("CardZoom: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("TextureRect:margin_top")
|
||||
tracks/2/path = NodePath("CardZoom: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="TextureRect" type="TextureRect" parent="."]
|
||||
[node name="CardZoom" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
modulate = Color( 1, 1, 1, 0 )
|
||||
margin_left = 40.0
|
||||
|
|
|
@ -13,13 +13,26 @@ var clicked := false
|
|||
var exhausted := false
|
||||
var lifted := false
|
||||
var flipped := false
|
||||
var cardID := ""
|
||||
var cardID := "" setget set_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")
|
||||
|
@ -27,6 +40,7 @@ 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:
|
||||
|
@ -54,12 +68,18 @@ 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:
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and clickable():
|
||||
|
||||
# Update click status
|
||||
clicked = event.pressed
|
||||
|
||||
|
@ -78,6 +98,12 @@ 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
|
||||
|
@ -113,4 +139,23 @@ func disableInput():
|
|||
$CollisionShape.disabled = true
|
||||
|
||||
func enableInput():
|
||||
$CollisionShape.disabled = false
|
||||
$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)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=13 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/ExampleCard/ff6.jpg" type="Texture" id=4]
|
||||
[ext_resource path="res://MLPAssets/Placeholders/CardMat.tres" type="Material" id=4]
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
margin = 0.001
|
||||
|
@ -127,12 +127,6 @@ 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 )
|
||||
|
@ -158,7 +152,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 = SubResource( 9 )
|
||||
material/0 = ExtResource( 4 )
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
[connection signal="input_event" from="." to="." method="_input_event"]
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 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"
|
||||
|
||||
|
@ -24,16 +32,18 @@ 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.85598, 0, 0, 0, 1, 0, 0, 0, 0.871019, 0, 0, 0 )
|
||||
width = 0.946586
|
||||
transform = Transform( 0.802373, 0, 0, 0, 1, 0, 0, 0, 0.81647, 0, 0, 0 )
|
||||
width = 0.85
|
||||
height = 0.002
|
||||
depth = 1.18809
|
||||
depth = 1.15
|
||||
material = SubResource( 5 )
|
||||
|
||||
[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.891339
|
||||
width = 0.8
|
||||
height = 0.102173
|
||||
depth = 1.1406
|
||||
depth = 1.1
|
||||
|
||||
[node name="CSGBox3" type="CSGBox" parent="CSGBox"]
|
||||
operation = 2
|
||||
|
@ -62,7 +72,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, 1.05839e-009, 0.0298628, 7.64017e-010 )
|
||||
transform = Transform( 0.5853, 0.810817, -3.54419e-008, 0, -4.37114e-008, -1, -0.810817, 0.5853, -2.55843e-008, 0, 0, 0 )
|
||||
texture = SubResource( 4 )
|
||||
region_rect = Rect2( 0, 0, 30, 30 )
|
||||
[connection signal="mouse_entered" from="." to="." method="_mouse_entered"]
|
||||
|
|
34
Scenes/Global/Remote.gd
Normal file
34
Scenes/Global/Remote.gd
Normal file
|
@ -0,0 +1,34 @@
|
|||
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)
|
6
Scenes/Global/Remote.tscn
Normal file
6
Scenes/Global/Remote.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[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,7 +5,8 @@ class_name Board
|
|||
onready var CardTemplate := preload("res://Scenes/Components/Card.tscn")
|
||||
|
||||
onready var camera := $Camera
|
||||
onready var hand := $Camera/Hand
|
||||
onready var hand := $Camera/PlayerHand
|
||||
onready var oppHand := $Camera/OppHand
|
||||
onready var ui := $BoardUI
|
||||
onready var cards := $Cards
|
||||
|
||||
|
@ -19,18 +20,31 @@ var mouseOrigin: Vector2
|
|||
var lastCameraTransform: Transform
|
||||
|
||||
onready var zones: Dictionary = {
|
||||
"player1.deck": $Cards/Deck,
|
||||
"player1.banished": $Cards/Banished,
|
||||
"player1.graveyard": $Cards/Graveyard
|
||||
"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
|
||||
}
|
||||
|
||||
func _ready():
|
||||
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()
|
||||
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)
|
||||
|
||||
func _input(event: InputEvent):
|
||||
# Camera zoom
|
||||
|
@ -135,7 +149,7 @@ func reparent(object: Node, from: Node, to: Node):
|
|||
from.remove_child(object)
|
||||
to.add_child(object)
|
||||
object.set_owner(to)
|
||||
reorder_hand()
|
||||
reorder_hand(0)
|
||||
|
||||
func add_card(cardID: String, playerID: int, inHand: bool):
|
||||
var card := CardTemplate.instance()
|
||||
|
@ -151,8 +165,11 @@ 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 if player != me, put in opponent's hand
|
||||
hand.add_child(card)
|
||||
# TODO support for >2 players
|
||||
if playerID == 0:
|
||||
hand.add_child(card)
|
||||
else:
|
||||
oppHand.add_child(card)
|
||||
else:
|
||||
cards.add_child(card)
|
||||
|
||||
|
@ -160,15 +177,19 @@ func check_hand_drop(card: Card):
|
|||
# Re-order hand as soon as the animation is over
|
||||
if card.inHand:
|
||||
card.reset_transform()
|
||||
reorder_hand()
|
||||
reorder_hand(0)
|
||||
|
||||
const MAX_CARD_DISTANCE := 0.5
|
||||
const HAND_SCREEN_PERC := 0.6
|
||||
const CARD_ROTATION := 0.03
|
||||
const UNITSPERPX := 0.003
|
||||
|
||||
func reorder_hand():
|
||||
var cardsInHand: Array = hand.get_children()
|
||||
func reorder_hand(playerID: int):
|
||||
var cardsInHand: Array = []
|
||||
if playerID == 0:
|
||||
cardsInHand = hand.get_children()
|
||||
else:
|
||||
cardsInHand = oppHand.get_children()
|
||||
cardsInHand.sort_custom(TransformSorter, "sort")
|
||||
var size := cardsInHand.size()
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
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,6 +36,10 @@ 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