1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00
Files
fallingshrimp dc4b080a09 feat: 新增角色系统及基础功能实现
新增HCN、Lynx和MuyangDog三个可玩角色及其相关资源
实现角色选择界面和角色属性系统
重构玩家生成逻辑以支持角色选择
优化角色卡片UI显示效果
2026-05-04 21:34:57 +08:00

57 lines
1.8 KiB
GDScript

@tool
extends Control
class_name CharacterCard
signal select()
@export var displayName: String = "Unknown Character"
@export var slogan: String = "Slogan"
@export var avatar: Texture2D = null
@export_multiline var description: String = ""
@export var fields: Array[FieldStore.Entity] = []
@export var fieldValues: Array[float] = []
@export var clickToRebuild: bool = false
@export var borderOpacity: float = 0
@onready var avatarTexture: TextureRect = $%avatarTexture
@onready var nameLebel: Label = $%nameLabel
@onready var sloganLabel: Label = $%sloganLabel
@onready var descriptionLabel: Label = $%descriptionLabel
@onready var fieldsBox: Control = $%fields
@onready var animator: AnimationPlayer = $%animator
var watcher: Watcher = Watcher.new(false)
@onready var panelStyleBox: StyleBoxFlat = get_theme_stylebox("panel").duplicate()
func _ready():
add_theme_stylebox_override("panel", panelStyleBox)
watcher.changed.connect(rebuildInfo)
gui_input.connect(
func(event):
if event is InputEventMouseButton:
if !(event.pressed && event.button_index == MouseButton.MOUSE_BUTTON_LEFT): return
if animator.is_playing(): return
select.emit()
)
rebuildInfo()
func _process(_delta):
watcher.setState(clickToRebuild)
panelStyleBox.border_width_top = int(10 * borderOpacity)
panelStyleBox.border_width_bottom = int(10 * borderOpacity)
func rebuildInfo():
avatarTexture.texture = avatar
nameLebel.text = displayName
sloganLabel.text = "%s" % slogan
descriptionLabel.text = description
for child in fieldsBox.get_children():
fieldsBox.remove_child(child)
for index in len(fields):
var field = fields[index]
var value = fieldValues[index]
var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate() as FieldShow
fieldShow.field = field
fieldShow.showAdvantage = true
fieldShow.value = value
fieldsBox.add_child(fieldShow)