This commit is contained in:
Ggafrik 2025-08-28 23:38:53 +08:00
parent 1e4137a587
commit fdf4e8f53d
6 changed files with 59 additions and 4 deletions

Binary file not shown.

View File

@ -46,6 +46,8 @@
{"id":1011,"text":"祝福:出现{0}属性的概率+{1}"}, {"id":1011,"text":"祝福:出现{0}属性的概率+{1}"},
{"id":1012,"text":"祝福:出现{0}技能的概率+{1}"}, {"id":1012,"text":"祝福:出现{0}技能的概率+{1}"},
{"id":1013,"text":"祝福:出现{0}晶石的概率+{1}"}, {"id":1013,"text":"祝福:出现{0}晶石的概率+{1}"},
{"id":1020,"text":"战力:{0}"},
{"id":1021,"text":"所需战力:{0}"},
{"id":1200,"text":"该装备无符文槽位"}, {"id":1200,"text":"该装备无符文槽位"},
{"id":20000,"text":"普攻"}, {"id":20000,"text":"普攻"},
{"id":20001,"text":"剑气"}, {"id":20001,"text":"剑气"},

View File

@ -46,6 +46,8 @@
{"id":1011,"text":"祝福:出现{0}属性的概率+{1}"}, {"id":1011,"text":"祝福:出现{0}属性的概率+{1}"},
{"id":1012,"text":"祝福:出现{0}技能的概率+{1}"}, {"id":1012,"text":"祝福:出现{0}技能的概率+{1}"},
{"id":1013,"text":"祝福:出现{0}晶石的概率+{1}"}, {"id":1013,"text":"祝福:出现{0}晶石的概率+{1}"},
{"id":1020,"text":"战力:{0}"},
{"id":1021,"text":"所需战力:{0}"},
{"id":1200,"text":"该装备无符文槽位"}, {"id":1200,"text":"该装备无符文槽位"},
{"id":20000,"text":"普攻"}, {"id":20000,"text":"普攻"},
{"id":20001,"text":"剑气"}, {"id":20001,"text":"剑气"},

View File

@ -0,0 +1,24 @@
local BattleUtils = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local JsonAttributes = require(ReplicatedStorage.Json.Attributes)
local Utils = require(ReplicatedStorage.Tools.Utils)
function BattleUtils:GetPlayerBattleValue(player)
local character = player.Character
if not character then warn("character not found") return 0 end
local attributes = character:FindFirstChild("Attributes")
if not attributes then warn("attributes not found") return 0 end
local battleValue = 0
for attributeKey, attributeValue in attributes:GetAttributes() do
local attributeData = Utils:GetSpecialKeyDataFromJson(JsonAttributes, "effectAttribute", attributeKey)
if not attributeData then continue end
battleValue += math.floor(attributeValue / attributeData.battleValue[1] * attributeData.battleValue[2])
end
return battleValue
end
return BattleUtils

View File

@ -7,6 +7,7 @@ local Utils = require(ReplicatedStorage.Tools.Utils)
local Localization = require(ReplicatedStorage.Tools.Localization) local Localization = require(ReplicatedStorage.Tools.Localization)
local JsonAttributesUpgrade = require(ReplicatedStorage.Json.AttributesUpgrade) local JsonAttributesUpgrade = require(ReplicatedStorage.Json.AttributesUpgrade)
local JsonAttributes = require(ReplicatedStorage.Json.Attributes) local JsonAttributes = require(ReplicatedStorage.Json.Attributes)
local BattleUtils = require(ReplicatedStorage.Tools.BattleUtils)
local RE_UpgradeAttributes = ReplicatedStorage.Events.RE_UpgradeAttributes local RE_UpgradeAttributes = ReplicatedStorage.Events.RE_UpgradeAttributes
@ -18,6 +19,7 @@ function AttributeLvupShow:Init(data: table)
self.Variables = { self.Variables = {
["_imgIcon"] = 0, ["_imgIcon"] = 0,
["_tmpAttributeName"] = 0, ["_tmpAttributeName"] = 0,
["_tmpBattleValueRequire"] = 0,
["_tmpValue"] = 0, ["_tmpValue"] = 0,
["_tmpLv"] = 0, ["_tmpLv"] = 0,
["_btnUpgrade"] = 0, ["_btnUpgrade"] = 0,
@ -61,12 +63,16 @@ function AttributeLvupShow:Refresh()
self.Variables._tmpLv.Text = "Lv." .. nowLv self.Variables._tmpLv.Text = "Lv." .. nowLv
-- TODO:战斗力计算 -- TODO:战斗力计算
local nowBattleValue = 0 local nowBattleValue = BattleUtils:GetPlayerBattleValue(LocalPlayer)
local limitBattleValue local limitBattleValue
if nowLv == 0 then if nowLv == 0 then
limitBattleValue = attributesUpgradeData.battleValueLimit[1] limitBattleValue = attributesUpgradeData.battleValueLimit[1]
else else
if self.Data.maxLv then
limitBattleValue = attributesUpgradeData.battleValueLimit[1] + math.min(nowLv, self.Data.maxLv - 1) * attributesUpgradeData.battleValueLimit[2] limitBattleValue = attributesUpgradeData.battleValueLimit[1] + math.min(nowLv, self.Data.maxLv - 1) * attributesUpgradeData.battleValueLimit[2]
else
limitBattleValue = attributesUpgradeData.battleValueLimit[1] + (nowLv - 1) * attributesUpgradeData.battleValueLimit[2]
end
end end
-- 花费按钮显示 -- 花费按钮显示
@ -94,7 +100,14 @@ function AttributeLvupShow:Refresh()
end end
-- 战力限制不让点 -- 战力限制不让点
if nowBattleValue < limitBattleValue then self.Variables._btnUpgrade.Interactable = false end if nowBattleValue < limitBattleValue then
self.Variables._btnUpgrade.Interactable = false
self.Variables._tmpBattleValueRequire.TextColor3 = Color3.fromRGB(255, 55, 55)
else
self.Variables._tmpBattleValueRequire.TextColor3 = Color3.fromRGB(0, 0, 0)
end
self.Variables._tmpBattleValueRequire.Text = Localization:FormatString(Localization:GetLanguageData(1021), limitBattleValue)
end end
function AttributeLvupShow:OnInitFinish() function AttributeLvupShow:OnInitFinish()
@ -109,6 +122,8 @@ function AttributeLvupShow:OnInitFinish()
-- TODO: 检查货币是否充足 -- TODO: 检查货币是否充足
RE_UpgradeAttributes:FireServer(self.Data.id) RE_UpgradeAttributes:FireServer(self.Data.id)
end end
self.TopUI:UpdateBattleValue()
self:Refresh()
end) end)
table.insert(self.Connections, con) table.insert(self.Connections, con)

