--> Services local ReplicatedStorage = game:GetService("ReplicatedStorage") --> Dependencies local UIWindow = require(ReplicatedStorage.Base.UIWindow) local UIEnums = require(ReplicatedStorage.Base.UIEnums) --> Json local JsonLevel = require(ReplicatedStorage.Json.Level) local Utils = require(ReplicatedStorage.Tools.Utils) local LocalPlayer = game:GetService("Players").LocalPlayer -------------------------------------------------------------------------------- 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, ["_btnMainCha"] = 0, ["_btnMainAttributeUpgrade"] = 0, ["_tmpNowLevel"] = 0, ["_imgBoss"] = 0, } self.UIRootName = "ui_w_main" self.UIParentName = UIEnums.UIParent.UIRoot return self end 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 function MainWindow:OnOpenWindow() UIWindow.OnOpenWindow(self) local createCon = self.Variables["_btnMainCreate"].Activated:Connect(function() self.UIManager:OpenWindow("CreateWindow") end) local chaCon = self.Variables["_btnMainCha"].Activated:Connect(function() self.UIManager:OpenWindow("ChaWindow") end) local attributeUpgradeCon = self.Variables["_btnMainAttributeUpgrade"].Activated:Connect(function() self.UIManager:OpenWindow("AttributeLvupWindow") end) table.insert(self.Connections, createCon) table.insert(self.Connections, chaCon) table.insert(self.Connections, attributeUpgradeCon) local playerDataFolder = Utils:WaitPlayerDataFolder(LocalPlayer) local StatsFolder = playerDataFolder:WaitForChild("PlayerInfo"):WaitForChild("Stats") local levelCon = StatsFolder.level.Changed:Connect(function(newValue) self:SetShowLevel(newValue) end) -- 初始值设置 self:SetShowLevel(StatsFolder.level.Value) table.insert(self.Connections, levelCon) end return MainWindow