fix: compilation errors that were caused by the dragonproperties refactoring

This commit is contained in:
Gerard Gascón 2025-04-11 23:52:31 +02:00
parent 46726bca32
commit 50bc814367
14 changed files with 66 additions and 207 deletions

View file

@ -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)

View file

@ -4,13 +4,20 @@ class_name DragonSprite
@export var hat: Sprite2D
@export var shirt: Sprite2D
@export var shoes: Sprite2D
@export var decor: Sprite2D
@export var color: Sprite2D
@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):
self.hat.texture = hat_outfits.get_texture(properties.hat)
self.shirt.texture = shirt_outfits.get_texture(properties.shirt)
self.decor.texture = decor_outfits.get_texture(properties.decor)
self.color.texture = color_outfits.get_texture(properties.color)
func walk_left():

View file

@ -1,20 +1,29 @@
[gd_scene load_steps=8 format=3 uid="uid://baa8gpicw2yg0"]
[gd_scene load_steps=12 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="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_mxc00"]
[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="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_umqeb"]
[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_7b2ll"]
[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="Resource" uid="uid://bcs60f2k7h0jc" path="res://assets/outfits/dragons.tres" id="5_x2k4p"]
[ext_resource type="SpriteFrames" uid="uid://4cm7picl2gvs" path="res://assets/animations/dragon_green.tres" id="6_yf7bj"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oaoux"]
size = Vector2(76, 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")
decor = NodePath("Sprite/Decor")
color = NodePath("Sprite")
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="."]
@ -32,10 +41,11 @@ texture = ExtResource("3_oaoux")
[node name="Shirt" type="Sprite2D" parent="Sprite"]
texture = ExtResource("4_oaoux")
[node name="Shoes" type="Sprite2D" parent="Sprite"]
[node name="Decor" type="Sprite2D" parent="Sprite"]
texture = ExtResource("5_stf6f")
[node name="DragonBody" type="AnimatedSprite2D" parent="."]
visible = false
position = Vector2(36, 34)
sprite_frames = ExtResource("6_yf7bj")
animation = &"idle"