View File

@ -1,10 +1,13 @@
--> Services --> Services
local ReplicatedStorage = game:GetService("ReplicatedStorage") local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--> Dependencies --> Dependencies
local UIWindow = require(ReplicatedStorage.Base.UIWindow) local UIWindow = require(ReplicatedStorage.Base.UIWindow)
local UIEnums = require(ReplicatedStorage.Base.UIEnums) local UIEnums = require(ReplicatedStorage.Base.UIEnums)
local Utils = require(ReplicatedStorage.Tools.Utils) local Utils = require(ReplicatedStorage.Tools.Utils)
local BattleUtils = require(ReplicatedStorage.Tools.BattleUtils)
local Localization = require(ReplicatedStorage.Tools.Localization)
--> Components --> Components
local AttributeLvupShow = require(script.AttributeLvupShow) local AttributeLvupShow = require(script.AttributeLvupShow)
@ -12,6 +15,9 @@ local AttributeLvupShow = require(script.AttributeLvupShow)
--> Json --> Json
local JsonAttributesUpgrade = require(ReplicatedStorage.Json.AttributesUpgrade) local JsonAttributesUpgrade = require(ReplicatedStorage.Json.AttributesUpgrade)
--> LocalPlayer
local LocalPlayer = Players.LocalPlayer
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local AttributeLvupWindow = {} local AttributeLvupWindow = {}
@ -28,6 +34,7 @@ function AttributeLvupWindow:Init(UIManager: table, Data: table?)
["__listBaseAttributes"] = 0, ["__listBaseAttributes"] = 0,
["_tmpSpecialTitle"] = 0, ["_tmpSpecialTitle"] = 0,
["_tmpBaseTitle"] = 0, ["_tmpBaseTitle"] = 0,
["_tmpBattleValue"] = 0,
["__moneyCoin"] = 0, ["__moneyCoin"] = 0,
@ -40,6 +47,10 @@ function AttributeLvupWindow:Init(UIManager: table, Data: table?)
return self return self
end end
function AttributeLvupWindow:UpdateBattleValue()
self.Variables["_tmpBattleValue"].Text = Localization:FormatString(Localization:GetLanguageData(1020), BattleUtils:GetPlayerBattleValue(LocalPlayer))
end
function AttributeLvupWindow:OnOpenWindow() function AttributeLvupWindow:OnOpenWindow()
UIWindow.OnOpenWindow(self) UIWindow.OnOpenWindow(self)
@ -57,6 +68,7 @@ function AttributeLvupWindow:OnOpenWindow()
self:SetData(data) self:SetData(data)
self:UpdateBattleValue()
self.Variables["__listSpecialAttributes"]:AddComponent(AttributeLvupShow) self.Variables["__listSpecialAttributes"]:AddComponent(AttributeLvupShow)
self.Variables["__listBaseAttributes"]:AddComponent(AttributeLvupShow) self.Variables["__listBaseAttributes"]:AddComponent(AttributeLvupShow)