1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

feat(武器系统): 添加自动强化和一键强化功能

- 新增自动强化开关和按钮图标资源
- 实现武器自动强化逻辑
- 添加一键强化功能可连续升级
- 优化武器卡UI布局和样式
- 增加强化操作时的提示信息
This commit is contained in:
2026-05-03 17:45:00 +08:00
parent bc89c93feb
commit 9df62992e5
16 changed files with 351 additions and 33 deletions
+2
View File
@@ -66,6 +66,8 @@ func apply(entity: EntityBase):
entity.weaponStore.add_child(instance)
entity.rebuildWeaponIcons()
hide()
else:
UIState.showTip("物品不足!", TipBox.MessageType.ERROR)
selected.emit(allHave)
return allHave
func countOf(index: int) -> int:
+42 -21
View File
@@ -30,34 +30,53 @@ enum EmitType {
@export var debugRebuild: bool = false
@export var level: int = 0
@onready var avatarRect: TextureRect = $"%avatar"
@onready var nameLabel: WeaponName = $"%name"
@onready var sourceLabel: Label = $"%source"
@onready var teaseLabel: Label = $"%tease"
@onready var energyLabel: Label = $"%energy"
@onready var beachball: ItemShow = $"%beachball"
@onready var soul: ItemShow = $"%soul"
@onready var descriptionLabel: RichTextLabel = $"%description"
@onready var updateBtn: Button = $"%updateBtn"
@onready var extractBtn: Button = $"%extractBtn"
@onready var inlayBtn: Button = $"%inlayBtn"
@onready var sounds: Node2D = $"%sounds"
@onready var moveLeftBtn: Button = $"%moveleft"
@onready var moveRightBtn: Button = $"%moveright"
@onready var avatarRect: TextureRect = $%avatar
@onready var nameLabel: WeaponName = $%name
@onready var sourceLabel: Label = $%source
@onready var teaseLabel: Label = $%tease
@onready var energyLabel: Label = $%energy
@onready var beachball: ItemShow = $%beachball
@onready var soul: ItemShow = $%soul
@onready var descriptionLabel: RichTextLabel = $%description
@onready var sounds: Node2D = $%sounds
@onready var moveLeftBtn: Button = $%moveleft
@onready var moveRightBtn: Button = $%moveright
@onready var autoUpdateBtn: Button = $%autoUpdateBtn
@onready var onceUpdateBtn: Button = $%onceUpdateBtn
@onready var updateBtn: Button = $%updateBtn
@onready var extractBtn: Button = $%extractBtn
@onready var inlayBtn: Button = $%inlayBtn
var cooldownTimer: CooldownTimer = null
var originalStore: Dictionary = {}
var chargedTime: float = 0
var attackSpeed: float = 1
var looping: bool = false
var autoUpdate: bool = false
func _ready():
cooldownTimer = CooldownTimer.new()
cooldownTimer.cooldown = cooldown
originalStore = store
autoUpdateBtn.toggled.connect(
func(on: bool):
autoUpdate = on
)
onceUpdateBtn.pressed.connect(
func():
var count = 0
while canUpdate(UIState.player):
updateApply(UIState.player)
count += 1
if count > 0:
UIState.showTip("一键强化提升了[b]%d[/b]级!" % count)
else:
UIState.showTip("一键强化没有提升等级......", TipBox.MessageType.ERROR)
)
updateBtn.pressed.connect(
func():
apply(UIState.player)
updateApply(UIState.player)
)
extractBtn.pressed.connect(
func():
@@ -105,18 +124,20 @@ func _physics_process(_delta):
if debugRebuild:
rebuildInfo()
func canUpdate():
return UIState.player.hasItem({ItemStore.ItemType.BEACHBALL: costBeachball})
func canUpdate(entity: EntityBase):
return entity.hasItem({ItemStore.ItemType.BEACHBALL: costBeachball})
func canInlay():
return UIState.player.hasItem({ItemStore.ItemType.SOUL: soulLevel})
func apply(entity: EntityBase) -> bool:
if canUpdate():
func updateApply(entity: EntityBase) -> bool:
if canUpdate(entity):
level += 1
entity.inventory[ItemStore.ItemType.BEACHBALL] -= costBeachball
updateStore(level, entity)
costBeachball = floor(GameRule.weaponUpdateCost * costBeachball)
rebuildInfo(true)
return true
else:
UIState.showTip("沙滩球不足!", TipBox.MessageType.ERROR)
return false
func updateStore(to: int, entity: EntityBase):
store = update(to, originalStore.duplicate(), entity)
@@ -142,9 +163,9 @@ func rebuildInfo(showNext: bool = false):
beachball.count = costBeachball
soul.count = soulLevel
if is_instance_valid(UIState.player):
beachball.enough = canUpdate()
beachball.enough = canUpdate(UIState.player)
soul.enough = canInlay()
descriptionLabel.text = buildDescription(showNext && (canUpdate() || canInlay()))
descriptionLabel.text = buildDescription(showNext && (canUpdate(UIState.player) || canInlay()))
func formatValue(value: Variant, type: FieldStore.DataType) -> String:
if type == FieldStore.DataType.VALUE:
return "%.2f" % value