From e4b0f2e5f3824543811f4b2cd8a4d356e97ce2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sun, 21 Sep 2025 17:00:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=AD=A6=E5=99=A8=E8=8E=B7=E5=8F=96=E5=92=8C?= =?UTF-8?q?=E6=8F=90=E7=82=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在WeaponShow.gd中修改操作标签文本为"获得武器"和"提炼灵魂" - 在Feed.gd中添加武器获取逻辑,区分已有武器和新增武器情况 - 在EntityBase.gd中重构武器图标更新逻辑,提取为rebuildWeaponIcons方法 --- scripts/Statemachine/EntityBase.gd | 15 ++++++++++----- scripts/Statemachine/WeaponShow.gd | 4 ++-- scripts/Structs/Feed.gd | 12 ++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 7825f98..5dc035f 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -85,7 +85,7 @@ var inventoryMax = { @onready var stageAnimator: AnimationPlayer = $"%stageAnimator" @onready var damageAnchor: Node2D = $"%damageAnchor" @onready var trailParticle: GPUParticles2D = $"%trailParticle" -@onready var weaponStore = $"%weaponStore" +@onready var weaponStore: Node2D = $"%weaponStore" var statebar: EntityStateBar var health: float = 0 @@ -127,10 +127,7 @@ func _ready(): else: UIState.energyPercent.setCurrent(newEnergy) ) - for i in weapons: - var icon: SkillIcon = ComponentManager.getUIComponent("SkillIcon").instantiate() - icon.weapon = i - UIState.skillIconContainer.add_child(icon) + rebuildWeaponIcons() else: if !currentFocusedBoss: currentFocusedBoss = get_tree().get_nodes_in_group("players")[0] @@ -174,6 +171,14 @@ func _physics_process(_delta: float) -> void: trailParticle.emitting = trailing # 通用方法 +func rebuildWeaponIcons(): + if isPlayer(): + for i in UIState.skillIconContainer.get_children(): + i.queue_free() + for i in weapons: + var icon: SkillIcon = ComponentManager.getUIComponent("SkillIcon").instantiate() + icon.weapon = i + UIState.skillIconContainer.add_child(icon) func timeLived(): return WorldManager.getTime() - spawnTime func setStage(stage: int): diff --git a/scripts/Statemachine/WeaponShow.gd b/scripts/Statemachine/WeaponShow.gd index 38eed6b..b5ee26c 100644 --- a/scripts/Statemachine/WeaponShow.gd +++ b/scripts/Statemachine/WeaponShow.gd @@ -21,12 +21,12 @@ func _ready(): nameLabel.text = weaponInstance.displayName soulShow.count = weaponInstance.soulLevel if operation == Operation.GET: - operationLabel.text = "获得" + operationLabel.text = "获得武器" avatarRect.visible = true nameLabel.visible = true soulShow.visible = false else: - operationLabel.text = "提炼" + operationLabel.text = "提炼灵魂" avatarRect.visible = false nameLabel.visible = false soulShow.visible = true diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index e04b146..d8330b7 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -51,6 +51,18 @@ func apply(entity: EntityBase): if !applier or applier.call(entity, value): entity.fields[field] += value entity.fields[field] = clamp(entity.fields[field], 0, FieldStore.entityMaxValueMap.get(field, INF)) + for i in weapons: + var instance = i.instantiate() as Weapon + if UIState.player.weaponBag.has(instance.displayName): + UIState.player.getItem({ + ItemStore.ItemType.SOUL: instance.soulLevel + }) + else: + instance.hide() + entity.weapons.append(instance) + entity.weaponBag.append(instance.displayName) + entity.weaponStore.add_child(instance) + entity.rebuildWeaponIcons() hide() selected.emit(allHave) return allHave