challenge-editor/scene/character_bag_card.gd
2024-10-04 18:08:33 +08:00

32 lines
1.1 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends TextureRect
class_name CharacterBagCard
#被按下时发出
signal self_click(data:Dictionary)
@onready var star_group:Array[TextureRect]=[$mask/HBoxContainer/HBoxContainer/TextureRect, $mask/HBoxContainer/HBoxContainer/TextureRect2, $mask/HBoxContainer/HBoxContainer/TextureRect3, $mask/HBoxContainer/HBoxContainer/TextureRect4, $mask/HBoxContainer/HBoxContainer/TextureRect5]
#初始化数据应先更改此字典然后进行add child 触发ready
var data:Dictionary
#设置星数
func set_star_num(num:int):
for i in star_group.size():
if i<num:
star_group[i].show()
else:
star_group[i].hide()
pass
#设置卡面
func set_face(icon):
%texture_face.texture=icon
#设置名字
func set_character_name(n:String):
%n.text=n
pass
func _ready() -> void:
set_star_num(CharacterTool.get_character_star_num(data))
set_face(Database.get_texture(CharacterTool.get_skin_now_use_data(data)["card_face"]))
set_character_name(CharacterTool.get_character_name(data))
func _on_button_pressed() -> void:
self_click.emit(data)
pass # Replace with function body.