challenge-editor/scene/character_select.gd

50 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-09-18 17:57:10 +08:00
extends Control
signal back
const CHARACTER_SELECT_CARD = preload("res://scene/character_select_card.tscn")
2024-09-20 12:02:11 +08:00
@onready var character_add_pos: VFlowContainer = $VBoxContainer/HBoxContainer/margin/HBoxContainer/ScrollContainer/character_add_pos
@onready var start: ToolButton = $VBoxContainer/HBoxContainer2/TextureRect/start
var now_select_node
var now_select_data:
set(val):
2024-09-20 17:31:23 +08:00
if now_select_node!=null:
now_select_node.is_selected=false
2024-09-20 12:02:11 +08:00
start.disable(val==null)
now_select_data=val
2024-09-20 17:31:23 +08:00
2024-09-18 17:57:10 +08:00
var data:Dictionary={
}
func _on_back_pressed() -> void:
back.emit()
pass # Replace with function body.
2024-09-27 17:51:20 +08:00
func fresh():
2024-09-20 12:02:11 +08:00
start.disable(true)
for i in character_add_pos.get_children():
i.queue_free()
2024-09-20 17:31:23 +08:00
for i in Global.system_game_data["unlock_character"]:
2024-09-20 12:02:11 +08:00
var new_character=CHARACTER_SELECT_CARD.instantiate()
character_add_pos.add_child(new_character)
new_character.set_data(Global.get_character_data(i))
new_character.pressed.connect(pressed)
2024-09-27 17:51:20 +08:00
func _ready() -> void:
fresh()
2024-09-21 11:52:44 +08:00
2024-09-20 12:02:11 +08:00
func pressed(data,node,is_select):
if is_select:
now_select_data=data
now_select_node=node
else:
now_select_data=null
now_select_node=null
pass
func _on_start_pressed() -> void:
2024-09-20 17:31:23 +08:00
Global.now_game_data.character_data=now_select_data
SceneManager.change_scene_to("res://scene/game_flow.tscn")
2024-09-20 12:02:11 +08:00
pass # Replace with function body.