diff --git a/Globals/player_data.gd b/Globals/player_data.gd new file mode 100644 index 0000000..106cb23 --- /dev/null +++ b/Globals/player_data.gd @@ -0,0 +1,3 @@ +extends Node + +var die_inventory: Array[DieData] diff --git a/Globals/player_data.gd.uid b/Globals/player_data.gd.uid new file mode 100644 index 0000000..bebaf73 --- /dev/null +++ b/Globals/player_data.gd.uid @@ -0,0 +1 @@ +uid://btw1rdth3dily diff --git a/Resources/Dies/default_die.tres b/Resources/Dies/default_die.tres new file mode 100644 index 0000000..9413537 --- /dev/null +++ b/Resources/Dies/default_die.tres @@ -0,0 +1,9 @@ +[gd_resource type="Resource" script_class="DieData" format=3 uid="uid://c8l1o5q7jvlc7"] + +[ext_resource type="Script" uid="uid://p6yd34plywsk" path="res://Resources/die_data.gd" id="1_kgj8p"] + +[resource] +script = ExtResource("1_kgj8p") +die_name = "Default" +die_size = 6 +metadata/_custom_type_script = "uid://p6yd34plywsk" diff --git a/Resources/die_data.gd b/Resources/die_data.gd new file mode 100644 index 0000000..57be16b --- /dev/null +++ b/Resources/die_data.gd @@ -0,0 +1,15 @@ +class_name DieData +extends Resource + +var die_faces: Array[int] = [] + +@export var die_name: String +@export var die_size: int: + set(new_size): + die_size = new_size + update_faces() + +func update_faces() -> void: + die_faces.clear() + for i in range(1, die_size + 1): + die_faces.append(i) diff --git a/Resources/die_data.gd.uid b/Resources/die_data.gd.uid new file mode 100644 index 0000000..d6bf07c --- /dev/null +++ b/Resources/die_data.gd.uid @@ -0,0 +1 @@ +uid://p6yd34plywsk diff --git a/Scenes/Battle/attack_card.tscn b/Scenes/Battle/attack_card.tscn new file mode 100644 index 0000000..5d57d84 --- /dev/null +++ b/Scenes/Battle/attack_card.tscn @@ -0,0 +1,38 @@ +[gd_scene format=3 uid="uid://bikd5ukvohh5y"] + +[ext_resource type="Script" uid="uid://r48cvc2v21kg" path="res://attack_card.gd" id="1_tbh35"] + +[node name="AttackCard" type="Panel" unique_id=2051834154] +custom_maximum_size = Vector2(400, 200) +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_tbh35") + +[node name="Labels" type="VBoxContainer" parent="." unique_id=2138569391] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Damage" type="Label" parent="Labels" unique_id=409743516] +layout_mode = 2 +size_flags_vertical = 3 +text = "Damage: ##" +vertical_alignment = 1 + +[node name="DiceName" type="Label" parent="Labels" unique_id=289063252] +layout_mode = 2 +size_flags_vertical = 3 +text = "Dice name: ###" +vertical_alignment = 1 + +[node name="DiceFaces" type="Label" parent="Labels" unique_id=1570645889] +layout_mode = 2 +size_flags_vertical = 3 +text = "Total faces: ##" +vertical_alignment = 1 diff --git a/Scenes/Battle/battle_scene.gd b/Scenes/Battle/battle_scene.gd new file mode 100644 index 0000000..81e7bbf --- /dev/null +++ b/Scenes/Battle/battle_scene.gd @@ -0,0 +1,17 @@ +extends Control + +@export var test_die: DieData + +const DICE = preload("uid://bt42roinpuaqy") + +var new_dice: Node + + +func _ready() -> void: + new_dice = DICE.instantiate() + add_child(new_dice) + new_dice.initialize_dice(test_die) + + +func _on_roll_dice_pressed() -> void: + new_dice.roll_dice.emit() diff --git a/Scenes/Battle/battle_scene.gd.uid b/Scenes/Battle/battle_scene.gd.uid new file mode 100644 index 0000000..ed079ca --- /dev/null +++ b/Scenes/Battle/battle_scene.gd.uid @@ -0,0 +1 @@ +uid://t1oraavj6jpk diff --git a/Scenes/Battle/battle_scene.tscn b/Scenes/Battle/battle_scene.tscn new file mode 100644 index 0000000..04baa31 --- /dev/null +++ b/Scenes/Battle/battle_scene.tscn @@ -0,0 +1,40 @@ +[gd_scene format=3 uid="uid://pfl6jxwdjafp"] + +[ext_resource type="Script" uid="uid://t1oraavj6jpk" path="res://Scenes/Battle/battle_scene.gd" id="1_yw7yn"] +[ext_resource type="Resource" uid="uid://c8l1o5q7jvlc7" path="res://Resources/Dies/default_die.tres" id="2_owr4d"] +[ext_resource type="PackedScene" uid="uid://bikd5ukvohh5y" path="res://Scenes/Battle/attack_card.tscn" id="3_c3aki"] + +[node name="BattleScene" type="Control" unique_id=1237978529] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_yw7yn") +test_die = ExtResource("2_owr4d") + +[node name="RollDice" type="Button" parent="." unique_id=993526403] +custom_minimum_size = Vector2(400, 200) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -200.0 +offset_top = -200.0 +offset_right = 200.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_font_sizes/font_size = 90 +text = "Roll Dice" + +[node name="AttackCard" parent="." unique_id=2051834154 instance=ExtResource("3_c3aki")] +layout_mode = 1 +offset_left = 186.0 +offset_top = 818.0 +offset_right = -1334.0 +offset_bottom = -62.0 + +[connection signal="pressed" from="RollDice" to="." method="_on_roll_dice_pressed"] diff --git a/Scenes/Dice/dice.gd b/Scenes/Dice/dice.gd new file mode 100644 index 0000000..e32ce03 --- /dev/null +++ b/Scenes/Dice/dice.gd @@ -0,0 +1,17 @@ +extends Control + +signal roll_dice + +var die_data: DieData +@onready var dice_roll: Label = $Background/DiceRoll + +func _ready() -> void: + roll_dice.connect(_on_roll_dice) + +func initialize_dice(data: DieData) -> void: + die_data = data + dice_roll.text = str(0) + +func _on_roll_dice() -> void: + var face = die_data.die_faces.pick_random() + dice_roll.text = str(face) diff --git a/Scenes/Dice/dice.gd.uid b/Scenes/Dice/dice.gd.uid new file mode 100644 index 0000000..315c73e --- /dev/null +++ b/Scenes/Dice/dice.gd.uid @@ -0,0 +1 @@ +uid://5atyp2xyf04j diff --git a/Scenes/Dice/dice.tscn b/Scenes/Dice/dice.tscn new file mode 100644 index 0000000..82f5d4a --- /dev/null +++ b/Scenes/Dice/dice.tscn @@ -0,0 +1,23 @@ +[gd_scene format=3 uid="uid://bt42roinpuaqy"] + +[ext_resource type="Script" uid="uid://5atyp2xyf04j" path="res://Scenes/Dice/dice.gd" id="1_nyboh"] + +[node name="Dice" type="Control" unique_id=960143251] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_nyboh") + +[node name="Background" type="Panel" parent="." unique_id=1503072774] +custom_minimum_size = Vector2(200, 200) +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="DiceRoll" type="Label" parent="Background" unique_id=199352863] +layout_mode = 0 +offset_right = 200.0 +offset_bottom = 200.0 +theme_override_font_sizes/font_size = 100 +text = "##" +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/attack_card.gd b/attack_card.gd new file mode 100644 index 0000000..529cfc6 --- /dev/null +++ b/attack_card.gd @@ -0,0 +1,11 @@ +extends Control + +@onready var damage: Label = $Labels/Damage +@onready var dice_name: Label = $Labels/DiceName +@onready var dice_faces: Label = $Labels/DiceFaces + + +func _ready() -> void: + damage.text = 'Damage: ##' + dice_name.text = 'Dice name: ##' + dice_faces.text = 'Total faces: ##' diff --git a/attack_card.gd.uid b/attack_card.gd.uid new file mode 100644 index 0000000..0bb2285 --- /dev/null +++ b/attack_card.gd.uid @@ -0,0 +1 @@ +uid://r48cvc2v21kg diff --git a/project.godot b/project.godot index e2c715b..1c6eb72 100644 --- a/project.godot +++ b/project.godot @@ -1,8 +1,26 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + [application] config/name="dice_delves" +run/main_scene="uid://pfl6jxwdjafp" +config/features=PackedStringArray("4.7") config/icon="res://icon.svg" -[rendering] +[autoload] -renderer/rendering_method="forward_plus" +PlayerData="*uid://btw1rdth3dily" + +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080 +window/size/mode=3