2025-07-19 03:03:02 +08:00
|
|
|
|
--> Services
|
|
|
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
|
|
|
|
|
|
|
|
--> Dependencies
|
|
|
|
|
local UIWindow = require(ReplicatedStorage.Base.UIWindow)
|
|
|
|
|
local UIEnums = require(ReplicatedStorage.Base.UIEnums)
|
|
|
|
|
|
2025-07-30 00:37:09 +08:00
|
|
|
|
--> Json
|
|
|
|
|
local JsonLevel = require(ReplicatedStorage.Json.Level)
|
|
|
|
|
|
|
|
|
|
local Utils = require(ReplicatedStorage.Tools.Utils)
|
|
|
|
|
|
|
|
|
|
local LocalPlayer = game:GetService("Players").LocalPlayer
|
|
|
|
|
|
2025-07-19 03:03:02 +08:00
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
local MainWindow = {}
|
|
|
|
|
MainWindow.__index = MainWindow
|
|
|
|
|
setmetatable(MainWindow, {__index = UIWindow})
|
|
|
|
|
|
|
|
|
|
function MainWindow:Init(UIManager: table, Data: table?)
|
|
|
|
|
local self = UIWindow:Init(UIManager, Data)
|
|
|
|
|
setmetatable(self, MainWindow)
|
|
|
|
|
self.Variables = {
|
|
|
|
|
["_btnMainCreate"] = 0,
|
2025-07-22 01:56:56 +08:00
|
|
|
|
["_btnMainCha"] = 0,
|
2025-07-23 01:04:27 +08:00
|
|
|
|
["_btnMainAttributeUpgrade"] = 0,
|
2025-07-30 00:37:09 +08:00
|
|
|
|
|
|
|
|
|
["_tmpNowLevel"] = 0,
|
|
|
|
|
["_imgBoss"] = 0,
|
2025-07-19 03:03:02 +08:00
|
|
|
|
}
|
|
|
|
|
self.UIRootName = "ui_w_main"
|
|
|
|
|
self.UIParentName = UIEnums.UIParent.UIRoot
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-30 00:37:09 +08:00
|
|
|
|
function MainWindow:SetShowLevel(level: number)
|
|
|
|
|
self.Variables["_tmpNowLevel"].Text = string.format("第%d关", level)
|
|
|
|
|
local levelData = Utils:GetIdDataFromJson(JsonLevel, level)
|
|
|
|
|
if levelData.type == 2 then
|
|
|
|
|
self.Variables["_imgBoss"].Visible = true
|
|
|
|
|
else
|
|
|
|
|
self.Variables["_imgBoss"].Visible = false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-19 03:03:02 +08:00
|
|
|
|
function MainWindow:OnOpenWindow()
|
|
|
|
|
UIWindow.OnOpenWindow(self)
|
|
|
|
|
|
|
|
|
|
local createCon = self.Variables["_btnMainCreate"].Activated:Connect(function()
|
|
|
|
|
self.UIManager:OpenWindow("CreateWindow")
|
|
|
|
|
end)
|
2025-07-22 01:56:56 +08:00
|
|
|
|
local chaCon = self.Variables["_btnMainCha"].Activated:Connect(function()
|
|
|
|
|
self.UIManager:OpenWindow("ChaWindow")
|
|
|
|
|
end)
|
2025-07-23 01:04:27 +08:00
|
|
|
|
local attributeUpgradeCon = self.Variables["_btnMainAttributeUpgrade"].Activated:Connect(function()
|
|
|
|
|
self.UIManager:OpenWindow("AttributeLvupWindow")
|
|
|
|
|
end)
|
2025-07-22 01:56:56 +08:00
|
|
|
|
|
2025-07-19 03:03:02 +08:00
|
|
|
|
table.insert(self.Connections, createCon)
|
2025-07-22 01:56:56 +08:00
|
|
|
|
table.insert(self.Connections, chaCon)
|
2025-07-23 01:04:27 +08:00
|
|
|
|
table.insert(self.Connections, attributeUpgradeCon)
|
2025-07-30 00:37:09 +08:00
|
|
|
|
|
2025-07-30 19:46:01 +08:00
|
|
|
|
-- TODO: 暂时用主关卡数显示,我记得之前这里主要是记录的,Challenge中才是正在挑战的内容
|
|
|
|
|
-- TODO: 之后LevelProxy也应该挪到ReplicatedStorage下,之前可能是因为觉得Challenge是临时的内容所以放在workspace下,但是逻辑做的不统一
|
|
|
|
|
local playerDataFolder = game.Workspace:WaitForChild("Level"):WaitForChild(LocalPlayer.UserId)
|
|
|
|
|
local StatsFolder = playerDataFolder:WaitForChild("Progress")
|
|
|
|
|
local levelCon = StatsFolder.Main.Changed:Connect(function(newValue)
|
2025-07-30 00:37:09 +08:00
|
|
|
|
self:SetShowLevel(newValue)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
-- 初始值设置
|
2025-07-30 19:46:01 +08:00
|
|
|
|
self:SetShowLevel(StatsFolder.Main.Value)
|
2025-07-30 00:37:09 +08:00
|
|
|
|
table.insert(self.Connections, levelCon)
|
2025-07-19 03:03:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return MainWindow
|