From 5a4ab83188ff9814063a5343a564d90a3c7066e9 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: Fri, 30 Jan 2026 11:50:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(Feed):=20=E6=B7=BB=E5=8A=A0=E5=85=8D?= =?UTF-8?q?=E8=B4=B9=E8=B4=AD=E4=B9=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在Feed结构中新增freeToBuy属性,当设置为true时允许免费购买物品。同时修改SelectIntialFeed面板,在初始化时将feed卡片设置为免费购买。移除UIState中不必要的调试打印语句。 --- scripts/Contents/Panels/SelectIntialFeed.gd | 1 + scripts/Statemachine/UIState.gd | 2 -- scripts/Structs/Feed.gd | 20 ++++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/Contents/Panels/SelectIntialFeed.gd b/scripts/Contents/Panels/SelectIntialFeed.gd index 4bd7fa9..fbf4bb9 100644 --- a/scripts/Contents/Panels/SelectIntialFeed.gd +++ b/scripts/Contents/Panels/SelectIntialFeed.gd @@ -8,4 +8,5 @@ func beforeOpen(_args: Array = []): feed.queue_free() for feed in ComponentManager.feeds: var card = feed.instantiate() as Feed + card.freeToBuy = true initialFeedSelection.add_child(card) diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index 4e57884..8b818ef 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -77,8 +77,6 @@ static func setPanel(targetName: String = "", args: Array = []): panel.showPanel(args) else: panel.hidePanel() - if !currentPanel: - print("没有叫%s的面板" % targetName) static func closeCurrentPanel(): setPanel() static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO): diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index 6f4b2c8..86d968d 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -20,6 +20,7 @@ signal selected(applied: bool) @onready var weaponsBox: VBoxContainer = $"%weapons" @onready var costsBox: GridContainer = $"%costs" @onready var selectButton: Button = $"%selectBtn" +var freeToBuy: bool = false func _ready(): selectButton.pressed.connect( @@ -29,6 +30,8 @@ func _ready(): rebuildInfo() func allHad(entity: EntityBase) -> bool: + if freeToBuy: + return true for i in range(min(costs.size(), costCounts.size())): var item = costs[i] var count = countOf(i) @@ -103,11 +106,12 @@ func rebuildInfo(): weaponsBox.add_child(weaponShow) for i in costsBox.get_children(): i.queue_free() - for i in range(min(costs.size(), costCounts.size())): - var cost = costs[i] - var count = countOf(i) - var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate() - costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= count - costShow.type = cost - costShow.count = count - costsBox.add_child(costShow) + if !freeToBuy: + for i in range(min(costs.size(), costCounts.size())): + var cost = costs[i] + var count = countOf(i) + var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate() + costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= count + costShow.type = cost + costShow.count = count + costsBox.add_child(costShow)