1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat(Feed): 添加免费购买功能

在Feed结构中新增freeToBuy属性,当设置为true时允许免费购买物品。同时修改SelectIntialFeed面板,在初始化时将feed卡片设置为免费购买。移除UIState中不必要的调试打印语句。
This commit is contained in:
2026-01-30 11:50:16 +08:00
parent 0e4d6e6fe3
commit 5a4ab83188
3 changed files with 13 additions and 10 deletions
+12 -8
View File
@@ -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)