mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
307e3dd63f
refactor(物品展示): 修改ItemShow状态机自动隐藏逻辑 feat(游戏逻辑): 添加玩家死亡时的游戏结束界面 style(场景配置): 调整World场景中相机节点位置和偏移 feat(UI): 为ItemShow添加显示动画并更新动画库
31 lines
950 B
GDScript
31 lines
950 B
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
|
|
|
|
@onready var avatarTexture: TextureRect = $"%avatar"
|
|
@onready var countLabel: Label = $"%count"
|
|
@onready var animator: AnimationPlayer = $"%animator"
|
|
|
|
func _ready():
|
|
if autoFree:
|
|
animator.play("show")
|
|
await animator.animation_finished
|
|
await TickTool.millseconds(GameRule.itemShowStayTime) # 等待几秒后自动隐藏
|
|
animator.play("hide")
|
|
await animator.animation_finished
|
|
queue_free()
|
|
func _physics_process(_delta):
|
|
avatarTexture.texture = ItemStore.getTexture(type)
|
|
countLabel.text = str(count)
|
|
|
|
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false):
|
|
var item = preload("res://components/UI/ItemShow.tscn").instantiate()
|
|
item.type = itemType
|
|
item.count = itemCount
|
|
item.autoFree = isAutoFree
|
|
return item
|