c1_lua/lua/app/ui/main_city/component/dungeon_comp.lua
2023-07-28 18:40:11 +08:00

62 lines
1.8 KiB
Lua

local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell"
local DungeonComp = class("DungeonComp", MainCompBaseCell)
function DungeonComp:getIsOpen()
return DataManager.DungeonData:isOpenAnyone()
end
function DungeonComp:getEntranceName()
return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_BTN)
end
function DungeonComp:getShowEntranceRedPoint()
return DataManager.DungeonData:isCanChallengeAnyone()
end
function DungeonComp:ctor()
end
function DungeonComp:init()
self.uiMap = self:getBaseObject():genAllChildren()
self.scrollRect = self.uiMap["dungeon_comp.scrollrect"]
self.scrollRectComp = self.scrollRect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRectComp:addInitCallback(function()
return "app/ui/dungeon/dungeon_board_cell"
end)
self.scrollRectComp:addRefreshCallback(function(index, cell)
cell:refresh(self.openDungeons[index].module)
end)
self.scrollRectComp:setTotalCount(0)
self:refreshShow()
end
function DungeonComp:refreshShow(targetMuduleKey)
if EDITOR_MODE then
Logger.logHighlight("更新副本显示."..tostring(Time:getTodaySurplusTime()))
end
self.openDungeons = DataManager.DungeonData:getOpenDungeons()
local targetIndex
if targetMuduleKey then
for index, dungeon in ipairs(self.openDungeons) do
if dungeon.module == targetMuduleKey then
targetIndex = index
break
end
end
end
self.scrollRectComp:clearCells()
self.scrollRectComp:refillCells(#self.openDungeons, nil, targetIndex)
-- 跨天定时器
if self.countdownSid then
self:getBaseObject():unscheduleGlobal(self.countdownSid)
self.countdownSid = nil
end
self.countdownSid = self:getBaseObject():scheduleGlobal(function()
ModuleManager.DungeonManager:checkDayChange()
end, Time:getTodaySurplusTime() + 1)
end
return DungeonComp