---@class KLActivityPreviewItem:UIKmlLuaPanelBase ---@field view KLActivityPreviewItemView ---@field data {leftTime:number,id:number,open:boolean,cfg:cfg_activity_rule_column,isPreview:boolean} local KLActivityPreviewItem = class(UIKmlLuaPanelBase) local this = KLActivityPreviewItem ---创建时调用一次 function this:Init() end function this:InitData(index, data) self.index = index self.data = data end ---创建或者刷新界面数据时调用 function this:Refresh() end function this:RefreshItem() if self.data and self.data.cfg then GUI:Text_setString(self.view.activityName, self.data.cfg.name) GUI:Image_loadTexture(self.view.activityIcon, self.data.cfg.Icon, "Atlas/UIActivityPreview.spriteatlas") if self.data.open then GUI:Image_loadTexture(self.view.activityIsOpenImg, "act_open", "Atlas/UIActivityPreview.spriteatlas") else GUI:Image_loadTexture(self.view.activityIsOpenImg, "act_wait", "Atlas/UIActivityPreview.spriteatlas") end self:RefreshTimeText() if not self.timer then --self.timer = Timer.StartLoopForever(1, self.RefreshTimeText, self) self.timer = SL:Schedule(self.timer,0,1,-1,self.RefreshTimeText,self) end end end function this:RefreshTimeText() if not self.data then return end if self.data.open then local text = "剩余时间:" GUI:Text_setString(self.view.text, text) GUI:Text_setTextColor(self.view.textTime, EColor[EGradColor.green]) else local text = "开启时间:" GUI:Text_setString(self.view.text, text) GUI:Text_setTextColor(self.view.textTime, EColor[EGradColor.red]) end local showTime = self.data.leftTime - Time.GetServerTime() if showTime < 0 then if not self.isShowTimeOver then self.isShowTimeOver = true if self.timer then --Timer.Stop(self.timer) SL:UnSchedule(self.timer) self.timer = nil end SL:onLUAEvent(LUA_EVENT_ACTIVITYPREVIEW_CHANGE) self.isShowTimeOver = false end return end GUI:Text_setString(self.view.textTime, Time.FormatTimeHMS(math.ceil(showTime))) end function this:SetActiveUI(val) GUI:SetActive(self.view.root, val) end ----@return boolean function this:GetActiveUI(val) return GUI:getVisible(self.view.root) end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnClickEvent(self.view.btnGoNpc, self, self.OnClickGoNpc) end function this:OnClickGoNpc() if self.data and self.data.cfg then --狼魂要塞 if self.data.cfg.id == EActivityType.WolfSoulFortress then if SL:MeData_GetUnionId() == 0 then SL:TipMessage( SL:GetConfig('cfg_string', 433).text, 1, NoticeType.NoticeMid ) return end ---@type cfg_rep_column local tempTbl = InfoManager.wolfSoulFortressInfo:GetCfgByOpenServerDay() if tempTbl then SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_ENTER_DUPLICATE, tempTbl.id) end else local cond, message = InfoManager.godsDescendInfo.CheckActivityCondition(self.data.cfg.id) if cond then ---@type cfg_activity_rule_column local tbl = SL:GetConfig("cfg_activity_rule", self.data.cfg.id) if tbl.mapid and table.count(tbl.mapid) >0 then if tbl.mapid[1] == 21000 then local cond, message = InfoManager.godsDescendInfo.CheckActivityConditionMapId(self.data.cfg.id) if cond then SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_GOTO_CROSS_MAP,{}) else SL:TipMessage(message, 1, NoticeType.NoticeMid) end return end end SL:ShortcutDO(tbl.panel) else SL:TipMessage( message, 1, NoticeType.NoticeMid ) end --SL:ShortcutDO(self.data.cfg.panel) end end end function this:Close() if self.timer then --Timer.Stop(self.timer) SL:UnSchedule(self.timer) self.timer = nil end end return this