Added initial hands drawing from decks
This commit is contained in:
parent
cba1d36005
commit
3cb59c172e
|
@ -0,0 +1,67 @@
|
|||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://cards/spawn_trapper.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://cards/spawn_xander.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://cards/spawn_breeze.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://cards/spawn_jumper.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://cards/spawn_flea.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://cards/spawn_falcon.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://cards/spawn_avenger.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://cards/spawn_commodore.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://cards/spawn_creeper.tscn" type="PackedScene" id=9]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
[node name="spawn_avenger" parent="." instance=ExtResource( 7 )]
|
||||
margin_left = 0.0
|
||||
margin_top = 0.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 240.0
|
||||
|
||||
[node name="spawn_breeze" parent="." instance=ExtResource( 3 )]
|
||||
margin_left = 200.0
|
||||
margin_top = 0.0
|
||||
margin_right = 380.0
|
||||
margin_bottom = 240.0
|
||||
|
||||
[node name="spawn_commorode" parent="." instance=ExtResource( 8 )]
|
||||
margin_left = 400.0
|
||||
margin_top = 0.0
|
||||
margin_right = 580.0
|
||||
margin_bottom = 240.0
|
||||
|
||||
[node name="spawn_creeper" parent="." instance=ExtResource( 9 )]
|
||||
margin_left = 600.0
|
||||
margin_top = 0.0
|
||||
margin_right = 780.0
|
||||
margin_bottom = 240.0
|
||||
|
||||
[node name="spawn_falcon" parent="." instance=ExtResource( 6 )]
|
||||
margin_left = 800.0
|
||||
margin_top = 0.0
|
||||
margin_right = 980.0
|
||||
margin_bottom = 240.0
|
||||
|
||||
[node name="spawn_flea" parent="." instance=ExtResource( 5 )]
|
||||
margin_left = 0.0
|
||||
margin_top = 300.0
|
||||
margin_right = 180.0
|
||||
margin_bottom = 540.0
|
||||
|
||||
[node name="spawn_jumper" parent="." instance=ExtResource( 4 )]
|
||||
margin_left = 200.0
|
||||
margin_top = 300.0
|
||||
margin_right = 380.0
|
||||
margin_bottom = 540.0
|
||||
|
||||
[node name="spawn_trapper" parent="." instance=ExtResource( 1 )]
|
||||
margin_left = 400.0
|
||||
margin_top = 300.0
|
||||
margin_right = 580.0
|
||||
margin_bottom = 540.0
|
||||
|
||||
[node name="spawn_xander" parent="." instance=ExtResource( 2 )]
|
||||
margin_left = 600.0
|
||||
margin_top = 300.0
|
||||
margin_right = 780.0
|
||||
margin_bottom = 540.0
|
|
@ -2,9 +2,18 @@ extends Panel
|
|||
|
||||
const BattleHelper = preload("res://helpers/battle.gd")
|
||||
|
||||
export(PackedScene) var deck_attack
|
||||
export(PackedScene) var deck_defend
|
||||
|
||||
onready var deck_attack_cards = deck_attack.instance()
|
||||
onready var deck_defend_cards = deck_defend.instance()
|
||||
|
||||
func _ready():
|
||||
create_hero_units()
|
||||
|
||||
fill_hand($hand_attack, deck_attack_cards)
|
||||
fill_hand($hand_defend, deck_defend_cards)
|
||||
|
||||
func find_free_anchor(anchor_type: String):
|
||||
for anchor in get_tree().get_nodes_in_group("anchors"):
|
||||
if anchor.anchor_type == anchor_type and anchor.is_empty():
|
||||
|
@ -19,3 +28,18 @@ func create_hero_unit(name: String, anchor_type: String):
|
|||
func create_hero_units():
|
||||
create_hero_unit("tomahawk", "attack_start")
|
||||
create_hero_unit("rhino", "defend_start")
|
||||
|
||||
func fill_hand(hand: Node, deck: Node, limit=4):
|
||||
while hand.get_child_count() < 4:
|
||||
var count = deck.get_child_count()
|
||||
var index = floor(rand_range(0, count))
|
||||
var card = deck.get_child(index).duplicate()
|
||||
hand.add_child(card)
|
||||
|
||||
reorganize_hand(hand)
|
||||
|
||||
func reorganize_hand(hand: Node):
|
||||
var i = 0
|
||||
for card in hand.get_children():
|
||||
card.rect_position = Vector2(i * 210, 0)
|
||||
i += 1
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://screens/battle/mechanolith.ogg" type="AudioStream" id=1]
|
||||
[ext_resource path="res://cards/spawn_falcon.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://arenas/normal1.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://screens/battle/background.jpg" type="Texture" id=4]
|
||||
[ext_resource path="res://screens/battle/battle.gd" type="Script" id=5]
|
||||
[ext_resource path="res://cards/spawn_jumper.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://cards/spawn_flea.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://cards/spawn_creeper.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://decks/all.tscn" type="PackedScene" id=9]
|
||||
|
||||
[node name="view" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
|
@ -16,6 +13,8 @@ script = ExtResource( 5 )
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
deck_attack = ExtResource( 9 )
|
||||
deck_defend = ExtResource( 9 )
|
||||
|
||||
[node name="background" type="Sprite" parent="."]
|
||||
position = Vector2( 540, 970 )
|
||||
|
@ -32,28 +31,23 @@ stream = ExtResource( 1 )
|
|||
volume_db = -15.891
|
||||
autoplay = true
|
||||
|
||||
[node name="spawn_falcon" parent="." instance=ExtResource( 2 )]
|
||||
self_modulate = Color( 1, 1, 1, 1 )
|
||||
[node name="hand_attack" type="Control" parent="."]
|
||||
margin_left = 240.0
|
||||
margin_top = 1660.0
|
||||
margin_right = 420.0
|
||||
margin_bottom = 1900.0
|
||||
theme = null
|
||||
|
||||
[node name="spawn_jumper" parent="." instance=ExtResource( 6 )]
|
||||
margin_left = 450.0
|
||||
margin_top = 1660.0
|
||||
margin_right = 630.0
|
||||
margin_bottom = 1900.0
|
||||
|
||||
[node name="spawn_creeper" parent="." instance=ExtResource( 8 )]
|
||||
margin_left = 660.0
|
||||
margin_top = 1660.0
|
||||
margin_right = 840.0
|
||||
margin_bottom = 1900.0
|
||||
|
||||
[node name="spawn_flea" parent="." instance=ExtResource( 7 )]
|
||||
margin_left = 870.0
|
||||
margin_top = 1660.0
|
||||
margin_right = 1050.0
|
||||
margin_bottom = 1900.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false,
|
||||
"_editor_description_": ""
|
||||
}
|
||||
|
||||
[node name="hand_defend" type="Control" parent="."]
|
||||
visible = false
|
||||
modulate = Color( 1, 1, 1, 0 )
|
||||
margin_left = 1180.0
|
||||
margin_top = 760.0
|
||||
margin_right = 1990.0
|
||||
margin_bottom = 1000.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ base_shield_points = 2
|
|||
base_damage_points = 2
|
||||
|
||||
[node name="sprite" parent="." index="0"]
|
||||
scale = Vector2( 2, 2 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="points" parent="." index="1"]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource path="res://units/base_unit.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://units/heroes/tomahawk.png" type="Texture" id=2]
|
||||
|
||||
[node name="tomahawk" instance=ExtResource( 1 )]
|
||||
[node name="unit" instance=ExtResource( 1 )]
|
||||
sprite = ExtResource( 2 )
|
||||
base_move_points = 1
|
||||
base_hull_points = 5
|
||||
|
@ -11,6 +11,7 @@ base_shield_points = 2
|
|||
base_damage_points = 2
|
||||
|
||||
[node name="sprite" parent="." index="0"]
|
||||
scale = Vector2( 2, 2 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="points" parent="." index="1"]
|
||||
|
|
Loading…
Reference in New Issue