This commit is contained in:
gechangfu 2025-09-04 16:06:00 +08:00
parent 592f4aee24
commit ce9e4a3909
9 changed files with 116 additions and 12 deletions

Binary file not shown.

View File

@ -142,6 +142,13 @@ function UIList:SetSingleInstance(index: number, data: table)
uiInstance.Visible = true
end
-- 所有子节点执行自身函数
function UIList:ExecuteAllInstanceFunction(functionName: string, ...)
for _, ui in pairs(self.Instances) do
if ui[functionName] then ui[functionName](ui, ...) end
end
end
function UIList:GetMinLayoutOrderInstance()
local minOrder = math.huge
local minInstance = nil

View File

@ -476,7 +476,7 @@ function EquipmentProxy:AutoRecycleEquipment(Player: Player)
end
for _, EquipmentData in EquipmentData do
if EquipmentData.quality < highestQuality and EquipmentData.maxRuneNumber == 0 then
if EquipmentData.quality < highestQuality and EquipmentData.maxRuneNumber == 0 and tonumber(EquipmentData.wearing) == 0 then
self:RecycleEquipment(Player, EquipmentData.id)
end
end

View File

@ -2,5 +2,6 @@ local StarterGui = game:GetService("StarterGui")
-- Disable default health bar and backpack
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
return {}

View File

@ -35,6 +35,13 @@ local InstanceMoney = MoneyFolder:FindFirstChild(CheckMoneyId)
local ItemData = Utils:GetIdDataFromJson(JsonItemProp, tonumber(CheckMoneyId))
imgIcon.Image = Localization:GetImageData(ItemData.iconId)
local function SetMoneyChange()
tmpValue.Text = InstanceMoney.Value
connection = InstanceMoney.Changed:Connect(function(newValue)
tmpValue.Text = newValue
end)
end
if not InstanceMoney then
tmpValue.Text = "0"
connectionFolder = MoneyFolder.ChildAdded:Connect(function(child)
@ -42,13 +49,11 @@ if not InstanceMoney then
tmpValue.Text = child.Value
InstanceMoney = child
connectionFolder:Disconnect()
SetMoneyChange()
end
end)
else
tmpValue.Text = InstanceMoney.Value
connection = InstanceMoney.Changed:Connect(function(newValue)
tmpValue.Text = newValue
end)
SetMoneyChange()
end
script.Destroying:Once(function()

View File

@ -82,22 +82,25 @@ function AttributeLvupShow:Refresh()
end
end
local costValue = 0
-- 花费按钮显示
if self.Data.maxLv then
self.Variables._btnUpgrade.Text = nowLv >= self.Data.maxLv and "满级" or self.Data.cost[2] + self.Data.cost[3] * (self.Data.maxLv - 1)
costValue = self.Data.cost[2] + self.Data.cost[3] * (self.Data.maxLv - 1)
self.Variables._btnUpgrade.Text = nowLv >= self.Data.maxLv and "满级" or costValue
-- 满级不让点击
if nowLv >= self.Data.maxLv then self.Variables._btnUpgrade.Interactable = false end
-- 属性值显示
local caculateValue = self.Data.lvAdd[1] + self.Data.lvAdd[2] * (self.Data.maxLv - 1)
local attributeValue = self.Data.lvAdd[1] + self.Data.lvAdd[2] * (self.Data.maxLv - 1)
if attributeData.type == 1 then
self.Variables._tmpValue.Text = "+"..caculateValue
self.Variables._tmpValue.Text = "+"..attributeValue
else
self.Variables._tmpValue.Text = "+"..string.format("%.2f%%", caculateValue / 100)
self.Variables._tmpValue.Text = "+"..string.format("%.2f%%", attributeValue / 100)
end
else
self.Variables._btnUpgrade.Text = self.Data.cost[2] + self.Data.cost[3] * nowLv
costValue = self.Data.cost[2] + self.Data.cost[3] * nowLv
self.Variables._btnUpgrade.Text = costValue
-- 属性值显示(下一级)
if self.Data.id == 1 or self.Data.id == 2 then
self.Variables._tmpValue.Text = "+"..math.floor(self.Data.lvAdd[1] * ((self.Data.lvAdd[2] / 10000) ^ nowLv))
@ -115,6 +118,25 @@ function AttributeLvupShow:Refresh()
end
self.Variables._tmpBattleValueRequire.Text = Localization:FormatString(Localization:GetLanguageData(1021), limitBattleValue)
self:CheckShowRed()
end
function AttributeLvupShow:CheckShowRed()
local nowLv = self:GetNowLv()
if self.Data.maxLv then
costValue = self.Data.cost[2] + self.Data.cost[3] * (self.Data.maxLv - 1)
else
costValue = self.Data.cost[2] + self.Data.cost[3] * nowLv
end
local ItemsFolder = Utils:GetPlayerDataFolder(LocalPlayer):FindFirstChild("PlayerInfo"):FindFirstChild("Items")
local nowMoney = ItemsFolder:FindFirstChild(1) and ItemsFolder:FindFirstChild(1).Value or 0
if nowMoney < costValue then
self.Variables._tmpRed.Visible = false
else
self.Variables._tmpRed.Visible = true
end
end
function AttributeLvupShow:OnInitFinish()
@ -130,6 +152,7 @@ function AttributeLvupShow:OnInitFinish()
-- TODO: 检查货币是否充足
RE_UpgradeAttributes:FireServer(self.Data.id)
end
self.TopUI:UpdateRed()
self.TopUI:UpdateBattleValue()
self:Refresh()
end)

