feat: dragon list now with correct outfits

This commit is contained in:
Gerard Gascón 2025-04-18 00:28:50 +02:00
parent 646c232cae
commit 117d23dc4e
3 changed files with 37 additions and 12 deletions

View file

@ -1,10 +1,14 @@
[gd_scene load_steps=6 format=3 uid="uid://cq3orf2ktmel0"]
[gd_scene load_steps=10 format=3 uid="uid://cq3orf2ktmel0"]
[ext_resource type="SpriteFrames" uid="uid://duxxw4mfxql3c" path="res://assets/animations/dragons/verd.tres" id="1_o3jkx"]
[ext_resource type="Script" uid="uid://b7knkhjgtdy4l" path="res://scenes/dragon_list/dragon/dragon_list_entry.gd" id="2_uckob"]
[ext_resource type="SpriteFrames" uid="uid://ccxyplt2t7t6y" path="res://assets/animations/hats/barretina.tres" id="3_jl6px"]
[ext_resource type="Resource" uid="uid://c03ejnvavmcj5" path="res://assets/outfits/dragons.tres" id="3_jpsrj"]
[ext_resource type="Resource" uid="uid://x063x858re3f" path="res://assets/outfits/hats.tres" id="4_58xh2"]
[ext_resource type="SpriteFrames" uid="uid://dsxhfu2ekw7j" path="res://assets/animations/shirts/traje.tres" id="4_v3rc7"]
[ext_resource type="Resource" uid="uid://bsydervvb1jpe" path="res://assets/outfits/shirts.tres" id="5_6mheo"]
[ext_resource type="SpriteFrames" uid="uid://c5rqqy7b5ihi5" path="res://assets/animations/decor/rosa.tres" id="5_jpsrj"]
[ext_resource type="Resource" uid="uid://dkm7d10c1lp2n" path="res://assets/outfits/decor.tres" id="6_dtw4b"]
[node name="Dragon" type="AnimatedSprite2D" node_paths=PackedStringArray("color", "hat", "shirt", "decor")]
sprite_frames = ExtResource("1_o3jkx")
@ -14,6 +18,10 @@ color = NodePath(".")
hat = NodePath("Hat")
shirt = NodePath("Shirt")
decor = NodePath("Decor")
color_outfits = ExtResource("3_jpsrj")
hat_outfits = ExtResource("4_58xh2")
shirt_outfits = ExtResource("5_6mheo")
decor_outfits = ExtResource("6_dtw4b")
[node name="Hat" type="AnimatedSprite2D" parent="."]
sprite_frames = ExtResource("3_jl6px")

View file

@ -7,20 +7,36 @@ class_name DragonListEntry
@export var shirt: AnimatedSprite2D
@export var decor: AnimatedSprite2D
@export var color_outfits: DragonOutfit
@export var hat_outfits: DragonOutfit
@export var shirt_outfits: DragonOutfit
@export var decor_outfits: DragonOutfit
func play_animation(anim: String):
func play_animation(anim: String) -> void:
if color.sprite_frames != null:
color.set_frame(0)
color.play(anim)
if hat.sprite_frames != null:
hat.set_frame(0)
hat.play(anim)
if shirt.sprite_frames != null:
shirt.set_frame(0)
shirt.play(anim)
if decor.sprite_frames != null:
decor.set_frame(0)
decor.play(anim)
func face_direction(left: bool):
func face_direction(left: bool) -> void:
color.flip_h = not left
hat.flip_h = not left
shirt.flip_h = not left
decor.flip_h = not left
func dress(properties: DragonProperties) -> void:
color.sprite_frames = color_outfits.get_texture(properties.color)
hat.sprite_frames = hat_outfits.get_texture(properties.hat)
shirt.sprite_frames = shirt_outfits.get_texture(properties.shirt)
decor.sprite_frames = decor_outfits.get_texture(properties.decor)

View file

@ -35,6 +35,7 @@ func set_library(library: DragonLibrary):
func _instantiate_dragon(dragon: DragonProperties, offset_step: int):
var instance: DragonListEntry = dragon_list_entry_template.instantiate()
instance.dress(dragon)
dragon_list_pivot.add_child(instance)
instance.position.x += offset_step * 110
_dragons.push_back(instance)