mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(Feed): 添加免费购买功能
在Feed结构中新增freeToBuy属性,当设置为true时允许免费购买物品。同时修改SelectIntialFeed面板,在初始化时将feed卡片设置为免费购买。移除UIState中不必要的调试打印语句。
This commit is contained in:
@@ -8,4 +8,5 @@ func beforeOpen(_args: Array = []):
|
|||||||
feed.queue_free()
|
feed.queue_free()
|
||||||
for feed in ComponentManager.feeds:
|
for feed in ComponentManager.feeds:
|
||||||
var card = feed.instantiate() as Feed
|
var card = feed.instantiate() as Feed
|
||||||
|
card.freeToBuy = true
|
||||||
initialFeedSelection.add_child(card)
|
initialFeedSelection.add_child(card)
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ static func setPanel(targetName: String = "", args: Array = []):
|
|||||||
panel.showPanel(args)
|
panel.showPanel(args)
|
||||||
else:
|
else:
|
||||||
panel.hidePanel()
|
panel.hidePanel()
|
||||||
if !currentPanel:
|
|
||||||
print("没有叫%s的面板" % targetName)
|
|
||||||
static func closeCurrentPanel():
|
static func closeCurrentPanel():
|
||||||
setPanel()
|
setPanel()
|
||||||
static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO):
|
static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO):
|
||||||
|
|||||||
+12
-8
@@ -20,6 +20,7 @@ signal selected(applied: bool)
|
|||||||
@onready var weaponsBox: VBoxContainer = $"%weapons"
|
@onready var weaponsBox: VBoxContainer = $"%weapons"
|
||||||
@onready var costsBox: GridContainer = $"%costs"
|
@onready var costsBox: GridContainer = $"%costs"
|
||||||
@onready var selectButton: Button = $"%selectBtn"
|
@onready var selectButton: Button = $"%selectBtn"
|
||||||
|
var freeToBuy: bool = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
selectButton.pressed.connect(
|
selectButton.pressed.connect(
|
||||||
@@ -29,6 +30,8 @@ func _ready():
|
|||||||
rebuildInfo()
|
rebuildInfo()
|
||||||
|
|
||||||
func allHad(entity: EntityBase) -> bool:
|
func allHad(entity: EntityBase) -> bool:
|
||||||
|
if freeToBuy:
|
||||||
|
return true
|
||||||
for i in range(min(costs.size(), costCounts.size())):
|
for i in range(min(costs.size(), costCounts.size())):
|
||||||
var item = costs[i]
|
var item = costs[i]
|
||||||
var count = countOf(i)
|
var count = countOf(i)
|
||||||
@@ -103,11 +106,12 @@ func rebuildInfo():
|
|||||||
weaponsBox.add_child(weaponShow)
|
weaponsBox.add_child(weaponShow)
|
||||||
for i in costsBox.get_children():
|
for i in costsBox.get_children():
|
||||||
i.queue_free()
|
i.queue_free()
|
||||||
for i in range(min(costs.size(), costCounts.size())):
|
if !freeToBuy:
|
||||||
var cost = costs[i]
|
for i in range(min(costs.size(), costCounts.size())):
|
||||||
var count = countOf(i)
|
var cost = costs[i]
|
||||||
var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate()
|
var count = countOf(i)
|
||||||
costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= count
|
var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate()
|
||||||
costShow.type = cost
|
costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= count
|
||||||
costShow.count = count
|
costShow.type = cost
|
||||||
costsBox.add_child(costShow)
|
costShow.count = count
|
||||||
|
costsBox.add_child(costShow)
|
||||||
|
|||||||
Reference in New Issue
Block a user