challenge-editor/scene/character_select_card.gd
2024-09-20 17:31:23 +08:00

44 lines
1.2 KiB
GDScript

extends TextureRect
var is_selected:bool=false:
set(val):
if val!=is_selected:
if val:
%select_texture.show()
else:
%select_texture.hide()
pass
is_selected=val
@onready var texture_face: TextureRect = %texture_face
@onready var star_group=[$mask/HBoxContainer/HBoxContainer/TextureRect, $mask/HBoxContainer/HBoxContainer/TextureRect2, $mask/HBoxContainer/HBoxContainer/TextureRect3, $mask/HBoxContainer/HBoxContainer/TextureRect4, $mask/HBoxContainer/HBoxContainer/TextureRect5]
@onready var n: Label = %n
func set_star_num(num:int):
for i in star_group.size():
if i<num:
star_group[i].show()
else:
star_group[i].hide()
var data:Dictionary={
}
signal pressed(data,node,is_select)
func _on_tool_button_pressed() -> void:
is_selected=!is_selected
pressed.emit(data,self,is_selected)
pass # Replace with function body.
func _ready() -> void:
#set_data(Global.get_character_data("test_character_01"))
pass
func set_data(_data:Dictionary):
data=_data
var skin_data=data["character"]["skin"][data["character"]["skin_now_use"]]
texture_face.texture=Global.get_texture(skin_data["card_face"])
set_star_num(data["character"]["star"])
n.text=data["character"]["name"]
pass