1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00
Files
fallingshrimp 4a7ba8aec6 feat(物品系统): 新增饮料物品并优化物品显示逻辑
添加草莓气泡水物品资源及配置
调整阴阳球物品属性数值
优化物品显示逻辑,支持负数消耗显示为绿色
修改物品应用逻辑,允许负消耗直接扣除
2026-04-12 15:43:13 +08:00

41 lines
1.2 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:
if count < 0:
countLabel.label_settings.font_color = Color.GREEN
countLabel.text = "+%d" % abs(count)
else:
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