challenge-editor/scene/character_select_card.gd
2024-10-04 18:08:33 +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.duplicate(),self,is_selected)
pass # Replace with function body.
func _ready() -> void:
#set_data(Database.get_character_data("test_character_01"))
pass
func set_data(_data:Dictionary):
data=_data
var skin_data=CharacterTool.get_skin_now_use_data(data)
texture_face.texture=Database.get_texture(skin_data["card_face"])
set_star_num(data["star"])
n.text=data["name"]
pass