Merge remote-tracking branch 'origin/master'
# Conflicts: # scenes/main.tscn
This commit is contained in:
commit
6ebd5731c0
136 changed files with 4013 additions and 1143 deletions
|
@ -1,22 +0,0 @@
|
|||
extends Button
|
||||
|
||||
|
||||
@export var dragon_adder: PackedScene
|
||||
@onready var base: GameManager = $"../.."
|
||||
|
||||
|
||||
func _on_pressed() -> void:
|
||||
var adder: DragonAdder = dragon_adder.instantiate()
|
||||
adder.dragon_added.connect(_add_dragon)
|
||||
|
||||
var window_position: Vector2i = DisplayServer.window_get_position()
|
||||
var window_size: Vector2i = DisplayServer.window_get_size()
|
||||
|
||||
adder.position = window_position - adder.size / 2
|
||||
|
||||
adder.show()
|
||||
add_child(adder)
|
||||
|
||||
|
||||
func _add_dragon(dragon_name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
base.add_dragon(hat, shirt, shoes, dragon_name)
|
|
@ -1 +0,0 @@
|
|||
uid://w60u0tg1hlvu
|
|
@ -1,35 +0,0 @@
|
|||
extends Window
|
||||
class_name DragonAdder
|
||||
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
|
||||
var code_generator: CodeGenerator
|
||||
|
||||
@onready var line_edit: LineEdit = $CanvasLayer/LineEdit
|
||||
|
||||
signal dragon_added(dragon_name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
code_generator = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits)
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
var dragon: Dictionary = code_generator.descrypt(line_edit.text)
|
||||
if dragon['name'] == null:
|
||||
return
|
||||
|
||||
var name: String = dragon['name']
|
||||
var hat: Texture2D = dragon['hat']
|
||||
var shirt: Texture2D = dragon['shirt']
|
||||
var shoes: Texture2D = dragon['shoes']
|
||||
|
||||
dragon_added.emit(name, hat, shirt, shoes)
|
||||
|
||||
queue_free()
|
||||
|
||||
func _on_close_requested() -> void:
|
||||
queue_free()
|
|
@ -1 +0,0 @@
|
|||
uid://b1fnwy6wnufw1
|
|
@ -1,62 +0,0 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://oqa2ry73vqjf"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b1fnwy6wnufw1" path="res://scenes/dragon_adder/dragon_adder.gd" id="1_x83p2"]
|
||||
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_33u3u"]
|
||||
[ext_resource type="Script" uid="uid://mhudiyt5gnt1" path="res://scenes/dragon_editor/line_edit.gd" id="2_77mmq"]
|
||||
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_xb0i6"]
|
||||
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_nf61g"]
|
||||
|
||||
[node name="DragonAdder" type="Window"]
|
||||
position = Vector2i(0, 36)
|
||||
size = Vector2i(500, 300)
|
||||
always_on_top = true
|
||||
script = ExtResource("1_x83p2")
|
||||
hat_outfits = ExtResource("2_33u3u")
|
||||
shirt_outfits = ExtResource("3_xb0i6")
|
||||
shoes_outfits = ExtResource("4_nf61g")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Button" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -32.0
|
||||
offset_top = -31.0
|
||||
offset_right = 32.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
focus_mode = 0
|
||||
text = "afegeix"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="CanvasLayer"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -214.0
|
||||
offset_top = -29.0
|
||||
offset_right = 214.0
|
||||
offset_bottom = 29.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
placeholder_text = "CODI"
|
||||
alignment = 1
|
||||
max_length = 22
|
||||
script = ExtResource("2_77mmq")
|
||||
|
||||
[node name="Label" type="Label" parent="CanvasLayer"]
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -59.5
|
||||
offset_right = 59.5
|
||||
offset_bottom = 23.0
|
||||
grow_horizontal = 2
|
||||
text = "afegeix un drac"
|
||||
|
||||
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
||||
[connection signal="pressed" from="CanvasLayer/Button" to="." method="_on_button_pressed"]
|
|
@ -1,54 +1,102 @@
|
|||
extends Window
|
||||
class_name DragonEditor
|
||||
|
||||
|
||||
@onready var hat: TextureRect = $CanvasLayer/Dragon/Hat
|
||||
@onready var shirt: TextureRect = $CanvasLayer/Dragon/Shirt
|
||||
@onready var shoes: TextureRect = $CanvasLayer/Dragon/Shoes
|
||||
@onready var dragon: TextureRect = $CanvasLayer/Dragon
|
||||
@onready var hat: AnimatedSprite2D = $CanvasLayer/Dragon/Hat
|
||||
@onready var shirt: AnimatedSprite2D = $CanvasLayer/Dragon/Shirt
|
||||
@onready var decor: AnimatedSprite2D = $CanvasLayer/Dragon/Decor
|
||||
@onready var dragon: AnimatedSprite2D = $CanvasLayer/Dragon
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
@export var decor_outfits: DragonOutfit
|
||||
@export var dragon_colors: DragonOutfit
|
||||
|
||||
@onready var dragon_name: LineEdit = $CanvasLayer/LineEdit
|
||||
var _save_load: SaveLoad = SaveLoad.new()
|
||||
|
||||
signal on_create_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String)
|
||||
@onready var dragon_name: LineEdit = $CanvasLayer/NameLabel/LineEdit
|
||||
@onready var dragger: DraggableWindow = $CanvasLayer/Dragger
|
||||
signal on_create_dragon(properties: DragonProperties)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
hat.texture = null
|
||||
shirt.texture = null
|
||||
shoes.texture = null
|
||||
_save_load.load()
|
||||
|
||||
hat.visible = false
|
||||
shirt.visible = false
|
||||
decor.visible = false
|
||||
dragon.play('idle')
|
||||
|
||||
hat_outfits.reset()
|
||||
shirt_outfits.reset()
|
||||
decor_outfits.reset()
|
||||
dragon_colors.reset()
|
||||
|
||||
dragger.on_drag.connect(_on_drag)
|
||||
|
||||
|
||||
func _on_close_requested() -> void:
|
||||
queue_free()
|
||||
func _on_drag(offset: Vector2i):
|
||||
position += offset
|
||||
|
||||
|
||||
func _on_next_color_pressed() -> void:
|
||||
dragon.texture = dragon_colors.pick_next()
|
||||
_pick_next_animation(dragon, dragon_colors)
|
||||
|
||||
|
||||
func _on_previous_color_pressed() -> void:
|
||||
dragon.texture = dragon_colors.pick_previous()
|
||||
_pick_previous_animation(dragon, dragon_colors)
|
||||
|
||||
|
||||
func _on_change_hat_pressed() -> void:
|
||||
hat.texture = hat_outfits.pick_next()
|
||||
_pick_next_animation(hat, hat_outfits)
|
||||
|
||||
|
||||
func _on_change_shirt_pressed() -> void:
|
||||
shirt.texture = shirt_outfits.pick_next()
|
||||
_pick_next_animation(shirt, shirt_outfits)
|
||||
|
||||
|
||||
func _on_change_shoes_pressed() -> void:
|
||||
shoes.texture = shoes_outfits.pick_next()
|
||||
_pick_next_animation(decor, decor_outfits)
|
||||
|
||||
|
||||
func _pick_next_animation(sprite: AnimatedSprite2D, outfits: DragonOutfit):
|
||||
var animation: SpriteFrames = outfits.pick_next()
|
||||
if animation == null:
|
||||
sprite.visible = false
|
||||
return
|
||||
sprite.visible = true
|
||||
sprite.set_sprite_frames(animation)
|
||||
_restart_animations()
|
||||
|
||||
|
||||
func _restart_animations():
|
||||
hat.set_frame(0)
|
||||
hat.play('idle')
|
||||
shirt.set_frame(0)
|
||||
shirt.play('idle')
|
||||
decor.set_frame(0)
|
||||
decor.play('idle')
|
||||
dragon.set_frame(0)
|
||||
dragon.play('idle')
|
||||
|
||||
|
||||
func _pick_previous_animation(sprite: AnimatedSprite2D, outfits: DragonOutfit):
|
||||
var animation: SpriteFrames = outfits.pick_previous()
|
||||
if animation == null:
|
||||
sprite.visible = false
|
||||
return
|
||||
sprite.visible = true
|
||||
sprite.set_sprite_frames(animation)
|
||||
_restart_animations()
|
||||
|
||||
|
||||
func _on_create_pressed() -> void:
|
||||
if dragon_name.text.is_empty():
|
||||
return
|
||||
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
|
||||
|
||||
var properties = DragonProperties.new(dragon_name.text, _save_load.get_tower_name(), dragon_colors.get_current_index(), hat_outfits.get_current_index(), shirt_outfits.get_current_index(), decor_outfits.get_current_index())
|
||||
on_create_dragon.emit(properties)
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_close_pressed() -> void:
|
||||
queue_free()
|
||||
|
|
|
@ -1,172 +1,177 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://fut42ruut302"]
|
||||
[gd_scene load_steps=23 format=3 uid="uid://fut42ruut302"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bfuos2kgfgber" path="res://scenes/dragon_editor/dragon_editor.gd" id="1_8vkll"]
|
||||
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_vvtct"]
|
||||
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_xhgxf"]
|
||||
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_1ivi1"]
|
||||
[ext_resource type="Resource" uid="uid://bcs60f2k7h0jc" path="res://assets/outfits/dragons.tres" id="5_1ivi1"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl87ffgh2hl68" path="res://assets/sprites/dragons/DragonPet_drac01.png" id="5_xhgxf"]
|
||||
[ext_resource type="Texture2D" uid="uid://12fv5nymaljj" path="res://assets/sprites/hats/DragonPet_barret_barretina.png" id="6_1ivi1"]
|
||||
[ext_resource type="Texture2D" uid="uid://cs0ke244c33t2" path="res://assets/sprites/shirts/DragonPet_roba_armadura.png" id="7_giwys"]
|
||||
[ext_resource type="Texture2D" uid="uid://onajhbpjtnil" path="res://assets/sprites/decor/DragonPet_acc_escut.png" id="8_udwtk"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://ccxyplt2t7t6y" path="res://assets/animations/hats/barretina.tres" id="2_aystc"]
|
||||
[ext_resource type="Resource" uid="uid://x063x858re3f" path="res://assets/outfits/hats.tres" id="2_vvtct"]
|
||||
[ext_resource type="Resource" uid="uid://bsydervvb1jpe" path="res://assets/outfits/shirts.tres" id="3_xhgxf"]
|
||||
[ext_resource type="Resource" uid="uid://dkm7d10c1lp2n" path="res://assets/outfits/decor.tres" id="4_1ivi1"]
|
||||
[ext_resource type="Resource" uid="uid://c03ejnvavmcj5" path="res://assets/outfits/dragons.tres" id="5_1ivi1"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://c5rqqy7b5ihi5" path="res://assets/animations/decor/rosa.tres" id="6_c4sli"]
|
||||
[ext_resource type="Texture2D" uid="uid://dceoy4417v83e" path="res://assets/sprites/ui/DP_UI_CharCreation_BG.png" id="6_udwtk"]
|
||||
[ext_resource type="Script" uid="uid://dxl7onk7x6h8b" path="res://src/draggable.gd" id="7_1vw8k"]
|
||||
[ext_resource type="Texture2D" uid="uid://bu5xa7tgfk3h3" path="res://assets/sprites/ui/DP_UI_Buttons01.png" id="7_qppok"]
|
||||
[ext_resource type="Texture2D" uid="uid://bgpbbkmwt8ysq" path="res://assets/sprites/ui/DP_UI_Button_Text.png" id="8_ofxsr"]
|
||||
[ext_resource type="Script" uid="uid://mhudiyt5gnt1" path="res://scenes/dragon_editor/line_edit.gd" id="9_xhgxf"]
|
||||
[ext_resource type="Texture2D" uid="uid://bdrm1nxydvf5t" path="res://assets/sprites/ui/DP_UI_Label_Big.png" id="12_qppok"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://duxxw4mfxql3c" path="res://assets/animations/dragons/verd.tres" id="14_aystc"]
|
||||
[ext_resource type="StyleBox" uid="uid://bhe580k04w6ve" path="res://assets/styles/style_box_empty.tres" id="14_bh8dj"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://dsxhfu2ekw7j" path="res://assets/animations/shirts/traje.tres" id="15_x0448"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ofxsr"]
|
||||
atlas = ExtResource("7_qppok")
|
||||
region = Rect2(0, 40, 38, 40)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bh8dj"]
|
||||
atlas = ExtResource("7_qppok")
|
||||
region = Rect2(0, 80, 38, 40)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1vw8k"]
|
||||
atlas = ExtResource("7_qppok")
|
||||
region = Rect2(0, 0, 38, 40)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rrp4v"]
|
||||
atlas = ExtResource("7_qppok")
|
||||
region = Rect2(0, 120, 38, 40)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mc14k"]
|
||||
atlas = ExtResource("8_ofxsr")
|
||||
region = Rect2(0, 0, 62, 24)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kohpo"]
|
||||
atlas = ExtResource("7_qppok")
|
||||
region = Rect2(0, 160, 38, 40)
|
||||
|
||||
[node name="DragonEditor" type="Window"]
|
||||
transparent_bg = true
|
||||
title = "Dragon Editor"
|
||||
position = Vector2i(0, 36)
|
||||
size = Vector2i(300, 500)
|
||||
size = Vector2i(230, 332)
|
||||
unresizable = true
|
||||
borderless = true
|
||||
always_on_top = true
|
||||
min_size = Vector2i(300, 500)
|
||||
max_size = Vector2i(1000, 1000)
|
||||
transparent = true
|
||||
script = ExtResource("1_8vkll")
|
||||
hat_outfits = ExtResource("2_vvtct")
|
||||
shirt_outfits = ExtResource("3_xhgxf")
|
||||
shoes_outfits = ExtResource("4_1ivi1")
|
||||
decor_outfits = ExtResource("4_1ivi1")
|
||||
dragon_colors = ExtResource("5_1ivi1")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="BG" type="TextureRect" parent="CanvasLayer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
texture = ExtResource("6_udwtk")
|
||||
|
||||
[node name="Dragon" type="AnimatedSprite2D" parent="CanvasLayer"]
|
||||
position = Vector2(112, 154)
|
||||
sprite_frames = ExtResource("14_aystc")
|
||||
animation = &"idle"
|
||||
|
||||
[node name="Hat" type="AnimatedSprite2D" parent="CanvasLayer/Dragon"]
|
||||
sprite_frames = ExtResource("2_aystc")
|
||||
animation = &"idle"
|
||||
|
||||
[node name="Shirt" type="AnimatedSprite2D" parent="CanvasLayer/Dragon"]
|
||||
sprite_frames = ExtResource("15_x0448")
|
||||
animation = &"idle"
|
||||
|
||||
[node name="Decor" type="AnimatedSprite2D" parent="CanvasLayer/Dragon"]
|
||||
sprite_frames = ExtResource("6_c4sli")
|
||||
animation = &"idle"
|
||||
|
||||
[node name="Dragger" type="Control" parent="CanvasLayer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = 18.0
|
||||
offset_top = 32.0
|
||||
offset_right = 198.0
|
||||
offset_bottom = 320.0
|
||||
script = ExtResource("7_1vw8k")
|
||||
|
||||
[node name="change_hat" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -130.0
|
||||
offset_top = -206.0
|
||||
offset_right = -62.0
|
||||
offset_bottom = -175.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
offset_left = 48.0
|
||||
offset_top = 38.0
|
||||
offset_right = 94.0
|
||||
offset_bottom = 86.0
|
||||
focus_mode = 0
|
||||
text = "barret"
|
||||
icon = SubResource("AtlasTexture_ofxsr")
|
||||
flat = true
|
||||
|
||||
[node name="change_shirt" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -47.0
|
||||
offset_top = -242.0
|
||||
offset_right = 42.0
|
||||
offset_bottom = -211.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
offset_left = 84.0
|
||||
offset_top = 50.0
|
||||
offset_right = 130.0
|
||||
offset_bottom = 98.0
|
||||
focus_mode = 0
|
||||
text = "samarreta"
|
||||
icon = SubResource("AtlasTexture_bh8dj")
|
||||
flat = true
|
||||
|
||||
[node name="change_shoes" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = 54.0
|
||||
offset_top = -206.0
|
||||
offset_right = 114.0
|
||||
offset_bottom = -175.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
offset_left = 120.0
|
||||
offset_top = 38.0
|
||||
offset_right = 166.0
|
||||
offset_bottom = 86.0
|
||||
focus_mode = 0
|
||||
text = "sabata"
|
||||
icon = SubResource("AtlasTexture_1vw8k")
|
||||
flat = true
|
||||
|
||||
[node name="dragon_previous" type="Button" parent="CanvasLayer"]
|
||||
offset_left = 40.0
|
||||
offset_top = 232.0
|
||||
offset_right = 58.0
|
||||
offset_bottom = 263.0
|
||||
offset_left = 76.0
|
||||
offset_top = 136.0
|
||||
offset_right = 122.0
|
||||
offset_bottom = 184.0
|
||||
scale = Vector2(-1, 1)
|
||||
focus_mode = 0
|
||||
text = "<"
|
||||
icon = SubResource("AtlasTexture_rrp4v")
|
||||
flat = true
|
||||
|
||||
[node name="dragon_next" type="Button" parent="CanvasLayer"]
|
||||
offset_left = 235.0
|
||||
offset_top = 232.0
|
||||
offset_right = 253.0
|
||||
offset_bottom = 263.0
|
||||
offset_left = 134.0
|
||||
offset_top = 136.0
|
||||
offset_right = 180.0
|
||||
offset_bottom = 184.0
|
||||
focus_mode = 0
|
||||
text = ">"
|
||||
icon = SubResource("AtlasTexture_rrp4v")
|
||||
flat = true
|
||||
|
||||
[node name="create" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -42.0
|
||||
offset_top = -31.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
offset_left = 112.0
|
||||
offset_top = 274.0
|
||||
offset_right = 182.0
|
||||
offset_bottom = 306.0
|
||||
focus_mode = 0
|
||||
text = "crea"
|
||||
icon = SubResource("AtlasTexture_mc14k")
|
||||
flat = true
|
||||
|
||||
[node name="Dragon" type="TextureRect" parent="CanvasLayer"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -38.0
|
||||
offset_top = -57.0
|
||||
offset_right = 38.0
|
||||
offset_bottom = 31.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("5_xhgxf")
|
||||
[node name="close" type="Button" parent="CanvasLayer"]
|
||||
offset_left = 178.0
|
||||
offset_top = 6.0
|
||||
offset_right = 224.0
|
||||
offset_bottom = 54.0
|
||||
focus_mode = 0
|
||||
icon = SubResource("AtlasTexture_kohpo")
|
||||
flat = true
|
||||
|
||||
[node name="Hat" type="TextureRect" parent="CanvasLayer/Dragon"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -38.0
|
||||
offset_top = -44.0
|
||||
offset_right = 38.0
|
||||
offset_bottom = 44.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("6_1ivi1")
|
||||
[node name="NameLabel" type="TextureRect" parent="CanvasLayer"]
|
||||
offset_left = 34.0
|
||||
offset_top = 228.0
|
||||
offset_right = 182.0
|
||||
offset_bottom = 276.0
|
||||
texture = ExtResource("12_qppok")
|
||||
|
||||
[node name="Shirt" type="TextureRect" parent="CanvasLayer/Dragon"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -38.0
|
||||
offset_top = -44.0
|
||||
offset_right = 38.0
|
||||
offset_bottom = 44.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("7_giwys")
|
||||
|
||||
[node name="Shoes" type="TextureRect" parent="CanvasLayer/Dragon"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -38.0
|
||||
offset_top = -44.0
|
||||
offset_right = 38.0
|
||||
offset_bottom = 44.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("8_udwtk")
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="CanvasLayer"]
|
||||
offset_left = 59.0
|
||||
offset_top = 372.0
|
||||
offset_right = 250.0
|
||||
offset_bottom = 403.0
|
||||
[node name="LineEdit" type="LineEdit" parent="CanvasLayer/NameLabel"]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 8.0
|
||||
offset_right = 138.0
|
||||
offset_bottom = 42.0
|
||||
theme_override_styles/focus = ExtResource("14_bh8dj")
|
||||
placeholder_text = "NOM"
|
||||
alignment = 1
|
||||
max_length = 8
|
||||
flat = true
|
||||
caret_blink = true
|
||||
script = ExtResource("9_xhgxf")
|
||||
|
||||
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
||||
|
@ -176,3 +181,4 @@ script = ExtResource("9_xhgxf")
|
|||
[connection signal="pressed" from="CanvasLayer/dragon_previous" to="." method="_on_previous_color_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/dragon_next" to="." method="_on_next_color_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/create" to="." method="_on_create_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/close" to="." method="_on_close_pressed"]
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://tubxrqxjic6r"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://tubxrqxjic6r"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bs45hvb2mpw4k" path="res://scenes/dragon_list/dragon_properties.tscn" id="1_4vct3"]
|
||||
[ext_resource type="Script" uid="uid://dm8d0ikf1n8qa" path="res://scenes/dragon_list/dragon_list_view.gd" id="1_q7g8i"]
|
||||
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="3_xxwat"]
|
||||
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="4_7mhmu"]
|
||||
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="5_h4iwm"]
|
||||
|
||||
[node name="DragonList" type="Window" node_paths=PackedStringArray("dragon_list_view")]
|
||||
size = Vector2i(450, 700)
|
||||
|
@ -12,9 +9,6 @@ always_on_top = true
|
|||
script = ExtResource("1_q7g8i")
|
||||
dragon_list_entry = ExtResource("1_4vct3")
|
||||
dragon_list_view = NodePath("CanvasLayer/ScrollContainer/VBoxContainer")
|
||||
hat_outfits = ExtResource("3_xxwat")
|
||||
shirt_outfits = ExtResource("4_7mhmu")
|
||||
shoes_outfits = ExtResource("5_h4iwm")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
|
|
|
@ -3,15 +3,13 @@ class_name DragonListEntry
|
|||
|
||||
@export var texture_rect: TextureRect
|
||||
@export var name_label: Label
|
||||
@export var code_label: Label
|
||||
|
||||
var code_generator: CodeGenerator
|
||||
@export var origin_label: Label
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
|
||||
|
||||
func set_properties(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> void:
|
||||
name_label.text = name
|
||||
code_label.text = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits).encrypt(hat, shirt, shoes, name)
|
||||
func set_properties(properties: DragonProperties) -> void:
|
||||
name_label.text = properties.name
|
||||
origin_label.text = properties.origin
|
||||
|
|
|
@ -4,25 +4,18 @@ class_name DragonList
|
|||
@export var dragon_list_entry: PackedScene
|
||||
@export var dragon_list_view: VBoxContainer
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
|
||||
var _library: DragonLibrary
|
||||
|
||||
|
||||
func set_library(library: DragonLibrary):
|
||||
_library = library
|
||||
for d in _library.dragons:
|
||||
var hat: Texture2D = hat_outfits.get_texture(d['hat'])
|
||||
var shirt: Texture2D = shirt_outfits.get_texture(d['shirt'])
|
||||
var shoes: Texture2D = shoes_outfits.get_texture(d['shoes'])
|
||||
append_dragon(d['name'], hat, shirt, shoes)
|
||||
#
|
||||
append_dragon(d)
|
||||
|
||||
func append_dragon(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
|
||||
func append_dragon(properties: DragonProperties):
|
||||
var dragon: DragonListEntry = dragon_list_entry.instantiate()
|
||||
dragon.set_properties(name, hat, shirt, shoes)
|
||||
dragon.set_properties(properties)
|
||||
dragon_list_view.add_child(dragon)
|
||||
|
||||
|
||||
|
|
|
@ -1,23 +1,391 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bs45hvb2mpw4k"]
|
||||
[gd_scene load_steps=57 format=3 uid="uid://bs45hvb2mpw4k"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="1_4i8li"]
|
||||
[ext_resource type="Script" uid="uid://d1bq5f35wptxt" path="res://scenes/dragon_list/dragon_list_entry.gd" id="1_s7he7"]
|
||||
[ext_resource type="FontFile" uid="uid://dn8qanm8tctb2" path="res://assets/fonts/Montserrat-Regular.ttf" id="2_s7he7"]
|
||||
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_y33em"]
|
||||
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_84ie0"]
|
||||
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_xvxt0"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://ccxyplt2t7t6y" path="res://assets/animations/hats/barretina.tres" id="2_xvxt0"]
|
||||
[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="3_eop0l"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7nmelv0lx3i3" path="res://assets/sprites/decor/DP_acc_escut_Anim.png" id="4_xvxt0"]
|
||||
[ext_resource type="Texture2D" uid="uid://drnel2cjwf5dr" path="res://assets/sprites/decor/DP_acc_espasa_Anim.png" id="5_eop0l"]
|
||||
[ext_resource type="Texture2D" uid="uid://dbbcv076jh4ep" path="res://assets/sprites/decor/DP_acc_rosa_Anim.png" id="6_chh13"]
|
||||
|
||||
[node name="DragonProperties" type="Control" node_paths=PackedStringArray("texture_rect", "name_label", "code_label")]
|
||||
[sub_resource type="Resource" id="Resource_nlx3a"]
|
||||
script = ExtResource("3_eop0l")
|
||||
allow_null = true
|
||||
outfits = Array[SpriteFrames]([ExtResource("2_xvxt0")])
|
||||
metadata/_custom_type_script = "uid://rw26nny160xh"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1dq4x"]
|
||||
script = ExtResource("3_eop0l")
|
||||
allow_null = true
|
||||
outfits = Array[SpriteFrames]([ExtResource("2_xvxt0")])
|
||||
metadata/_custom_type_script = "uid://rw26nny160xh"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n1vju"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(0, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_m1nfd"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(108, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3fnsk"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(216, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_njuvk"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(324, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mq26c"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(0, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_p6fb4"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(108, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fwa0p"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(216, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_26ptf"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(324, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_amy8y"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(432, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_knwp6"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(540, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yfy00"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(0, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bnccx"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(108, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hc8ch"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(216, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0nuxw"]
|
||||
atlas = ExtResource("4_xvxt0")
|
||||
region = Rect2(324, 108, 108, 108)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_gqmmt"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n1vju")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_m1nfd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3fnsk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_njuvk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"fly",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mq26c")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_p6fb4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fwa0p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_26ptf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_amy8y")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_knwp6")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yfy00")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bnccx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_hc8ch")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0nuxw")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qwppa"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(0, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1uixo"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(108, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xccp0"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(216, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nyede"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(324, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cxse4"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(0, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_edjcl"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(108, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jhak8"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(216, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t2351"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(324, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uw07h"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(432, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xcrai"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(540, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tywya"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(0, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7pu4u"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(108, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_i1w1o"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(216, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xsi0i"]
|
||||
atlas = ExtResource("5_eop0l")
|
||||
region = Rect2(324, 108, 108, 108)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_yc10j"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qwppa")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1uixo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xccp0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_nyede")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"fly",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_cxse4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_edjcl")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jhak8")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_t2351")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_uw07h")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xcrai")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tywya")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7pu4u")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_i1w1o")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xsi0i")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ifv4k"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(0, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uera2"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(108, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0q8tn"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(216, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f2bes"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(324, 216, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_albls"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(0, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mlrdx"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(108, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dipuj"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(216, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d0xss"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(324, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mpdbr"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(432, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dy3ut"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(540, 0, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gi66g"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(0, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_am77p"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(108, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_asxml"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(216, 108, 108, 108)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pral7"]
|
||||
atlas = ExtResource("6_chh13")
|
||||
region = Rect2(324, 108, 108, 108)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_rhebu"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ifv4k")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_uera2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0q8tn")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_f2bes")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"fly",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_albls")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mlrdx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dipuj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_d0xss")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mpdbr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dy3ut")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gi66g")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_am77p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_asxml")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pral7")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walk",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_if2jb"]
|
||||
script = ExtResource("3_eop0l")
|
||||
allow_null = true
|
||||
outfits = Array[SpriteFrames]([SubResource("SpriteFrames_gqmmt"), SubResource("SpriteFrames_yc10j"), SubResource("SpriteFrames_rhebu")])
|
||||
metadata/_custom_type_script = "uid://rw26nny160xh"
|
||||
|
||||
[node name="DragonProperties" type="Control" node_paths=PackedStringArray("texture_rect", "name_label", "origin_label")]
|
||||
custom_minimum_size = Vector2(0, 128)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_s7he7")
|
||||
texture_rect = NodePath("TextureRect")
|
||||
name_label = NodePath("Name")
|
||||
code_label = NodePath("Code")
|
||||
hat_outfits = ExtResource("2_y33em")
|
||||
shirt_outfits = ExtResource("3_84ie0")
|
||||
shoes_outfits = ExtResource("4_xvxt0")
|
||||
origin_label = NodePath("Origin")
|
||||
hat_outfits = SubResource("Resource_nlx3a")
|
||||
shirt_outfits = SubResource("Resource_1dq4x")
|
||||
shoes_outfits = SubResource("Resource_if2jb")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 0
|
||||
|
@ -39,7 +407,7 @@ theme_override_fonts/font = ExtResource("2_s7he7")
|
|||
theme_override_font_sizes/font_size = 36
|
||||
text = "AAAAAAAA"
|
||||
|
||||
[node name="Code" type="Label" parent="."]
|
||||
[node name="Origin" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 132.0
|
||||
offset_top = 8.0
|
||||
|
|
35
scenes/dragon_sharing.gd
Normal file
35
scenes/dragon_sharing.gd
Normal file
|
@ -0,0 +1,35 @@
|
|||
extends HTTPRequest
|
||||
class_name DragonSharing
|
||||
|
||||
|
||||
signal on_dragon_received(dragon: DragonProperties)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
request_completed.connect(_on_request_completed)
|
||||
|
||||
|
||||
func _on_request_completed(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray):
|
||||
if response_code != 200:
|
||||
print("HTTP request returned error: ", response_code)
|
||||
on_dragon_received.emit(null)
|
||||
return
|
||||
if body.size() != 0:
|
||||
var json = JSON.parse_string(body.get_string_from_utf8())
|
||||
var properties = DragonProperties.new(json['name'], json['origin'], json['color'], json['hat'], json['shirt'], json['decor'])
|
||||
print(properties)
|
||||
on_dragon_received.emit(properties)
|
||||
|
||||
|
||||
func send(properties: DragonProperties) -> void:
|
||||
var url: String = 'http://torreta.gerardgascon.com/add/%s/%s/%s/%s/%s/%s/' % [properties.origin, properties.name, properties.color, properties.shirt, properties.hat, properties.decor]
|
||||
var err: int = request(url)
|
||||
if err != OK:
|
||||
print("HTTP request failed: ", err)
|
||||
|
||||
|
||||
func receive(origin: String) -> void:
|
||||
var url: String = 'http://torreta.gerardgascon.com/get/%s/' % origin
|
||||
var err: int = request(url)
|
||||
if err != OK:
|
||||
print("HTTP request failed: ", err)
|
1
scenes/dragon_sharing.gd.uid
Normal file
1
scenes/dragon_sharing.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://bg58e3dobon4j
|
|
@ -8,11 +8,11 @@ class_name DragonEntity
|
|||
@export var min_exit_time: float
|
||||
@export var max_exit_time: float
|
||||
|
||||
signal on_pick(dragon_id: int, position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
|
||||
signal on_pick(properties: DragonProperties)
|
||||
signal on_quit(dragon_id: int)
|
||||
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
var id: int
|
||||
var properties: DragonProperties
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -22,13 +22,13 @@ func _ready() -> void:
|
|||
|
||||
func _queue_exit():
|
||||
await get_tree().create_timer(rng.randf_range(min_exit_time, max_exit_time)).timeout
|
||||
var tween = get_tree().create_tween()
|
||||
var tween: Tween = get_tree().create_tween()
|
||||
tween.tween_property($CollisionShape2D, "position", Vector2(get_window().size.x + 200, 0), animation_duration)
|
||||
tween.tween_callback(_proceed_exit)
|
||||
|
||||
|
||||
func _proceed_exit():
|
||||
on_quit.emit(id)
|
||||
on_quit.emit(properties.id)
|
||||
queue_free()
|
||||
|
||||
|
||||
|
@ -39,13 +39,14 @@ func _play_initial_animation() -> void:
|
|||
tween.tween_callback(_queue_exit)
|
||||
|
||||
|
||||
func _input_event(viewport, event, shape_idx) -> void:
|
||||
func _input_event(_viewport, event, _shape_idx) -> void:
|
||||
if event is InputEventMouseButton \
|
||||
and event.button_index == MOUSE_BUTTON_LEFT \
|
||||
and event.is_pressed():
|
||||
on_pick.emit(id, position + $CollisionShape2D.position, dragon.hat.texture, dragon.shirt.texture, dragon.shoes.texture)
|
||||
properties.position = position + $CollisionShape2D.position
|
||||
on_pick.emit(properties)
|
||||
queue_free()
|
||||
|
||||
|
||||
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
dragon.dress(hat, shirt, shoes)
|
||||
func dress(properties: DragonProperties):
|
||||
dragon.dress(properties)
|
||||
|
|
|
@ -2,22 +2,63 @@ extends Node2D
|
|||
class_name DragonSprite
|
||||
|
||||
|
||||
@export var hat: Sprite2D
|
||||
@export var shirt: Sprite2D
|
||||
@export var shoes: Sprite2D
|
||||
@export var hat: AnimatedSprite2D
|
||||
@export var shirt: AnimatedSprite2D
|
||||
@export var decor: AnimatedSprite2D
|
||||
@export var color: AnimatedSprite2D
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var decor_outfits: DragonOutfit
|
||||
@export var color_outfits: DragonOutfit
|
||||
|
||||
|
||||
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
self.hat.texture = hat
|
||||
self.shirt.texture = shirt
|
||||
self.shoes.texture = shoes
|
||||
func dress(properties: DragonProperties):
|
||||
_set_dress(hat, hat_outfits.get_texture(properties.hat))
|
||||
_set_dress(shirt, shirt_outfits.get_texture(properties.shirt))
|
||||
_set_dress(decor, decor_outfits.get_texture(properties.decor))
|
||||
_set_dress(color, color_outfits.get_texture(properties.color))
|
||||
play_walk()
|
||||
|
||||
|
||||
func _set_dress(part: AnimatedSprite2D, dress: SpriteFrames):
|
||||
if dress == null:
|
||||
part.visible = false
|
||||
else:
|
||||
part.visible = true
|
||||
part.set_sprite_frames(dress)
|
||||
|
||||
|
||||
func walk_left():
|
||||
$Sprite.scale.x = 1
|
||||
$DragonBody.scale.x = 1
|
||||
$Dragon.scale.x = 1
|
||||
|
||||
|
||||
func walk_right():
|
||||
$Sprite.scale.x = -1
|
||||
$DragonBody.scale.x = -1
|
||||
$Dragon.scale.x = -1
|
||||
|
||||
|
||||
func _play_animation(animation_name: String, part: AnimatedSprite2D) -> void:
|
||||
if !part.is_visible():
|
||||
return
|
||||
part.play(animation_name)
|
||||
|
||||
|
||||
func play_idle() -> void:
|
||||
_play_animation("idle", hat)
|
||||
_play_animation("idle", shirt)
|
||||
_play_animation("idle", decor)
|
||||
_play_animation("idle", color)
|
||||
|
||||
|
||||
func play_fly() -> void:
|
||||
_play_animation("fly", hat)
|
||||
_play_animation("fly", shirt)
|
||||
_play_animation("fly", decor)
|
||||
_play_animation("fly", color)
|
||||
|
||||
|
||||
func play_walk() -> void:
|
||||
_play_animation("walk", hat)
|
||||
_play_animation("walk", shirt)
|
||||
_play_animation("walk", decor)
|
||||
_play_animation("walk", color)
|
||||
|
|
|
@ -1,46 +1,51 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://baa8gpicw2yg0"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://baa8gpicw2yg0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bjiap06gs02j" path="res://scenes/dragons/dragon_sprite.gd" id="1_oaoux"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl87ffgh2hl68" path="res://assets/sprites/dragons/DragonPet_drac01.png" id="2_oaoux"]
|
||||
[ext_resource type="Texture2D" uid="uid://12fv5nymaljj" path="res://assets/sprites/hats/DragonPet_barret_barretina.png" id="3_oaoux"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3xnii6r00hol" path="res://assets/sprites/shirts/DragonPet_roba_traje.png" id="4_oaoux"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1b8gp5uf2ehk" path="res://assets/sprites/decor/DragonPet_acc_rosa.png" id="5_stf6f"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://4cm7picl2gvs" path="res://assets/animations/dragon_green.tres" id="6_yf7bj"]
|
||||
[ext_resource type="Resource" uid="uid://x063x858re3f" path="res://assets/outfits/hats.tres" id="2_mxc00"]
|
||||
[ext_resource type="Resource" uid="uid://bsydervvb1jpe" path="res://assets/outfits/shirts.tres" id="3_umqeb"]
|
||||
[ext_resource type="Resource" uid="uid://dkm7d10c1lp2n" path="res://assets/outfits/decor.tres" id="4_7b2ll"]
|
||||
[ext_resource type="Resource" uid="uid://c03ejnvavmcj5" path="res://assets/outfits/dragons.tres" id="5_x2k4p"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://duxxw4mfxql3c" path="res://assets/animations/dragons/verd.tres" id="6_yf7bj"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://ccxyplt2t7t6y" path="res://assets/animations/hats/barretina.tres" id="10_7b2ll"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://dsxhfu2ekw7j" path="res://assets/animations/shirts/traje.tres" id="11_x2k4p"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://c5rqqy7b5ihi5" path="res://assets/animations/decor/rosa.tres" id="12_rhebu"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oaoux"]
|
||||
size = Vector2(76, 88)
|
||||
size = Vector2(108, 88)
|
||||
|
||||
[node name="Dragon" type="Node2D" node_paths=PackedStringArray("hat", "shirt", "shoes")]
|
||||
[node name="Dragon" type="Node2D" node_paths=PackedStringArray("hat", "shirt", "decor", "color")]
|
||||
script = ExtResource("1_oaoux")
|
||||
hat = NodePath("Sprite/Hat")
|
||||
shirt = NodePath("Sprite/Shirt")
|
||||
shoes = NodePath("Sprite/Shoes")
|
||||
hat = NodePath("Dragon/Hat")
|
||||
shirt = NodePath("Dragon/Shirt")
|
||||
decor = NodePath("Dragon/Decor")
|
||||
color = NodePath("Dragon")
|
||||
hat_outfits = ExtResource("2_mxc00")
|
||||
shirt_outfits = ExtResource("3_umqeb")
|
||||
decor_outfits = ExtResource("4_7b2ll")
|
||||
color_outfits = ExtResource("5_x2k4p")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2(38, 44)
|
||||
position = Vector2(54, 44)
|
||||
shape = SubResource("RectangleShape2D_oaoux")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
position = Vector2(38, 44)
|
||||
texture = ExtResource("2_oaoux")
|
||||
|
||||
[node name="Hat" type="Sprite2D" parent="Sprite"]
|
||||
texture = ExtResource("3_oaoux")
|
||||
|
||||
[node name="Shirt" type="Sprite2D" parent="Sprite"]
|
||||
texture = ExtResource("4_oaoux")
|
||||
|
||||
[node name="Shoes" type="Sprite2D" parent="Sprite"]
|
||||
texture = ExtResource("5_stf6f")
|
||||
|
||||
[node name="DragonBody" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(36, 34)
|
||||
[node name="Dragon" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(54, 34)
|
||||
sprite_frames = ExtResource("6_yf7bj")
|
||||
animation = &"idle"
|
||||
autoplay = "idle"
|
||||
frame_progress = 0.10072
|
||||
|
||||
[node name="Hat" type="AnimatedSprite2D" parent="Dragon"]
|
||||
sprite_frames = ExtResource("10_7b2ll")
|
||||
animation = &"idle"
|
||||
|
||||
[node name="Shirt" type="AnimatedSprite2D" parent="Dragon"]
|
||||
sprite_frames = ExtResource("11_x2k4p")
|
||||
animation = &"idle"
|
||||
|
||||
[node name="Decor" type="AnimatedSprite2D" parent="Dragon"]
|
||||
sprite_frames = ExtResource("12_rhebu")
|
||||
animation = &"idle"
|
||||
|
||||
[connection signal="mouse_entered" from="Area2D" to="." method="_on_area_2d_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Area2D" to="." method="_on_area_2d_mouse_exited"]
|
||||
|
|
126
scenes/main.gd
126
scenes/main.gd
|
@ -4,14 +4,11 @@ class_name GameManager
|
|||
|
||||
@export var dragon_template: PackedScene
|
||||
@export var dragon_ingame: PackedScene
|
||||
@export var name_setter: PackedScene
|
||||
@export var dragon_spots: Array[Node2D]
|
||||
|
||||
var _filled_spots: Dictionary[Node2D, int]
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
|
||||
var _instantiator: DragonInstantiator
|
||||
var _save_load: SaveLoad
|
||||
var _library: DragonLibrary
|
||||
|
@ -23,47 +20,73 @@ var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
|||
@export var min_dragon_instantiation_time: float
|
||||
@export var max_dragon_instantiation_time: float
|
||||
|
||||
@onready var dragon_sharing: DragonSharing = $HTTPRequest
|
||||
|
||||
|
||||
func _ready():
|
||||
_library = DragonLibrary.new(hat_outfits, shirt_outfits, shoes_outfits)
|
||||
_library = DragonLibrary.new()
|
||||
_instantiator = DragonInstantiator.new(dragon_template, get_viewport(), get_window())
|
||||
_save_load = SaveLoad.new()
|
||||
|
||||
await get_tree().process_frame
|
||||
move_window_to_bottom_right()
|
||||
_load_game()
|
||||
if _save_load.get_tower_name() == "":
|
||||
_show_name_setter_screen()
|
||||
_queue_dragon_instantiation()
|
||||
|
||||
|
||||
func _show_name_setter_screen():
|
||||
var setter: NameSetter = name_setter.instantiate()
|
||||
setter.set_save_load(_save_load)
|
||||
add_child(setter)
|
||||
|
||||
var display_index: int = DisplayServer.window_get_current_screen()
|
||||
var work_area_position: Vector2i = DisplayServer.screen_get_usable_rect(display_index).position
|
||||
var work_area_size: Vector2i = DisplayServer.screen_get_usable_rect(display_index).size
|
||||
|
||||
var new_position: Vector2i = work_area_position + Vector2i(work_area_size.x / 2.0 - setter.size.x / 2.0, work_area_size.y / 2.0 - setter.size.y / 2.0)
|
||||
setter.position = new_position
|
||||
|
||||
|
||||
func _queue_dragon_instantiation():
|
||||
await get_tree().create_timer(rng.randf_range(min_dragon_instantiation_time, max_dragon_instantiation_time)).timeout
|
||||
_instantiate_random_dragon()
|
||||
|
||||
|
||||
func _instantiate_random_dragon():
|
||||
for spot in dragon_spots:
|
||||
if not _filled_spots.has(spot):
|
||||
var dragon: DragonEntity = _pick_random_dragon(spot.position)
|
||||
if dragon != null:
|
||||
_filled_spots[spot] = dragon.id
|
||||
break
|
||||
if _save_load.get_tower_name() != "":
|
||||
_instantiate_random_dragon()
|
||||
_queue_dragon_instantiation()
|
||||
|
||||
|
||||
func _pick_random_dragon(pos: Vector2) -> DragonEntity:
|
||||
for dragon in _library.dragons:
|
||||
var id: int = dragon['id']
|
||||
if _instantiated_dragons.has(id) or _dragon_entities.has(id):
|
||||
continue
|
||||
var dragon_name: String = dragon['name']
|
||||
var hat: Texture2D = hat_outfits.get_texture(dragon['hat'])
|
||||
var shirt: Texture2D = shirt_outfits.get_texture(dragon['shirt'])
|
||||
var shoes: Texture2D = shoes_outfits.get_texture(dragon['shoes'])
|
||||
return _instantiate_dragon_ingame(pos, hat, shirt, shoes, dragon_name, id)
|
||||
|
||||
func _instantiate_random_dragon():
|
||||
var spot: Node2D = _get_free_spot()
|
||||
if spot == null:
|
||||
return
|
||||
|
||||
#TODO: Add also a way to instantiate dragons in your library with a greater probability
|
||||
for i in range(5):
|
||||
dragon_sharing.receive(_save_load.get_tower_name())
|
||||
var dragon: DragonProperties = await dragon_sharing.on_dragon_received
|
||||
if dragon == null:
|
||||
return
|
||||
for d in _library.dragons:
|
||||
# TODO: Search for dragon and if is in library or in instantiated dragons continue next iteration
|
||||
pass
|
||||
var dragon_entity: DragonEntity = _generate_entity(spot.position, dragon)
|
||||
_filled_spots[spot] = dragon_entity.properties.id
|
||||
return
|
||||
|
||||
|
||||
func _get_free_spot() -> Node2D:
|
||||
for spot in dragon_spots:
|
||||
if not _filled_spots.has(spot):
|
||||
return spot
|
||||
return null
|
||||
|
||||
|
||||
func _generate_entity(pos: Vector2, properties: DragonProperties) -> DragonEntity:
|
||||
properties.id = rng.randi()
|
||||
return _instantiate_dragon_ingame(pos, properties)
|
||||
|
||||
|
||||
func move_window_to_bottom_right():
|
||||
var display_index: int = DisplayServer.window_get_current_screen()
|
||||
|
||||
|
@ -78,50 +101,50 @@ func move_window_to_bottom_right():
|
|||
DisplayServer.window_set_position(new_position)
|
||||
|
||||
|
||||
func add_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String):
|
||||
var id: int = _library.add_dragon(dragon_name, hat, shirt, shoes)
|
||||
func add_dragon(properties: DragonProperties):
|
||||
var id: int = _library.add_dragon(properties)
|
||||
dragon_sharing.send(properties)
|
||||
for spot in dragon_spots:
|
||||
if not _filled_spots.has(spot):
|
||||
_instantiate_dragon_ingame(spot.position, hat, shirt, shoes, dragon_name, id)
|
||||
_instantiate_dragon_ingame(spot.position, properties)
|
||||
_filled_spots[spot] = id
|
||||
break
|
||||
|
||||
|
||||
func _load_game():
|
||||
_save_load.load()
|
||||
var dragons: Array = _save_load.get_dragons()
|
||||
var dragons: Array[DragonProperties] = _save_load.get_dragons()
|
||||
_library.add_dragons(dragons)
|
||||
for d in dragons:
|
||||
if d['pos'] != Vector2i(0, 0):
|
||||
var hat: Texture2D = hat_outfits.get_texture(d['hat'])
|
||||
var shirt: Texture2D = shirt_outfits.get_texture(d['shirt'])
|
||||
var shoes: Texture2D = shoes_outfits.get_texture(d['shoes'])
|
||||
_pick_dragon(d['id'], d['pos'], hat, shirt, shoes, false)
|
||||
for d: DragonProperties in dragons:
|
||||
if d.position != Vector2i(0, 0):
|
||||
_pick_dragon(d, false)
|
||||
print(_save_load.contents_to_save)
|
||||
|
||||
|
||||
func _instantiate_dragon_ingame(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String, id: int) -> DragonEntity:
|
||||
func _instantiate_dragon_ingame(window_position: Vector2, properties: DragonProperties) -> DragonEntity:
|
||||
var dragon: DragonEntity = dragon_ingame.instantiate()
|
||||
dragon.dress(hat, shirt, shoes)
|
||||
add_child(dragon)
|
||||
dragon.id = id
|
||||
dragon.position = position
|
||||
dragon.dress(properties)
|
||||
dragon.properties = properties
|
||||
dragon.position = window_position
|
||||
dragon.on_pick.connect(_pick_dragon)
|
||||
dragon.on_quit.connect(_quit_dragon)
|
||||
_instantiated_dragons[id] = dragon
|
||||
_instantiated_dragons[properties.id] = dragon
|
||||
return dragon
|
||||
|
||||
|
||||
func _pick_dragon(id: int, position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D, drag: bool = true):
|
||||
var dragon: Dragon = _instantiator.instantiate(position, hat, shirt, shoes, drag)
|
||||
dragon.id = id
|
||||
_dragon_entities[id] = dragon
|
||||
func _pick_dragon(properties: DragonProperties, drag: bool = true):
|
||||
var dragon: Dragon = _instantiator.instantiate(properties, drag)
|
||||
_dragon_entities[properties.id] = dragon
|
||||
dragon.place_back.connect(_dragon_place_back)
|
||||
add_child(dragon)
|
||||
_instantiated_dragons.erase(id)
|
||||
_instantiated_dragons.erase(properties.id)
|
||||
|
||||
if not _library.has(properties):
|
||||
_library.add_dragon(properties)
|
||||
|
||||
for spot in _filled_spots:
|
||||
if _filled_spots[spot] == id:
|
||||
if _filled_spots[spot] == properties.id:
|
||||
_filled_spots.erase(spot)
|
||||
|
||||
|
||||
|
@ -134,16 +157,17 @@ func _quit_dragon(id: int):
|
|||
|
||||
|
||||
func _dragon_place_back(dragon: Dragon):
|
||||
_dragon_entities.erase(dragon.id)
|
||||
_dragon_entities.erase(dragon.properties.id)
|
||||
|
||||
|
||||
func _on_close_pressed() -> void:
|
||||
_save_load.clear_dragons()
|
||||
for d in _library.dragons:
|
||||
if _dragon_entities.has(d['id']) and _dragon_entities[d['id']] != null:
|
||||
_save_load.add_dragon(d['id'], d['name'], d['hat'], d['shirt'], d['shoes'], _dragon_entities[d['id']].position)
|
||||
if _dragon_entities.has(d.id) and _dragon_entities[d.id] != null:
|
||||
_save_load.add_dragon(d)
|
||||
else:
|
||||
_save_load.add_dragon(d['id'], d['name'], d['hat'], d['shirt'], d['shoes'], Vector2i(0, 0))
|
||||
d.position = Vector2i(0, 0)
|
||||
_save_load.add_dragon(d)
|
||||
_save_load.save()
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
|
|
|
@ -1,29 +1,24 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://ctytpqaed0yqx"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://ctytpqaed0yqx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://3kyt3shje5r1" path="res://scenes/main.gd" id="1_sugp2"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7nfcgjxqeg7l" path="res://scenes/window/dragon_popup.tscn" id="2_jyhfs"]
|
||||
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="4_85g3d"]
|
||||
[ext_resource type="PackedScene" uid="uid://miutbdsgccd1" path="res://scenes/dragons/dragon.tscn" id="4_jyhfs"]
|
||||
[ext_resource type="Script" uid="uid://cj4l3a6a8ro0r" path="res://scenes/create_button.gd" id="4_tbgi4"]
|
||||
[ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="5_choun"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdlipr8l1k38a" path="res://scenes/name_setter/name_setter.tscn" id="4_trceg"]
|
||||
[ext_resource type="PackedScene" uid="uid://fut42ruut302" path="res://scenes/dragon_editor/dragon_editor.tscn" id="5_tefeu"]
|
||||
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="6_ya4ey"]
|
||||
[ext_resource type="Script" uid="uid://oc6mw86npbii" path="res://scenes/list_button.gd" id="9_choun"]
|
||||
[ext_resource type="PackedScene" uid="uid://tubxrqxjic6r" path="res://scenes/dragon_list/dragon_list.tscn" id="10_ya4ey"]
|
||||
[ext_resource type="Script" uid="uid://w60u0tg1hlvu" path="res://scenes/dragon_adder.gd" id="11_eb6dy"]
|
||||
[ext_resource type="PackedScene" uid="uid://oqa2ry73vqjf" path="res://scenes/dragon_adder/dragon_adder.tscn" id="12_trceg"]
|
||||
[ext_resource type="Texture2D" uid="uid://bc2lykc3gwykh" path="res://assets/sprites/environment/castle/DP_castle_back.png" id="15_muem4"]
|
||||
[ext_resource type="Texture2D" uid="uid://o1e8lge2vuqu" path="res://assets/sprites/environment/castle/DP_castle_mid.png" id="16_dp3eg"]
|
||||
[ext_resource type="Texture2D" uid="uid://b1w6y1qvetsaw" path="res://assets/sprites/environment/castle/DP_castle_front.png" id="17_0ld40"]
|
||||
[ext_resource type="Script" path="res://scenes/dragon_sharing.gd" id="17_muem4"]
|
||||
|
||||
[node name="Base" type="Node2D" node_paths=PackedStringArray("dragon_spots")]
|
||||
script = ExtResource("1_sugp2")
|
||||
dragon_template = ExtResource("2_jyhfs")
|
||||
dragon_ingame = ExtResource("4_jyhfs")
|
||||
name_setter = ExtResource("4_trceg")
|
||||
dragon_spots = [NodePath("DragonSpot1"), NodePath("DragonSpot2"), NodePath("DragonSpot3")]
|
||||
hat_outfits = ExtResource("4_85g3d")
|
||||
shirt_outfits = ExtResource("5_choun")
|
||||
shoes_outfits = ExtResource("6_ya4ey")
|
||||
min_dragon_instantiation_time = 2.0
|
||||
max_dragon_instantiation_time = 10.0
|
||||
|
||||
|
@ -69,20 +64,6 @@ text = "llista"
|
|||
script = ExtResource("9_choun")
|
||||
dragon_list = ExtResource("10_ya4ey")
|
||||
|
||||
[node name="Adder" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -393.0
|
||||
offset_top = 14.0
|
||||
offset_right = -329.0
|
||||
offset_bottom = 45.0
|
||||
grow_horizontal = 0
|
||||
focus_mode = 0
|
||||
text = "afegeix"
|
||||
script = ExtResource("11_eb6dy")
|
||||
dragon_adder = ExtResource("12_trceg")
|
||||
|
||||
[node name="Castle" type="Node2D" parent="."]
|
||||
|
||||
[node name="DpCastleBack" type="Sprite2D" parent="Castle"]
|
||||
|
@ -109,9 +90,11 @@ position = Vector2(142, 118)
|
|||
[node name="DragonSpot3" type="Node2D" parent="."]
|
||||
position = Vector2(207, 252)
|
||||
|
||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||
script = ExtResource("17_muem4")
|
||||
|
||||
[connection signal="tree_entered" from="." to="." method="_on_tree_entered"]
|
||||
[connection signal="tree_exiting" from="." to="." method="_on_tree_exiting"]
|
||||
[connection signal="button_up" from="CanvasLayer/Create" to="CanvasLayer/Create" method="_on_button_up"]
|
||||
[connection signal="pressed" from="CanvasLayer/Close" to="." method="_on_close_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/List" to="CanvasLayer/List" method="_on_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/Adder" to="CanvasLayer/Adder" method="_on_pressed"]
|
||||
|
|
20
scenes/name_setter/name_setter.gd
Normal file
20
scenes/name_setter/name_setter.gd
Normal file
|
@ -0,0 +1,20 @@
|
|||
extends Window
|
||||
class_name NameSetter
|
||||
|
||||
|
||||
var save_load: SaveLoad
|
||||
@onready var name_edit: LineEdit = $Name
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func set_save_load(save_load: SaveLoad) -> void:
|
||||
self.save_load = save_load
|
||||
|
||||
|
||||
func _on_submit_pressed() -> void:
|
||||
if not name_edit.text.is_empty():
|
||||
save_load.set_tower_name(name_edit.text)
|
||||
queue_free()
|
1
scenes/name_setter/name_setter.gd.uid
Normal file
1
scenes/name_setter/name_setter.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://drulv5ptupx2w
|
38
scenes/name_setter/name_setter.tscn
Normal file
38
scenes/name_setter/name_setter.tscn
Normal file
|
@ -0,0 +1,38 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cdlipr8l1k38a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://drulv5ptupx2w" path="res://scenes/name_setter/name_setter.gd" id="1_f3gk5"]
|
||||
|
||||
[node name="NameSetter" type="Window"]
|
||||
position = Vector2i(0, 36)
|
||||
size = Vector2i(500, 250)
|
||||
unresizable = true
|
||||
always_on_top = true
|
||||
script = ExtResource("1_f3gk5")
|
||||
|
||||
[node name="Instructions" type="Label" parent="."]
|
||||
offset_right = 500.0
|
||||
offset_bottom = 146.0
|
||||
text = "En aquesta torreta, present a la cantonada del teu escriptori, hi viuran uns dracs que t’acompanyaran en el teu dia a dia. Fins i tot et vindran a visitar dracs d'altres torretes!
|
||||
|
||||
Per començar, posa un nom a la teva torreta.
|
||||
És el primer pas per fer-la teva."
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Name" type="LineEdit" parent="."]
|
||||
offset_left = 84.0
|
||||
offset_top = 163.0
|
||||
offset_right = 423.0
|
||||
offset_bottom = 214.0
|
||||
placeholder_text = "Nom"
|
||||
alignment = 1
|
||||
max_length = 16
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
offset_left = 220.0
|
||||
offset_top = 218.0
|
||||
offset_right = 287.0
|
||||
offset_bottom = 249.0
|
||||
text = "Assigna"
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_submit_pressed"]
|
|
@ -17,7 +17,7 @@ var _fall_speed: float
|
|||
|
||||
signal place_back(dragon: Dragon)
|
||||
|
||||
var id: int
|
||||
var properties: DragonProperties
|
||||
|
||||
|
||||
enum State {
|
||||
|
@ -35,7 +35,7 @@ var current_state: State = State.WALKING_IDLE
|
|||
func _ready() -> void:
|
||||
draggable.on_drag.connect(_on_drag)
|
||||
draggable.on_drop.connect(_on_drop)
|
||||
current_state = State.FALLING
|
||||
_change_state(State.FALLING)
|
||||
|
||||
|
||||
func on_place_back() -> void:
|
||||
|
@ -50,12 +50,6 @@ func _process(delta: float) -> void:
|
|||
State.DRAGGING:
|
||||
_thinking_path = false
|
||||
_actual_position = position
|
||||
State.WALKING_IDLE:
|
||||
if not _thinking_path:
|
||||
_think_path()
|
||||
State.FLYING_IDLE:
|
||||
if not _thinking_path:
|
||||
_think_path()
|
||||
State.WALKING:
|
||||
_move_to_target(delta)
|
||||
State.FALLING:
|
||||
|
@ -63,13 +57,33 @@ func _process(delta: float) -> void:
|
|||
State.FLYING:
|
||||
_move_to_target(delta)
|
||||
|
||||
properties.position = position
|
||||
|
||||
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
dragon.dress(hat, shirt, shoes)
|
||||
|
||||
func _change_state(new_state):
|
||||
match new_state:
|
||||
State.DRAGGING:
|
||||
dragon.play_idle()
|
||||
State.WALKING_IDLE:
|
||||
dragon.play_idle()
|
||||
_think_path()
|
||||
State.FLYING_IDLE:
|
||||
_think_path()
|
||||
State.WALKING:
|
||||
dragon.play_walk()
|
||||
State.FALLING:
|
||||
dragon.play_idle()
|
||||
State.FLYING:
|
||||
dragon.play_fly()
|
||||
|
||||
current_state = new_state
|
||||
|
||||
|
||||
func dress():
|
||||
dragon.dress(properties)
|
||||
|
||||
|
||||
func _think_path():
|
||||
_thinking_path = true
|
||||
await get_tree().create_timer(rng.randf_range(2, 7)).timeout
|
||||
dragon_speed = rng.randf_range(dragon_speed_min, dragon_speed_max)
|
||||
|
||||
|
@ -84,7 +98,7 @@ func _think_path():
|
|||
var decision: int = rng.randi_range(0, 99)
|
||||
if decision < 30:
|
||||
_fall_speed = 0
|
||||
current_state = State.FALLING
|
||||
_change_state(State.FALLING)
|
||||
else:
|
||||
_pick_random_screen_fly_position()
|
||||
|
||||
|
@ -96,7 +110,7 @@ func _fall(delta: float) -> void:
|
|||
|
||||
var ground_height: int = _ground_height()
|
||||
if position.y >= ground_height:
|
||||
current_state = State.WALKING_IDLE
|
||||
_change_state(State.WALKING_IDLE)
|
||||
position.y = ground_height
|
||||
_actual_position.y = ground_height
|
||||
|
||||
|
@ -115,24 +129,24 @@ func _move_to_target(delta: float):
|
|||
|
||||
match current_state:
|
||||
State.FLYING:
|
||||
current_state = State.FLYING_IDLE
|
||||
_change_state(State.FLYING_IDLE)
|
||||
State.WALKING:
|
||||
current_state = State.WALKING_IDLE
|
||||
_change_state(State.WALKING_IDLE)
|
||||
|
||||
|
||||
func _on_drag():
|
||||
current_state = State.DRAGGING
|
||||
_change_state(State.DRAGGING)
|
||||
|
||||
|
||||
func _on_drop():
|
||||
var ground_height: int = _ground_height()
|
||||
if position.y >= ground_height:
|
||||
current_state = State.WALKING_IDLE
|
||||
_change_state(State.WALKING_IDLE)
|
||||
position.y = ground_height
|
||||
_actual_position.y = ground_height
|
||||
else:
|
||||
_fall_speed = 0
|
||||
current_state = State.FALLING
|
||||
_change_state(State.FALLING)
|
||||
|
||||
|
||||
func _get_display_limits() -> Rect2i:
|
||||
|
@ -149,7 +163,7 @@ func _ground_height() -> int:
|
|||
|
||||
|
||||
func _pick_random_screen_fly_position() -> void:
|
||||
current_state = State.FLYING
|
||||
_change_state(State.FLYING)
|
||||
_thinking_path = false
|
||||
|
||||
var limits: Rect2i = _get_display_limits()
|
||||
|
@ -163,7 +177,7 @@ func _pick_random_screen_fly_position() -> void:
|
|||
|
||||
|
||||
func _pick_random_screen_walk_position() -> void:
|
||||
current_state = State.WALKING
|
||||
_change_state(State.WALKING)
|
||||
_thinking_path = false
|
||||
|
||||
var limits: Rect2i = _get_display_limits()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[node name="DragonPopup" type="Window" node_paths=PackedStringArray("dragon", "draggable")]
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
size = Vector2i(76, 88)
|
||||
size = Vector2i(108, 88)
|
||||
unresizable = true
|
||||
borderless = true
|
||||
always_on_top = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue