mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(UI): 更新字体资源并优化物品显示逻辑
替换原有字体文件为OTF格式,添加粗体字体支持 在物品显示组件中添加字体颜色变化功能,根据资源是否足够显示不同颜色 优化Feed类的资源消耗计算逻辑,增加countOf方法提高可读性
This commit is contained in:
@@ -29,20 +29,18 @@ func _ready():
|
||||
rebuildInfo()
|
||||
|
||||
func allHad(entity: EntityBase) -> bool:
|
||||
var allHave = true
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i] * multipiler()
|
||||
var count = countOf(i)
|
||||
if entity.inventory[item] < count:
|
||||
allHave = false
|
||||
break
|
||||
return allHave
|
||||
return false
|
||||
return true
|
||||
func apply(entity: EntityBase):
|
||||
var allHave = allHad(entity)
|
||||
if allHave:
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i] * multipiler()
|
||||
var count = countOf(i)
|
||||
entity.inventory[item] -= count
|
||||
for i in range(min(fields.size(), fieldValues.size())):
|
||||
var field = fields[i]
|
||||
@@ -66,6 +64,8 @@ func apply(entity: EntityBase):
|
||||
hide()
|
||||
selected.emit(allHave)
|
||||
return allHave
|
||||
func countOf(index: int) -> int:
|
||||
return ceil(costCounts[index] * multipiler())
|
||||
func multipiler() -> float:
|
||||
if is_instance_valid(UIState.player):
|
||||
return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION)
|
||||
@@ -106,6 +106,7 @@ func rebuildInfo():
|
||||
var cost = costs[i]
|
||||
var count = costCounts[i]
|
||||
var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate()
|
||||
costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= countOf(i)
|
||||
costShow.type = cost
|
||||
costShow.count = int(count * multipiler())
|
||||
costsBox.add_child(costShow)
|
||||
|
||||
Reference in New Issue
Block a user