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