View File

@ -51,6 +51,11 @@ function AttributeLvupWindow:UpdateBattleValue()
self.Variables["_tmpBattleValue"].Text = Localization:FormatString(Localization:GetLanguageData(1020), BattleUtils:GetPlayerBattleValue(LocalPlayer))
end
function AttributeLvupWindow:UpdateRed()
self.Variables["__listSpecialAttributes"]:ExecuteAllInstanceFunction("CheckShowRed")
self.Variables["__listBaseAttributes"]:ExecuteAllInstanceFunction("CheckShowRed")
end
function AttributeLvupWindow:OnOpenWindow()
UIWindow.OnOpenWindow(self)
@ -85,6 +90,34 @@ function AttributeLvupWindow:OnOpenWindow()
end)
-- table.insert(self.Connections, bgCloseCon)
table.insert(self.Connections, closeCon)
-- 金币变化监听
local MoneyFolder = Utils:GetPlayerDataFolder(LocalPlayer):FindFirstChild("PlayerInfo"):FindFirstChild("Items")
local InstanceMoney = MoneyFolder:FindFirstChild(1)
local function SetMoneyChange()
local con = InstanceMoney.Changed:Connect(function(newValue)
self:UpdateRed()
end)
table.insert(self.Connections, con)
end
if InstanceMoney then
SetMoneyChange()
else
local addCon
addCon = MoneyFolder.ChildAdded:Connect(function(child)
if child.Name == "1" then
InstanceMoney = child
addCon:Disconnect()
addCon = nil
SetMoneyChange()
self:UpdateRed()
end
end)
table.insert(self.Connections, addCon)
end
end

View File

@ -8,9 +8,12 @@ local Signal = require(ReplicatedStorage.Tools.Signal)
--> Json
local JsonLevel = require(ReplicatedStorage.Json.Level)
local JsonEnemy = require(ReplicatedStorage.Json.Enemy)
local JsonAttributes = require(ReplicatedStorage.Json.Attributes)
local JsonForge = require(ReplicatedStorage.Json.Forge)
local Utils = require(ReplicatedStorage.Tools.Utils)
local BattleUtils = require(ReplicatedStorage.Tools.BattleUtils)
--> Events
local RE_ChallengeBoss = ReplicatedStorage.Events.RE_ChallengeBoss
@ -35,6 +38,8 @@ function LevelStageWindow:Init(UIManager: table, Data: table?)
["_tmpNowLevel"] = 0,
["_imgBoss"] = 0,
["_btnChallengeBoss"] = 0,
["_tmpLevelBattleValue"] = 0,
}
self.UIRootName = "ui_w_level_stage"
self.UIParentName = UIEnums.UIParent.UIRoot
@ -51,6 +56,33 @@ function LevelStageWindow:SetShowLevel(level: number)
else
self.Variables["_imgBoss"].Visible = false
end
local attackTransData = Utils:GetSpecialKeyDataFromJson(JsonAttributes, "effectAttribute", "attack").battleValue
local hpTransData = Utils:GetSpecialKeyDataFromJson(JsonAttributes, "effectAttribute", "hp").battleValue
-- 战斗力显示
local playerBattleValue = BattleUtils:GetPlayerBattleValue(LocalPlayer)
-- 计算关卡怪物战力
local JsonLevelData = Utils:GetIdDataFromJson(JsonLevel, level)
local enemyBattleValue = 0
local maxAttackBattleValue = 0
for _, enemyWaveInfo in ipairs(JsonLevelData.wave) do
local JsonEnemyData = Utils:GetIdDataFromJson(JsonEnemy, enemyWaveInfo[2])
local hpBattleValue = math.floor(JsonEnemyData.hp *( JsonLevelData.hpBonus / 100) / hpTransData[1] * hpTransData[2]) * enemyWaveInfo[3]
local attackBattleValue = math.floor(JsonEnemyData.attack *( JsonLevelData.atkBonus / 100) / attackTransData[1] * attackTransData[2])
enemyBattleValue += hpBattleValue
if attackBattleValue > maxAttackBattleValue then
enemyBattleValue += (attackBattleValue - maxAttackBattleValue)
maxAttackBattleValue = attackBattleValue
end
end
if playerBattleValue < enemyBattleValue then
self.Variables["_tmpLevelBattleValue"].TextColor3 = Color3.fromRGB(255, 55, 55)
else
self.Variables["_tmpLevelBattleValue"].TextColor3 = Color3.fromRGB(255, 255, 255)
end
self.Variables["_tmpLevelBattleValue"].Text = enemyBattleValue
end
-- 设置boss挑战按钮显示

View File

@ -172,9 +172,10 @@ function MainWindow:SetShowAttributeUpgradeRed()
self:CheckShowAttributeUpgradeRed(newValue)
end)
table.insert(self.Connections, con)
-- 初始化显示设置
self:CheckShowAttributeUpgradeRed(InstanceMoney.Value)
end
-- 初始化显示设置
self:CheckShowAttributeUpgradeRed(InstanceMoney and InstanceMoney.Value or 0)
end
function MainWindow:OnOpenWindow()
@ -254,6 +255,8 @@ function MainWindow:OnOpenWindow()
-- 初始化设置
self:SetShowForgeBar(forgeInstance.Value, 0)
end
self:SetShowAttributeUpgradeRed()
end
return MainWindow