2024-09-10 16:34:05 +08:00
|
|
|
|
extends TextureRect
|
|
|
|
|
class_name CharacterBagCard
|
2024-09-10 18:01:45 +08:00
|
|
|
|
#被按下时发出
|
2024-09-26 11:49:53 +08:00
|
|
|
|
signal self_click(data:Dictionary)
|
2024-09-10 16:34:05 +08:00
|
|
|
|
@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]
|
2024-09-10 18:01:45 +08:00
|
|
|
|
#初始化数据,应先更改此字典,然后进行add child 触发ready
|
2024-09-26 11:49:53 +08:00
|
|
|
|
var data:Dictionary
|
2024-09-10 18:01:45 +08:00
|
|
|
|
#设置星数
|
2024-09-10 16:34:05 +08:00
|
|
|
|
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
|
2024-09-10 18:01:45 +08:00
|
|
|
|
#设置卡面
|
2024-09-26 17:54:02 +08:00
|
|
|
|
func set_face(icon):
|
|
|
|
|
%texture_face.texture=icon
|
2024-09-10 18:01:45 +08:00
|
|
|
|
#设置名字
|
2024-09-10 16:34:05 +08:00
|
|
|
|
func set_character_name(n:String):
|
|
|
|
|
%n.text=n
|
|
|
|
|
pass
|
|
|
|
|
func _ready() -> void:
|
2024-09-26 11:49:53 +08:00
|
|
|
|
set_star_num(CharacterTool.get_character_star_num(data))
|
2024-10-04 18:08:33 +08:00
|
|
|
|
set_face(Database.get_texture(CharacterTool.get_skin_now_use_data(data)["card_face"]))
|
2024-09-26 11:49:53 +08:00
|
|
|
|
set_character_name(CharacterTool.get_character_name(data))
|
2024-09-10 18:01:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_button_pressed() -> void:
|
2024-09-26 11:49:53 +08:00
|
|
|
|
self_click.emit(data)
|
2024-09-10 18:01:45 +08:00
|
|
|
|
pass # Replace with function body.
|