59 lines
1.6 KiB
Lua
59 lines
1.6 KiB
Lua
SelfTianGuanOBJ = Up_BaseClassOBJ:new()
|
|
|
|
SelfTianGuanOBJ.__cname = "SelfTianGuanOBJ"
|
|
|
|
-- 配置文件
|
|
SelfTianGuanOBJ.cfg = {}
|
|
|
|
SelfTianGuanOBJ.UIfile = "game/B/SelfTianGuanUI"
|
|
|
|
|
|
function SelfTianGuanOBJ:updata()
|
|
GUI:Text_setString(self.ui.Text_5, string.format("当前关卡:第%d层", self.cfg.level))
|
|
|
|
for i = 1, 2, 1 do
|
|
local up_btn = string.format("Button_%d", i)
|
|
GUI:addOnClickEvent(self.ui[up_btn], function()
|
|
ssrMessage:SubLink("TianGuanOBJ_selfgotolevel", i)
|
|
end)
|
|
end
|
|
end
|
|
|
|
|
|
function SelfTianGuanOBJ:CloseWin()
|
|
if GUI:Win_IsNotNull(self._parent) then
|
|
GUI:Win_Close(self._parent)
|
|
end
|
|
end
|
|
|
|
---* 注册事件
|
|
function SelfTianGuanOBJ:EventBind()
|
|
local function SelfTianGuanOBJ_Var_Change(data)
|
|
if GUI:Win_IsNotNull(self._parent) then
|
|
if data.key == "GLOBAL(INT_TIANGUANJIANGCHI)" then
|
|
GUI:Text_setString(self.ui.JiangChi_Text, "x" .. data.value)
|
|
end
|
|
end
|
|
end
|
|
SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname, SelfTianGuanOBJ_Var_Change, self._parent)
|
|
|
|
|
|
--关闭窗口
|
|
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName)
|
|
self:OnClose(widgetName)
|
|
end)
|
|
end
|
|
|
|
--关闭窗口
|
|
function SelfTianGuanOBJ:OnClose(widgetName)
|
|
if widgetName == self.__cname then
|
|
self:UnRegisterEvent()
|
|
end
|
|
end
|
|
|
|
function SelfTianGuanOBJ:UnRegisterEvent()
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname)
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname)
|
|
end
|
|
|
|
return SelfTianGuanOBJ
|