118 lines
4.6 KiB
Lua
118 lines
4.6 KiB
Lua
local DungeonBoardCell = class("DungeonBoardCell", BaseCell)
|
|
|
|
function DungeonBoardCell:init()
|
|
self.uiMap = self:getUIMap()
|
|
|
|
self.txTitle = self.uiMap["dungeon_board_cell.tx_title"]
|
|
self.countdown = self.uiMap["dungeon_board_cell.countdown"]
|
|
self.txCountdown = self.uiMap["dungeon_board_cell.countdown.tx_countdown"]
|
|
self.txOpen = self.uiMap["dungeon_board_cell.tx_open"]
|
|
self.lock = self.uiMap["dungeon_board_cell.lock"]
|
|
self.lockIcon = self.uiMap["dungeon_board_cell.lock.desc.icon"]
|
|
self.lockTxLock = self.uiMap["dungeon_board_cell.lock.desc.tx_lock"]
|
|
self.lockIconCountdown = self.uiMap["dungeon_board_cell.lock.countdown.icon"]
|
|
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.itemReward = self.uiMap["dungeon_board_cell.item_reward"]
|
|
self.itemRewardIcon = self.uiMap["dungeon_board_cell.item_reward.icon"]
|
|
|
|
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:refreshInfo()
|
|
self:refreshRewards()
|
|
end
|
|
|
|
function DungeonBoardCell:refreshInfo()
|
|
self.txTitle:setText(DataManager.DungeonData:getTitle(self.moduleKey))
|
|
self.txOpen:setText("<color=" .. DataManager.DungeonData:getOpenTextColor(self.moduleKey) .. ">" .. DataManager.DungeonData:getOpenTimeDesc(self.moduleKey) .. "</color>")
|
|
self.baseObject:setTexture(DataManager.DungeonData:getBanner(self.moduleKey))
|
|
|
|
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(110, 40, 0.6)
|
|
else
|
|
self.btnStart:removeRedPoint()
|
|
end
|
|
|
|
self.txOpen:setAnchoredPositionY(-110)
|
|
self.txStart:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
|
local timeStr = ":<color=#FF6464>" .. DataManager.DungeonData:getRemainTimes(self.moduleKey) .. "</color>"
|
|
self.txTimes:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, timeStr))
|
|
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
|
|
|
|
GFunc.centerImgAndTx(self.lockIcon, self.lockTxLock, 10)
|
|
GFunc.centerImgAndTx(self.lockIconCountdown, self.lockTxCountdown, 10)
|
|
end
|
|
|
|
function DungeonBoardCell:refreshRewards()
|
|
local reward = DataManager.DungeonData:getBoardShowRewardId(self.moduleKey)
|
|
if reward ~= nil then
|
|
-- 展示实际item
|
|
local info = ConfigManager:getConfig("item")[reward]
|
|
if info == nil then
|
|
return
|
|
end
|
|
|
|
self.itemRewardIcon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon)
|
|
self.itemReward:setTouchEnable(true)
|
|
self.itemReward:addClickListener(function()
|
|
ModuleManager.TipsManager:showRewardTips(reward, info.type, self.itemReward)
|
|
end)
|
|
else
|
|
reward = DataManager.DungeonData:getBoardShowRewardIcon(self.moduleKey)
|
|
-- 展示icon图片
|
|
self.itemRewardIcon:setSprite(reward[1], reward[2])
|
|
self.itemReward:setTouchEnable(false)
|
|
end
|
|
end
|
|
|
|
function DungeonBoardCell:refreshCountdown(txCountdown)
|
|
if self.countdownSid then
|
|
SchedulerManager:unscheduleGlobal(self.countdownSid)
|
|
self.countdownSid = nil
|
|
end
|
|
self.countdownSid = txCountdown:scheduleGlobal(function()
|
|
self:updateTime(txCountdown)
|
|
end, 1)
|
|
self:updateTime(txCountdown)
|
|
end
|
|
|
|
function DungeonBoardCell:updateTime(txCountdown)
|
|
if self.remainTime == nil then
|
|
self.remainTime = DataManager.DungeonData:geNextTime(self.moduleKey)
|
|
else
|
|
self.remainTime = self.remainTime - 1
|
|
end
|
|
|
|
txCountdown:setText(GFunc.getTimeStrWithHMS(self.remainTime))
|
|
end
|
|
|
|
return DungeonBoardCell |