feat: choose outfit from library when creating a dragon
This commit is contained in:
parent
fd8609c0ab
commit
f07b28d2dc
22 changed files with 370 additions and 17 deletions
9
assets/outfits/hats.tres
Normal file
9
assets/outfits/hats.tres
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_resource type="Resource" script_class="DragonOutfit" load_steps=3 format=3 uid="uid://cnhwn6kfcbjl5"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://s1gx0l4qciqn" path="res://assets/sprites/hat.png" id="1_ahj5i"]
|
||||||
|
[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="1_e7uo0"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_e7uo0")
|
||||||
|
outfits = Array[Texture2D]([ExtResource("1_ahj5i")])
|
||||||
|
metadata/_custom_type_script = "uid://rw26nny160xh"
|
9
assets/outfits/shirts.tres
Normal file
9
assets/outfits/shirts.tres
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_resource type="Resource" script_class="DragonOutfit" load_steps=3 format=3 uid="uid://etegcak2sphs"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dc2uk6tqtwl4n" path="res://assets/sprites/shirt.png" id="1_136ph"]
|
||||||
|
[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="1_yaxr2"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_yaxr2")
|
||||||
|
outfits = Array[Texture2D]([ExtResource("1_136ph")])
|
||||||
|
metadata/_custom_type_script = "uid://rw26nny160xh"
|
9
assets/outfits/shoes.tres
Normal file
9
assets/outfits/shoes.tres
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_resource type="Resource" script_class="DragonOutfit" load_steps=3 format=3 uid="uid://ba5684xylts3f"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://8srlwinjr3tt" path="res://assets/sprites/shoes.png" id="1_2hegr"]
|
||||||
|
[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="1_lu1y3"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_lu1y3")
|
||||||
|
outfits = Array[Texture2D]([ExtResource("1_2hegr")])
|
||||||
|
metadata/_custom_type_script = "uid://rw26nny160xh"
|
BIN
assets/sprites/hat.png
Normal file
BIN
assets/sprites/hat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
34
assets/sprites/hat.png.import
Normal file
34
assets/sprites/hat.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://s1gx0l4qciqn"
|
||||||
|
path="res://.godot/imported/hat.png-d10ab25b5ff6a88ab50e6c69248a3ef0.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/hat.png"
|
||||||
|
dest_files=["res://.godot/imported/hat.png-d10ab25b5ff6a88ab50e6c69248a3ef0.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
assets/sprites/shirt.png
Normal file
BIN
assets/sprites/shirt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
34
assets/sprites/shirt.png.import
Normal file
34
assets/sprites/shirt.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dc2uk6tqtwl4n"
|
||||||
|
path="res://.godot/imported/shirt.png-e59b3d32b60ac1a259719e0f7d9fdc17.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/shirt.png"
|
||||||
|
dest_files=["res://.godot/imported/shirt.png-e59b3d32b60ac1a259719e0f7d9fdc17.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
assets/sprites/shoes.png
Normal file
BIN
assets/sprites/shoes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
34
assets/sprites/shoes.png.import
Normal file
34
assets/sprites/shoes.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://8srlwinjr3tt"
|
||||||
|
path="res://.godot/imported/shoes.png-47dd2ca75c2aff89c900c933c1df27c2.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/shoes.png"
|
||||||
|
dest_files=["res://.godot/imported/shoes.png-47dd2ca75c2aff89c900c933c1df27c2.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -3,9 +3,12 @@ extends Button
|
||||||
|
|
||||||
@export var dragon_editor: PackedScene
|
@export var dragon_editor: PackedScene
|
||||||
|
|
||||||
|
@onready var base: GameManager = $"../.."
|
||||||
|
|
||||||
|
|
||||||
func _on_button_up() -> void:
|
func _on_button_up() -> void:
|
||||||
var editor: Window = dragon_editor.instantiate()
|
var editor: DragonEditor = dragon_editor.instantiate()
|
||||||
|
editor.on_create_dragon.connect(base.add_dragon)
|
||||||
|
|
||||||
var window_position: Vector2i = DisplayServer.window_get_position()
|
var window_position: Vector2i = DisplayServer.window_get_position()
|
||||||
var window_size: Vector2i = DisplayServer.window_get_size()
|
var window_size: Vector2i = DisplayServer.window_get_size()
|
||||||
|
|
|
@ -2,5 +2,40 @@ extends Window
|
||||||
class_name DragonEditor
|
class_name DragonEditor
|
||||||
|
|
||||||
|
|
||||||
|
@onready var hat: TextureRect = $CanvasLayer/Dragon/Hat
|
||||||
|
@onready var shirt: TextureRect = $CanvasLayer/Dragon/Shirt
|
||||||
|
@onready var shoes: TextureRect = $CanvasLayer/Dragon/Shoes
|
||||||
|
|
||||||
|
@export var hat_outfits: DragonOutfit
|
||||||
|
@export var shirt_outfits: DragonOutfit
|
||||||
|
@export var shoes_outfits: DragonOutfit
|
||||||
|
|
||||||
|
|
||||||
|
signal on_create_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
hat.texture = null
|
||||||
|
shirt.texture = null
|
||||||
|
shoes.texture = null
|
||||||
|
|
||||||
|
|
||||||
func _on_close_requested() -> void:
|
func _on_close_requested() -> void:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_change_hat_pressed() -> void:
|
||||||
|
hat.texture = hat_outfits.pick_next()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_change_shirt_pressed() -> void:
|
||||||
|
shirt.texture = shirt_outfits.pick_next()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_change_shoes_pressed() -> void:
|
||||||
|
shoes.texture = shoes_outfits.pick_next()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_create_pressed() -> void:
|
||||||
|
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture)
|
||||||
|
queue_free()
|
||||||
|
|
|
@ -1,12 +1,123 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://fut42ruut302"]
|
[gd_scene load_steps=9 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="Script" uid="uid://bfuos2kgfgber" path="res://scenes/dragon_editor/dragon_editor.gd" id="1_8vkll"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="2_un5ur"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_vvtct"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://s1gx0l4qciqn" path="res://assets/sprites/hat.png" id="3_4q6gv"]
|
||||||
|
[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="Texture2D" uid="uid://dc2uk6tqtwl4n" path="res://assets/sprites/shirt.png" id="4_6sr44"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://8srlwinjr3tt" path="res://assets/sprites/shoes.png" id="5_wby0j"]
|
||||||
|
|
||||||
[node name="DragonEditor" type="Window"]
|
[node name="DragonEditor" type="Window"]
|
||||||
title = "Dragon Editor"
|
title = "Dragon Editor"
|
||||||
|
position = Vector2i(0, 36)
|
||||||
size = Vector2i(300, 500)
|
size = Vector2i(300, 500)
|
||||||
min_size = Vector2i(300, 500)
|
min_size = Vector2i(300, 500)
|
||||||
max_size = Vector2i(1000, 1000)
|
max_size = Vector2i(1000, 1000)
|
||||||
script = ExtResource("1_8vkll")
|
script = ExtResource("1_8vkll")
|
||||||
|
hat_outfits = ExtResource("2_vvtct")
|
||||||
|
shirt_outfits = ExtResource("3_xhgxf")
|
||||||
|
shoes_outfits = ExtResource("4_1ivi1")
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer"]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -89.0
|
||||||
|
offset_bottom = 101.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
|
||||||
|
[node name="change_hat" type="Button" parent="CanvasLayer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "barret"
|
||||||
|
|
||||||
|
[node name="change_shirt" type="Button" parent="CanvasLayer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "samarreta"
|
||||||
|
|
||||||
|
[node name="change_shoes" type="Button" parent="CanvasLayer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "sabata"
|
||||||
|
|
||||||
|
[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
|
||||||
|
text = "crea"
|
||||||
|
|
||||||
|
[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 = -64.0
|
||||||
|
offset_top = -64.0
|
||||||
|
offset_right = 64.0
|
||||||
|
offset_bottom = 64.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("2_un5ur")
|
||||||
|
|
||||||
|
[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 = -90.0
|
||||||
|
offset_top = -109.0
|
||||||
|
offset_right = 93.0
|
||||||
|
offset_bottom = 74.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("3_4q6gv")
|
||||||
|
expand_mode = 1
|
||||||
|
|
||||||
|
[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 = -113.0
|
||||||
|
offset_top = -59.0
|
||||||
|
offset_right = 124.0
|
||||||
|
offset_bottom = 79.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("4_6sr44")
|
||||||
|
expand_mode = 1
|
||||||
|
|
||||||
|
[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 = -96.0
|
||||||
|
offset_top = -119.0
|
||||||
|
offset_right = 113.0
|
||||||
|
offset_bottom = 90.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("5_wby0j")
|
||||||
|
expand_mode = 1
|
||||||
|
|
||||||
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_hat" to="." method="_on_change_hat_pressed"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_shirt" to="." method="_on_change_shirt_pressed"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_shoes" to="." method="_on_change_shoes_pressed"]
|
||||||
|
[connection signal="pressed" from="CanvasLayer/create" to="." method="_on_create_pressed"]
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6eaxg"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_6eaxg"]
|
||||||
size = Vector2(128, 128)
|
size = Vector2(128, 128)
|
||||||
|
|
||||||
[node name="Dragon" type="Area2D"]
|
[node name="Dragon" type="Area2D" node_paths=PackedStringArray("dragon")]
|
||||||
script = ExtResource("1_jccds")
|
script = ExtResource("1_jccds")
|
||||||
|
dragon = NodePath("Dragon")
|
||||||
|
|
||||||
[node name="Dragon" parent="." instance=ExtResource("2_l1h0r")]
|
[node name="Dragon" parent="." instance=ExtResource("2_l1h0r")]
|
||||||
position = Vector2(-64, -64)
|
position = Vector2(-64, -64)
|
||||||
|
|
|
@ -2,7 +2,9 @@ extends Area2D
|
||||||
class_name DragonEntity
|
class_name DragonEntity
|
||||||
|
|
||||||
|
|
||||||
signal on_pick(position)
|
@export var dragon: DragonSprite
|
||||||
|
|
||||||
|
signal on_pick(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D)
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -13,5 +15,9 @@ func _input_event(viewport, event, shape_idx) -> void:
|
||||||
if event is InputEventMouseButton \
|
if event is InputEventMouseButton \
|
||||||
and event.button_index == MOUSE_BUTTON_LEFT \
|
and event.button_index == MOUSE_BUTTON_LEFT \
|
||||||
and event.is_pressed():
|
and event.is_pressed():
|
||||||
on_pick.emit(position)
|
on_pick.emit(position, dragon.hat.texture, dragon.shirt.texture, dragon.shoes.texture)
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||||
|
dragon.dress(hat, shirt, shoes)
|
||||||
|
|
13
scenes/dragons/dragon_sprite.gd
Normal file
13
scenes/dragons/dragon_sprite.gd
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
extends Node2D
|
||||||
|
class_name DragonSprite
|
||||||
|
|
||||||
|
|
||||||
|
@export var hat: Sprite2D
|
||||||
|
@export var shirt: Sprite2D
|
||||||
|
@export var shoes: Sprite2D
|
||||||
|
|
||||||
|
|
||||||
|
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||||
|
self.hat.texture = hat
|
||||||
|
self.shirt.texture = shirt
|
||||||
|
self.shoes.texture = shoes
|
1
scenes/dragons/dragon_sprite.gd.uid
Normal file
1
scenes/dragons/dragon_sprite.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://bjiap06gs02j
|
|
@ -1,10 +1,36 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://baa8gpicw2yg0"]
|
[gd_scene load_steps=6 format=3 uid="uid://baa8gpicw2yg0"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="1_ixu8j"]
|
[ext_resource type="Texture2D" uid="uid://fdqnc2qrrvn1" path="res://assets/sprites/icon.svg" id="1_ixu8j"]
|
||||||
|
[ext_resource type="Script" uid="uid://bjiap06gs02j" path="res://scenes/dragons/dragon_sprite.gd" id="1_oaoux"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://s1gx0l4qciqn" path="res://assets/sprites/hat.png" id="2_hdh4v"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dc2uk6tqtwl4n" path="res://assets/sprites/shirt.png" id="3_oaoux"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://8srlwinjr3tt" path="res://assets/sprites/shoes.png" id="4_yf7bj"]
|
||||||
|
|
||||||
[node name="Dragon" type="Node2D"]
|
[node name="Dragon" type="Node2D" node_paths=PackedStringArray("hat", "shirt", "shoes")]
|
||||||
|
script = ExtResource("1_oaoux")
|
||||||
|
hat = NodePath("Sprite/Hat")
|
||||||
|
shirt = NodePath("Sprite/Shirt")
|
||||||
|
shoes = NodePath("Sprite/Shoes")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
position = Vector2(0, 1)
|
position = Vector2(0, 1)
|
||||||
texture = ExtResource("1_ixu8j")
|
texture = ExtResource("1_ixu8j")
|
||||||
offset = Vector2(64, 64)
|
offset = Vector2(64, 64)
|
||||||
|
|
||||||
|
[node name="Hat" type="Sprite2D" parent="Sprite"]
|
||||||
|
position = Vector2(39, 22)
|
||||||
|
scale = Vector2(0.503906, 0.503906)
|
||||||
|
texture = ExtResource("2_hdh4v")
|
||||||
|
offset = Vector2(64, 64)
|
||||||
|
|
||||||
|
[node name="Shirt" type="Sprite2D" parent="Sprite"]
|
||||||
|
position = Vector2(40, 56)
|
||||||
|
scale = Vector2(0.477783, 0.288361)
|
||||||
|
texture = ExtResource("3_oaoux")
|
||||||
|
offset = Vector2(64, 64)
|
||||||
|
|
||||||
|
[node name="Shoes" type="Sprite2D" parent="Sprite"]
|
||||||
|
position = Vector2(48, 39)
|
||||||
|
scale = Vector2(0.353516, 0.353516)
|
||||||
|
texture = ExtResource("4_yf7bj")
|
||||||
|
offset = Vector2(64, 64)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
class_name GameManager
|
||||||
|
|
||||||
|
|
||||||
@export var dragon_template: PackedScene
|
@export var dragon_template: PackedScene
|
||||||
|
@ -29,20 +30,22 @@ func move_window_to_bottom_right():
|
||||||
DisplayServer.window_set_position(new_position)
|
DisplayServer.window_set_position(new_position)
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func add_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||||
if event.is_pressed() and event.is_action("ui_accept"):
|
# TODO: Check for free positon
|
||||||
_instantiate_dragon_ingame(dragon_spots[0].position)
|
_instantiate_dragon_ingame(dragon_spots[0].position, hat, shirt, shoes)
|
||||||
|
# TODO: Add to dragon library
|
||||||
|
|
||||||
|
|
||||||
func _instantiate_dragon_ingame(position: Vector2):
|
func _instantiate_dragon_ingame(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||||
var dragon: DragonEntity = dragon_ingame.instantiate()
|
var dragon: DragonEntity = dragon_ingame.instantiate()
|
||||||
|
dragon.dress(hat, shirt, shoes)
|
||||||
add_child(dragon)
|
add_child(dragon)
|
||||||
dragon.position = position
|
dragon.position = position
|
||||||
dragon.on_pick.connect(_pick_dragon)
|
dragon.on_pick.connect(_pick_dragon)
|
||||||
|
|
||||||
|
|
||||||
func _pick_dragon(position: Vector2):
|
func _pick_dragon(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||||
var dragon: Dragon = _instantiator.instantiate(position)
|
var dragon: Dragon = _instantiator.instantiate(position, hat, shirt, shoes)
|
||||||
dragon.place_back.connect(_dragon_place_back)
|
dragon.place_back.connect(_dragon_place_back)
|
||||||
add_child(dragon)
|
add_child(dragon)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ extends Window
|
||||||
class_name Dragon
|
class_name Dragon
|
||||||
|
|
||||||
@export var dragon_speed: float = 20.0
|
@export var dragon_speed: float = 20.0
|
||||||
@export var dragon: Node2D
|
@export var dragon: DragonSprite
|
||||||
|
|
||||||
@onready var _actual_position: Vector2 = position
|
@onready var _actual_position: Vector2 = position
|
||||||
var main_window_rect: Rect2i
|
var main_window_rect: Rect2i
|
||||||
|
@ -40,6 +40,10 @@ func _process(delta: float) -> void:
|
||||||
_move_to_target(delta)
|
_move_to_target(delta)
|
||||||
|
|
||||||
|
|
||||||
|
func dress(hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||||
|
dragon.dress(hat, shirt, shoes)
|
||||||
|
|
||||||
|
|
||||||
func _move_to_target(delta: float):
|
func _move_to_target(delta: float):
|
||||||
if _actual_position.distance_to(_target_pos) > 10.0:
|
if _actual_position.distance_to(_target_pos) > 10.0:
|
||||||
var direction: Vector2 = (_target_pos - _actual_position).normalized()
|
var direction: Vector2 = (_target_pos - _actual_position).normalized()
|
||||||
|
|
|
@ -10,9 +10,9 @@ func _init(dragon: PackedScene, viewport: Viewport, window: Window) -> void:
|
||||||
_dragon_template = dragon
|
_dragon_template = dragon
|
||||||
|
|
||||||
|
|
||||||
func instantiate(position: Vector2) -> Node:
|
func instantiate(position: Vector2, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> Node:
|
||||||
var relative_position: Vector2i = _calculate_relative_position(position)
|
var relative_position: Vector2i = _calculate_relative_position(position)
|
||||||
return _instantiate_dragon(relative_position)
|
return _instantiate_dragon(relative_position, hat, shirt, shoes)
|
||||||
|
|
||||||
|
|
||||||
func _calculate_window_scale() -> Vector2:
|
func _calculate_window_scale() -> Vector2:
|
||||||
|
@ -27,13 +27,14 @@ func _calculate_relative_position(position: Vector2) -> Vector2i:
|
||||||
return Vector2i(Vector2(position) * scale)
|
return Vector2i(Vector2(position) * scale)
|
||||||
|
|
||||||
|
|
||||||
func _instantiate_dragon(relative_position: Vector2i) -> Node:
|
func _instantiate_dragon(relative_position: Vector2i, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> Node:
|
||||||
var dragon: Dragon = _dragon_template.instantiate()
|
var dragon: Dragon = _dragon_template.instantiate()
|
||||||
|
|
||||||
var window_position: Vector2i = DisplayServer.window_get_position()
|
var window_position: Vector2i = DisplayServer.window_get_position()
|
||||||
var window_size: Vector2i = DisplayServer.window_get_size()
|
var window_size: Vector2i = DisplayServer.window_get_size()
|
||||||
|
|
||||||
dragon.position = window_position + relative_position - dragon.size / 2
|
dragon.position = window_position + relative_position - dragon.size / 2
|
||||||
|
dragon.dress(hat, shirt, shoes)
|
||||||
|
|
||||||
var size: float = _calculate_window_scale().y
|
var size: float = _calculate_window_scale().y
|
||||||
dragon.set_scale(size)
|
dragon.set_scale(size)
|
||||||
|
|
19
src/dragon_outfit.gd
Normal file
19
src/dragon_outfit.gd
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
extends Resource
|
||||||
|
class_name DragonOutfit
|
||||||
|
|
||||||
|
|
||||||
|
@export var outfits: Array[Texture2D]
|
||||||
|
var index: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _init(outfits: Array[Texture2D] = []):
|
||||||
|
self.outfits = outfits
|
||||||
|
|
||||||
|
|
||||||
|
func pick_next() -> Texture2D:
|
||||||
|
index += 1
|
||||||
|
index %= (len(outfits) + 1)
|
||||||
|
if index == 0:
|
||||||
|
return null
|
||||||
|
|
||||||
|
return outfits[index - 1]
|
1
src/dragon_outfit.gd.uid
Normal file
1
src/dragon_outfit.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://rw26nny160xh
|
Loading…
Add table
Add a link
Reference in a new issue