diff --git a/excel/language.xlsx b/excel/language.xlsx index c0b5a26..637f9eb 100644 Binary files a/excel/language.xlsx and b/excel/language.xlsx differ diff --git a/src/ReplicatedStorage/Json/Language_En_US.json b/src/ReplicatedStorage/Json/Language_En_US.json index 1266631..2d71da9 100644 --- a/src/ReplicatedStorage/Json/Language_En_US.json +++ b/src/ReplicatedStorage/Json/Language_En_US.json @@ -46,6 +46,8 @@ {"id":1011,"text":"祝福:出现{0}属性的概率+{1}"}, {"id":1012,"text":"祝福:出现{0}技能的概率+{1}"}, {"id":1013,"text":"祝福:出现{0}晶石的概率+{1}"}, +{"id":1020,"text":"战力:{0}"}, +{"id":1021,"text":"所需战力:{0}"}, {"id":1200,"text":"该装备无符文槽位"}, {"id":20000,"text":"普攻"}, {"id":20001,"text":"剑气"}, diff --git a/src/ReplicatedStorage/Json/Language_Zh_CN.json b/src/ReplicatedStorage/Json/Language_Zh_CN.json index 1266631..2d71da9 100644 --- a/src/ReplicatedStorage/Json/Language_Zh_CN.json +++ b/src/ReplicatedStorage/Json/Language_Zh_CN.json @@ -46,6 +46,8 @@ {"id":1011,"text":"祝福:出现{0}属性的概率+{1}"}, {"id":1012,"text":"祝福:出现{0}技能的概率+{1}"}, {"id":1013,"text":"祝福:出现{0}晶石的概率+{1}"}, +{"id":1020,"text":"战力:{0}"}, +{"id":1021,"text":"所需战力:{0}"}, {"id":1200,"text":"该装备无符文槽位"}, {"id":20000,"text":"普攻"}, {"id":20001,"text":"剑气"}, diff --git a/src/ReplicatedStorage/Tools/BattleUtils.luau b/src/ReplicatedStorage/Tools/BattleUtils.luau new file mode 100644 index 0000000..7271af4 --- /dev/null +++ b/src/ReplicatedStorage/Tools/BattleUtils.luau @@ -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 \ No newline at end of file diff --git a/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/AttributeLvupShow.luau b/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/AttributeLvupShow.luau index 273b9b4..65ccfee 100644 --- a/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/AttributeLvupShow.luau +++ b/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/AttributeLvupShow.luau @@ -7,6 +7,7 @@ local Utils = require(ReplicatedStorage.Tools.Utils) local Localization = require(ReplicatedStorage.Tools.Localization) local JsonAttributesUpgrade = require(ReplicatedStorage.Json.AttributesUpgrade) local JsonAttributes = require(ReplicatedStorage.Json.Attributes) +local BattleUtils = require(ReplicatedStorage.Tools.BattleUtils) local RE_UpgradeAttributes = ReplicatedStorage.Events.RE_UpgradeAttributes @@ -18,6 +19,7 @@ function AttributeLvupShow:Init(data: table) self.Variables = { ["_imgIcon"] = 0, ["_tmpAttributeName"] = 0, + ["_tmpBattleValueRequire"] = 0, ["_tmpValue"] = 0, ["_tmpLv"] = 0, ["_btnUpgrade"] = 0, @@ -61,12 +63,16 @@ function AttributeLvupShow:Refresh() self.Variables._tmpLv.Text = "Lv." .. nowLv -- TODO:战斗力计算 - local nowBattleValue = 0 + local nowBattleValue = BattleUtils:GetPlayerBattleValue(LocalPlayer) local limitBattleValue if nowLv == 0 then limitBattleValue = attributesUpgradeData.battleValueLimit[1] else - limitBattleValue = attributesUpgradeData.battleValueLimit[1] + math.min(nowLv, self.Data.maxLv - 1) * attributesUpgradeData.battleValueLimit[2] + if self.Data.maxLv then + 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 -- 花费按钮显示 @@ -94,7 +100,14 @@ function AttributeLvupShow:Refresh() 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 function AttributeLvupShow:OnInitFinish() @@ -109,6 +122,8 @@ function AttributeLvupShow:OnInitFinish() -- TODO: 检查货币是否充足 RE_UpgradeAttributes:FireServer(self.Data.id) end + self.TopUI:UpdateBattleValue() + self:Refresh() end) table.insert(self.Connections, con) diff --git a/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/init.luau b/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/init.luau index ecf4b69..046fa9c 100644 --- a/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/init.luau +++ b/src/StarterPlayerScripts/UI/Windows/AttributeLvupWindow/init.luau @@ -1,10 +1,13 @@ --> Services local ReplicatedStorage = game:GetService("ReplicatedStorage") +local Players = game:GetService("Players") --> Dependencies local UIWindow = require(ReplicatedStorage.Base.UIWindow) local UIEnums = require(ReplicatedStorage.Base.UIEnums) local Utils = require(ReplicatedStorage.Tools.Utils) +local BattleUtils = require(ReplicatedStorage.Tools.BattleUtils) +local Localization = require(ReplicatedStorage.Tools.Localization) --> Components local AttributeLvupShow = require(script.AttributeLvupShow) @@ -12,6 +15,9 @@ local AttributeLvupShow = require(script.AttributeLvupShow) --> Json local JsonAttributesUpgrade = require(ReplicatedStorage.Json.AttributesUpgrade) +--> LocalPlayer +local LocalPlayer = Players.LocalPlayer + -------------------------------------------------------------------------------- local AttributeLvupWindow = {} @@ -28,6 +34,7 @@ function AttributeLvupWindow:Init(UIManager: table, Data: table?) ["__listBaseAttributes"] = 0, ["_tmpSpecialTitle"] = 0, ["_tmpBaseTitle"] = 0, + ["_tmpBattleValue"] = 0, ["__moneyCoin"] = 0, @@ -40,6 +47,10 @@ function AttributeLvupWindow:Init(UIManager: table, Data: table?) return self end +function AttributeLvupWindow:UpdateBattleValue() + self.Variables["_tmpBattleValue"].Text = Localization:FormatString(Localization:GetLanguageData(1020), BattleUtils:GetPlayerBattleValue(LocalPlayer)) +end + function AttributeLvupWindow:OnOpenWindow() UIWindow.OnOpenWindow(self) @@ -57,7 +68,8 @@ function AttributeLvupWindow:OnOpenWindow() self:SetData(data) - + self:UpdateBattleValue() + self.Variables["__listSpecialAttributes"]:AddComponent(AttributeLvupShow) self.Variables["__listBaseAttributes"]:AddComponent(AttributeLvupShow) self.Variables["__listSpecialAttributes"]:SetData(self.Data.Special)