1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00
Files
Dog-Lynx-And-HCN/scripts/Statemachine/ItemShow.gd
T
fallingshrimp b8bba34d83 refactor(UI): 清理武器展示界面的冗余代码和配置
移除武器展示界面中不必要的可见性控制代码,统一通过脚本管理可见性
简化场景文件中的冗余属性设置,保持与脚本逻辑一致
2025-12-14 15:52:57 +08:00

37 lines
1.1 KiB
GDScript

@tool
extends HBoxContainer
class_name ItemShow
@export var type: ItemStore.ItemType = ItemStore.ItemType.BASEBALL
@export var count: int = 0
@export var autoFree: bool = false
@export var enough: bool = true
@onready var avatarTexture: TextureRect = $"%avatar"
@onready var countLabel: Label = $"%count"
@onready var animator: AnimationPlayer = $"%animator"
func _ready():
countLabel.label_settings = countLabel.label_settings.duplicate()
if autoFree:
animator.play("show")
await animator.animation_finished
await TickTool.millseconds(GameRule.itemShowLifetime)
animator.play("hide")
await animator.animation_finished
queue_free()
func _physics_process(_delta):
avatarTexture.texture = ItemStore.getTexture(type)
countLabel.text = str(count)
if enough:
countLabel.label_settings.font_color = Color.WHITE
else:
countLabel.label_settings.font_color = Color.RED
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false):
var item = ComponentManager.getUIComponent("ItemShow").instantiate()
item.type = itemType
item.count = itemCount
item.autoFree = isAutoFree
return item