Compare commits

...

5 Commits

8 changed files with 285 additions and 203 deletions

View File

@ -3,7 +3,7 @@
[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/BattleScene.gd" type="Script" id=3]
[ext_resource path="res://UI/CardView.tscn" type="PackedScene" id=4]
[ext_resource path="res://UI/CardContainer.tscn" type="PackedScene" id=4]
[ext_resource path="res://UI/DiceView.tscn" type="PackedScene" id=5]
[ext_resource path="res://Assets/TestTile.png" type="Texture" id=6]
[ext_resource path="res://Characters/Enemy.tscn" type="PackedScene" id=7]

View File

@ -1,5 +1,4 @@
tool
extends Control
extends Node
signal return_dice(dice_number)
signal do_movement(movement_range)
@ -7,84 +6,10 @@ signal do_damage(damage, damage_range)
signal do_effect(effect, effect_range)
signal card_removed(card_self)
const TYPE_COLORS = [
Color("#db4758"), # DAMAGE
Color("#3cc361"), # UTILITY
Color("#bcb64f"), # SPECIAL
Color("#bc5ec6"), # EFFECT
Color("#a4a4a4"), # MOVEMENT
]
const dice_node = preload("res://UI/Dice.tscn")
const dice_texture_string : String = "res://Assets/Dice/Dice%s.png"
export (Resource) var card_info
var input_dice = []
var addition_dice_amount : int setget _set_addition_dice
var hovering_dice setget _set_hovering_dice
func _set_hovering_dice(dice_value):
var input_dice0 = $VBox/AutoGrid.get_node_from_grid("InputDice0")
if hovering_dice == dice_value:
return
hovering_dice = dice_value
#remove the dice preview if not hovering
if dice_value == null:
var input_dice_children = input_dice0.get_children()
if len(input_dice_children) <= 1:
return
var old_dice = input_dice_children[1]
input_dice0.remove_child(old_dice)
return
var new_dice = dice_node.instance()
new_dice.dice_value = dice_value
input_dice0.add_child(new_dice)
func _set_addition_dice(new_amount):
addition_dice_amount = new_amount
$VBox/AutoGrid.get_node_from_grid("InputDice0").get_child("Number").text = String(new_amount)
func _ready():
# change the color of the panel to match the appropriate type
var card_style = $PanelContainer.get('custom_styles/panel').duplicate(true)
card_style.set_bg_color(TYPE_COLORS[card_info.type])
$PanelContainer.set('custom_styles/panel', card_style)
# add more input dice if needed
for i in range(1, card_info.number_of_dice):
var new_input_dice = get_node("VBox/AutoGrid/InputDice0").duplicate(true)
new_input_dice.name = "InputDice%s" % i
$VBox/AutoGrid.add_child(new_input_dice)
# change the name and description
$VBox/Name.text = card_info.name
$VBox/Description.text = card_info.description
#maybe set the addition amount
if card_info.addition_dice:
self.addition_dice_amount = card_info.addition_amount
# show the requirements for a dice
# TODO more difference from addition, smaller font, >, <, etc.
if len(card_info.accepted_dice) != 0:
var dice_string : String = ""
for num in card_info.accepted_dice:
dice_string += String(num)
dice_string += ","
dice_string = dice_string.trim_suffix(",")
$VBox/AutoGrid/InputDice0/Number.text = dice_string
var addition_dice_amount = card_info.addition_amount
func dice_inputted(dice_number):
@ -122,20 +47,19 @@ func dice_inputted(dice_number):
input_dice.remove(0)
# Put the Dice in the slot
var input_dice0 = $VBox/AutoGrid.get_node_from_grid("InputDice0")
input_dice0.texture = load(dice_texture_string % dice_number)
# -- RUN DICE CHECKS --
if card_info.addition_dice:
self.addition_dice_amount -= dice_number
input_dice.remove(0)
if addition_dice_amount > 0:
return
else:
run_card()
# if the addition type, then lower the counter by the input dice
# also check (and run) if the amount is reaches and
if card_info.addition_dice:
addition_dice_amount -= dice_number
if addition_dice_amount <= 0:
run_card()
return
# run the card if the correct number of dice have been inputted (and normal dice)
if (len(input_dice) == card_info.number_of_dice
and not card_info.addition_dice):
run_card()

View File

@ -1,100 +0,0 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://UI/Card.gd" type="Script" id=1]
[ext_resource path="res://Assets/CardDB/Default.tres" type="Resource" id=2]
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Bold.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://Assets/DiceInput.png" type="Texture" id=4]
[ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=5]
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Medium.ttf" type="DynamicFontData" id=6]
[sub_resource type="StyleBoxFlat" id=8]
bg_color = Color( 0.858824, 0.278431, 0.345098, 1 )
corner_radius_top_left = 20
corner_radius_top_right = 20
corner_radius_bottom_right = 20
corner_radius_bottom_left = 20
[sub_resource type="DynamicFontData" id=4]
font_path = "res://Assets/Metropolis-font/Metropolis-Bold.ttf"
[sub_resource type="DynamicFont" id=2]
size = 30
use_filter = true
font_data = SubResource( 4 )
[sub_resource type="DynamicFont" id=7]
size = 64
use_filter = true
font_data = ExtResource( 6 )
[sub_resource type="DynamicFont" id=5]
size = 20
use_filter = true
font_data = ExtResource( 3 )
[node name="Card" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
card_info = ExtResource( 2 )
[node name="PanelContainer" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_styles/panel = SubResource( 8 )
[node name="VBox" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = 10.0
margin_right = -10.0
margin_bottom = -10.0
[node name="Name" type="Label" parent="VBox"]
margin_right = 1260.0
margin_bottom = 31.0
custom_fonts/font = SubResource( 2 )
text = "Default"
align = 1
autowrap = true
[node name="AutoGrid" parent="VBox" instance=ExtResource( 5 )]
margin_top = 35.0
margin_right = 1260.0
margin_bottom = 606.0
[node name="InputDice0" type="TextureRect" parent="VBox/AutoGrid"]
margin_left = 42.0
margin_top = 5.0
margin_right = 192.0
margin_bottom = 155.0
rect_min_size = Vector2( 75, 75 )
size_flags_horizontal = 3
size_flags_vertical = 3
texture = ExtResource( 4 )
expand = true
stretch_mode = 6
[node name="Number" type="Label" parent="VBox/AutoGrid/InputDice0"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_fonts/font = SubResource( 7 )
align = 1
valign = 1
[node name="Description" type="Label" parent="VBox"]
margin_top = 610.0
margin_right = 1260.0
margin_bottom = 700.0
rect_min_size = Vector2( 0, 90 )
custom_fonts/font = SubResource( 5 )
text = "Default Description"
align = 1
valign = 1
autowrap = true

22
UI/CardContainer.tscn Normal file
View File

@ -0,0 +1,22 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://UI/CardContainer.gd" type="Script" id=5]
[node name="CardContainer" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 5 )
[node name="Margin" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 30.0
margin_top = 30.0
margin_right = -30.0
margin_bottom = -30.0
[node name="HBox" type="HBoxContainer" parent="Margin"]
margin_right = 1220.0
margin_bottom = 660.0
rect_min_size = Vector2( 0, 300 )
custom_constants/separation = 50

View File

@ -1,22 +1,96 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://UI/CardView.gd" type="Script" id=5]
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Medium.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Bold.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://Assets/DiceInput.png" type="Texture" id=5]
[ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=6]
[sub_resource type="StyleBoxFlat" id=8]
bg_color = Color( 0.858824, 0.278431, 0.345098, 1 )
corner_radius_top_left = 20
corner_radius_top_right = 20
corner_radius_bottom_right = 20
corner_radius_bottom_left = 20
[sub_resource type="DynamicFontData" id=4]
font_path = "res://Assets/Metropolis-font/Metropolis-Bold.ttf"
[sub_resource type="DynamicFont" id=2]
size = 30
use_filter = true
font_data = SubResource( 4 )
[sub_resource type="DynamicFont" id=7]
size = 64
use_filter = true
font_data = ExtResource( 2 )
[sub_resource type="DynamicFont" id=5]
size = 20
use_filter = true
font_data = ExtResource( 4 )
[node name="CardView" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 5 )
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Margin" type="MarginContainer" parent="."]
[node name="PanelContainer" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 30.0
margin_top = 30.0
margin_right = -30.0
margin_bottom = -30.0
custom_styles/panel = SubResource( 8 )
[node name="HBox" type="HBoxContainer" parent="Margin"]
margin_right = 1220.0
margin_bottom = 660.0
rect_min_size = Vector2( 0, 300 )
custom_constants/separation = 50
[node name="VBox" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = 10.0
margin_right = -10.0
margin_bottom = -10.0
[node name="Name" type="Label" parent="VBox"]
margin_right = 1260.0
margin_bottom = 31.0
custom_fonts/font = SubResource( 2 )
text = "Default"
align = 1
autowrap = true
[node name="AutoGrid" parent="VBox" instance=ExtResource( 6 )]
margin_top = 35.0
margin_right = 1260.0
margin_bottom = 606.0
[node name="InputDice0" type="TextureRect" parent="VBox/AutoGrid"]
margin_left = 42.0
margin_top = 5.0
margin_right = 192.0
margin_bottom = 155.0
rect_min_size = Vector2( 75, 75 )
size_flags_horizontal = 3
size_flags_vertical = 3
texture = ExtResource( 5 )
expand = true
stretch_mode = 6
[node name="Number" type="Label" parent="VBox/AutoGrid/InputDice0"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_fonts/font = SubResource( 7 )
align = 1
valign = 1
[node name="Description" type="Label" parent="VBox"]
margin_top = 610.0
margin_right = 1260.0
margin_bottom = 700.0
rect_min_size = Vector2( 0, 90 )
custom_fonts/font = SubResource( 5 )
text = "Default Description"
align = 1
valign = 1
autowrap = true

9
UI/InputDiceView.gd Normal file
View File

@ -0,0 +1,9 @@
tool
extends Control
func _process(_delta):
# update the pivot offset to make sure the object's animations
# are always centered
$Sprite.rect_pivot_offset = rect_size/2
$Particles2D.position = rect_size/2

153
UI/InputDiceView.tscn Normal file
View File

@ -0,0 +1,153 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Medium.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://Assets/DiceInput.png" type="Texture" id=2]
[ext_resource path="res://UI/InputDiceView.gd" type="Script" id=3]
[sub_resource type="Curve" id=10]
_data = [ Vector2( 0, 0.121591 ), 0.0, 4.0026, 0, 0, Vector2( 1, 0 ), -1.48166, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=11]
curve = SubResource( 10 )
[sub_resource type="ParticlesMaterial" id=12]
lifetime_randomness = 0.12
flag_disable_z = true
direction = Vector3( 0, 0, 0 )
spread = 180.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 44.59
orbit_velocity = 0.56
orbit_velocity_random = 0.48
linear_accel = -1.37
radial_accel = -11.78
scale = 0.01
scale_curve = SubResource( 11 )
hue_variation = 0.03
hue_variation_random = 1.0
[sub_resource type="DynamicFont" id=7]
size = 64
use_filter = true
font_data = ExtResource( 1 )
[sub_resource type="Animation" id=8]
resource_name = "Disappear"
length = 0.5
step = 0.01
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:rect_scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.09, 0.11, 0.5 ),
"transitions": PoolRealArray( 0.406125, 0.392292, 2.07053, 3.36359 ),
"update": 0,
"values": [ Vector2( 1, 1 ), Vector2( 1.2, 1.2 ), Vector2( 1.2, 1.2 ), Vector2( 1e-05, 1e-05 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Sprite:rect_rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.09, 0.11, 0.5 ),
"transitions": PoolRealArray( 0.406125, 0.392292, 2.92817, 3.36359 ),
"update": 0,
"values": [ 0.0, 55.0, 55.0, -155.0 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Particles2D:emitting")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="Animation" id=9]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:rect_scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Sprite:rect_rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ 0.0 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Particles2D:emitting")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ false ]
}
[node name="InputDiceView" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
[node name="Particles2D" type="Particles2D" parent="."]
position = Vector2( 640, 360 )
scale = Vector2( 5, 5 )
emitting = false
amount = 6
lifetime = 0.75
one_shot = true
speed_scale = 2.0
process_material = SubResource( 12 )
texture = ExtResource( 2 )
[node name="ExtraInfo" type="Label" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_fonts/font = SubResource( 7 )
align = 1
valign = 1
[node name="Sprite" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 75, 75 )
rect_pivot_offset = Vector2( 640, 360 )
size_flags_horizontal = 3
size_flags_vertical = 3
texture = ExtResource( 2 )
expand = true
stretch_mode = 6
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/Disappear = SubResource( 8 )
anims/RESET = SubResource( 9 )