112 lines
4.3 KiB
Lua
112 lines
4.3 KiB
Lua
local DungeonBoardCell = class("DungeonBoardCell", BaseCell)
|
|
|
|
function DungeonBoardCell:init()
|
|
self.uiMap = self:getUIMap()
|
|
|
|
self.icon = self.uiMap["dungeon_board_cell.info.icon"]
|
|
self.txTitle = self.uiMap["dungeon_board_cell.info.icon.tx_title"]
|
|
self.countdown = self.uiMap["dungeon_board_cell.info.countdown"]
|
|
self.txCountdown = self.uiMap["dungeon_board_cell.info.countdown.tx_countdown"]
|
|
self.txOpen = self.uiMap["dungeon_board_cell.info.tx_open"]
|
|
self.lock = self.uiMap["dungeon_board_cell.lock"]
|
|
self.lockTxLock = self.uiMap["dungeon_board_cell.lock.desc.tx_lock"]
|
|
self.lockTxCountdown = self.uiMap["dungeon_board_cell.lock.countdown.tx_countdown"]
|
|
self.btnStart = self.uiMap["dungeon_board_cell.btn_start"]
|
|
self.txStart = self.uiMap["dungeon_board_cell.btn_start.tx_btn"]
|
|
self.txTimes = self.uiMap["dungeon_board_cell.btn_start.tx_times"]
|
|
self.btnHelp = self.uiMap["dungeon_board_cell.btn_help"]
|
|
|
|
self.btnStart:addClickListener(function()
|
|
-- 打开副本关卡选择界面
|
|
UIManager:showUI("app/ui/dungeon/dungeon_difficulty_ui", {module = self.moduleKey})
|
|
end)
|
|
self.btnHelp:addClickListener(function()
|
|
-- 展示提示
|
|
ModuleManager.TipsManager:showDescTips(DataManager.DungeonData:getRule(self.moduleKey), self.btnHelp)
|
|
end)
|
|
end
|
|
|
|
function DungeonBoardCell:refresh(moduleKey)
|
|
self.moduleKey = moduleKey
|
|
self.baseObject:setName(self.moduleKey)
|
|
|
|
self:refreshInfo()
|
|
self:refreshRewards()
|
|
end
|
|
|
|
function DungeonBoardCell:refreshInfo()
|
|
self.txTitle:setText(DataManager.DungeonData:getTitle(self.moduleKey))
|
|
self.txOpen:setText(DataManager.DungeonData:getOpenTimeDesc(self.moduleKey))
|
|
self.icon:setSprite(DataManager.DungeonData:getIcon(self.moduleKey))
|
|
-- self.baseObject:setTexture("assets/arts/textures/background/fund/fund_bg_1.png")
|
|
-- self.iconBuff:setSprite(GConst.ATLAS_PATH.ICON_BUFF, "")
|
|
|
|
if DataManager.DungeonData:isActive(self.moduleKey) then
|
|
self.btnStart:setVisible(true)
|
|
self.countdown:setVisible(true)
|
|
self.lock:setVisible(false)
|
|
|
|
-- 红点
|
|
if DataManager.DungeonData:isCanChallenge(self.moduleKey) then
|
|
self.btnStart:addRedPoint(65, 35, 0.6)
|
|
else
|
|
self.btnStart:removeRedPoint()
|
|
end
|
|
|
|
self.txOpen:setAnchoredPositionY(-115)
|
|
self.txStart:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
|
self.txTimes:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, DataManager.DungeonData:getRemainTimes(self.moduleKey)))
|
|
self:refreshCountdown(self.txCountdown)
|
|
else
|
|
self.btnStart:setVisible(false)
|
|
self.countdown:setVisible(false)
|
|
self.lock:setVisible(true)
|
|
|
|
self.txOpen:setAnchoredPositionY(-75)
|
|
self.lockTxLock:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_OPEN))
|
|
self:refreshCountdown(self.lockTxCountdown)
|
|
end
|
|
end
|
|
|
|
function DungeonBoardCell:refreshRewards()
|
|
self.scrollRect = self.uiMap["dungeon_board_cell.rewards"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.scrollRect:addInitCallback(function()
|
|
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
|
end)
|
|
self.scrollRect:clearCells()
|
|
|
|
local rewards = DataManager.DungeonData:getBoardShowRewardId(self.moduleKey)
|
|
if rewards ~= nil then
|
|
-- 展示实际item
|
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
|
cell:refreshItemById(rewards[index], 0)
|
|
end)
|
|
self.scrollRect:setTotalCount(#rewards)
|
|
else
|
|
rewards = DataManager.DungeonData:getBoardShowRewardIcon(self.moduleKey)
|
|
-- 展示icon图片
|
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
|
cell:setRewardIcon(rewards[index][1], rewards[index][2])
|
|
cell:setVisibleS(false)
|
|
cell:setVisibleFragment(false)
|
|
cell:setTouchEnable(false)
|
|
end)
|
|
self.scrollRect:setTotalCount(#rewards)
|
|
end
|
|
end
|
|
|
|
function DungeonBoardCell:refreshCountdown(txCountdown)
|
|
if not self.countdownSid then
|
|
self.countdownSid = txCountdown:scheduleGlobal(function()
|
|
self:updateTime(txCountdown)
|
|
end, 1)
|
|
end
|
|
self:updateTime(txCountdown)
|
|
end
|
|
|
|
function DungeonBoardCell:updateTime(txCountdown)
|
|
local remainTime = Time:getTodaySurplusTime()
|
|
txCountdown:setText(GFunc.getTimeStrWithHMS(remainTime))
|
|
end
|
|
|
|
return DungeonBoardCell |