feat: added town name setting
This commit is contained in:
parent
a8b292aa03
commit
fc177656c5
8 changed files with 134 additions and 24 deletions
|
@ -1,7 +1,6 @@
|
|||
extends Window
|
||||
class_name DragonEditor
|
||||
|
||||
|
||||
@onready var hat: AnimatedSprite2D = $CanvasLayer/Dragon/Hat
|
||||
@onready var shirt: AnimatedSprite2D = $CanvasLayer/Dragon/Shirt
|
||||
@onready var decor: AnimatedSprite2D = $CanvasLayer/Dragon/Decor
|
||||
|
@ -12,24 +11,26 @@ class_name DragonEditor
|
|||
@export var decor_outfits: DragonOutfit
|
||||
@export var dragon_colors: DragonOutfit
|
||||
|
||||
var _save_load: SaveLoad = SaveLoad.new()
|
||||
|
||||
@onready var dragon_name: LineEdit = $CanvasLayer/NameLabel/LineEdit
|
||||
|
||||
@onready var dragger: DraggableWindow = $CanvasLayer/Dragger
|
||||
|
||||
signal on_create_dragon(properties: DragonProperties)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_save_load.load()
|
||||
|
||||
hat.visible = false
|
||||
shirt.visible = false
|
||||
decor.visible = false
|
||||
dragon.play('idle')
|
||||
|
||||
hat_outfits.index = 0
|
||||
shirt_outfits.index = 0
|
||||
decor_outfits.index = 0
|
||||
dragon_colors.index = 0
|
||||
|
||||
|
||||
hat_outfits.reset()
|
||||
shirt_outfits.reset()
|
||||
decor_outfits.reset()
|
||||
dragon_colors.reset()
|
||||
|
||||
dragger.on_drag.connect(_on_drag)
|
||||
|
||||
|
||||
|
@ -64,7 +65,18 @@ func _pick_next_animation(sprite: AnimatedSprite2D, outfits: DragonOutfit):
|
|||
return
|
||||
sprite.visible = true
|
||||
sprite.set_sprite_frames(animation)
|
||||
sprite.play('idle')
|
||||
_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):
|
||||
|
@ -74,14 +86,14 @@ func _pick_previous_animation(sprite: AnimatedSprite2D, outfits: DragonOutfit):
|
|||
return
|
||||
sprite.visible = true
|
||||
sprite.set_sprite_frames(animation)
|
||||
sprite.play('idle')
|
||||
_restart_animations()
|
||||
|
||||
|
||||
func _on_create_pressed() -> void:
|
||||
if dragon_name.text.is_empty():
|
||||
return
|
||||
|
||||
var properties = DragonProperties.new(dragon_name.text, "tower", hat_outfits.index, shirt_outfits.index, decor_outfits.index, dragon_colors.index)
|
||||
|
||||
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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue