140 lines
5.4 KiB
Lua
140 lines
5.4 KiB
Lua
local DungeonDifficultyUI = class("DungeonDifficultyUI", BaseUI)
|
|
|
|
function DungeonDifficultyUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function DungeonDifficultyUI:getPrefabPath()
|
|
return "assets/prefabs/ui/dungeon/dungeon_difficulty_ui.prefab"
|
|
end
|
|
|
|
function DungeonDifficultyUI:ctor(params)
|
|
self.module = params.module
|
|
self.curId = DataManager.DungeonData:getUnlockMaxId(self.module)
|
|
end
|
|
|
|
function DungeonDifficultyUI:onCover()
|
|
end
|
|
|
|
function DungeonDifficultyUI:onReshow()
|
|
end
|
|
|
|
function DungeonDifficultyUI:onClose()
|
|
end
|
|
|
|
function DungeonDifficultyUI:onLoadRootComplete()
|
|
self.uiMap = self.root:genAllChildren()
|
|
|
|
self.btnClose = self.uiMap["dungeon_difficulty_ui.bg.close_btn"]
|
|
self.btnStart = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_start"]
|
|
self.txStart = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_start.tx_start"]
|
|
self.txStartCost = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_start.cost.tx_cost"]
|
|
self.btnSweep = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_sweep"]
|
|
self.txSweep = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_sweep.tx_sweep"]
|
|
self.txSweepCost = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_sweep.cost.tx_cost"]
|
|
self.txTime = self.uiMap["dungeon_difficulty_ui.bg.btns.tx_time"]
|
|
self.txDifficulty = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.tx_difficulty"]
|
|
self.txLevel = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.tx_level"]
|
|
self.arrowLeft = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.arrow_left"]
|
|
self.arrowRight = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.arrow_right"]
|
|
self.txDesc = self.uiMap["dungeon_difficulty_ui.bg.tx_desc"]
|
|
self.txTitle = self.uiMap["dungeon_difficulty_ui.bg.title.title_text"]
|
|
self.buffObj = self.uiMap["dungeon_difficulty_ui.bg.boss_buff"]
|
|
self.txbuff = self.uiMap["dungeon_difficulty_ui.bg.boss_buff.tx_buff"]
|
|
self.iconBuff = self.uiMap["dungeon_difficulty_ui.bg.boss_buff.icon_buff"]
|
|
self.rewardFirst = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_first"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
|
self.rewardPass = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_pass"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
|
self.txFrist = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_first.tx_first"]
|
|
|
|
self.txTitle:setText(DataManager.DungeonData:getTitle(self.module))
|
|
self.txDifficulty:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_STAGE))
|
|
self.txStart:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
|
self.txSweep:setText(I18N:getGlobalText(I18N.GlobalConst.SMASH))
|
|
local cost = DataManager.DungeonData:getChallengeHpCost(self.module)
|
|
self.txStartCost:setText("-"..GFunc.getRewardNum(cost))
|
|
self.txSweepCost:setText("-"..GFunc.getRewardNum(cost))
|
|
self.txTime:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, DataManager.DungeonData:getRemainTimes(self.module)))
|
|
self.txFrist:setText(I18N:getGlobalText(I18N.GlobalConst.FIRST_PASS))
|
|
|
|
self:refreshDifficulty()
|
|
|
|
self.btnClose:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
self.btnStart:addClickListener(function()
|
|
-- 开始挑战
|
|
ModuleManager.DungeonManager:reqChallenge(self.module, self.curId)
|
|
end)
|
|
self.btnSweep:addClickListener(function()
|
|
-- 开始扫荡
|
|
ModuleManager.DungeonManager:reqSweep(self.module, self.curId)
|
|
end)
|
|
self.arrowLeft:addClickListener(function()
|
|
if self:isCanChallengeMinId() then
|
|
return
|
|
end
|
|
|
|
self.curId = self.curId - 1
|
|
self:refreshDifficulty()
|
|
end)
|
|
self.arrowRight:addClickListener(function()
|
|
if self:isCanChallengeMaxId() then
|
|
return
|
|
end
|
|
|
|
self.curId = self.curId + 1
|
|
self:refreshDifficulty()
|
|
end)
|
|
end
|
|
|
|
function DungeonDifficultyUI:refreshDifficulty()
|
|
self.arrowLeft:setActive(not self:isCanChallengeMinId())
|
|
self.arrowRight:setActive(not self:isCanChallengeMaxId())
|
|
self.btnSweep:setActive(self:isCanSweepId())
|
|
self.txLevel:setText(tostring(self.curId))
|
|
|
|
-- buff or desc
|
|
local buff = DataManager.DungeonData:getBossBuff(self.module, self.curId)
|
|
local desc = DataManager.DungeonData:getRule(self.module)
|
|
if buff then
|
|
self.txDesc:setActive(false)
|
|
self.buffObj:setActive(true)
|
|
self.txbuff:setText("")
|
|
self.iconBuff:setSprite("","")
|
|
elseif desc then
|
|
self.txDesc:setActive(true)
|
|
self.buffObj:setActive(false)
|
|
self.txDesc:setText(desc)
|
|
else
|
|
self.txDesc:setActive(false)
|
|
self.buffObj:setActive(false)
|
|
end
|
|
|
|
-- 奖励
|
|
local rewardFirst = DataManager.DungeonData:getFirstReward(self.module, self.curId)
|
|
local rewardPass = DataManager.DungeonData:getPassReward(self.module, self.curId)
|
|
if not self:isCanSweepId() and rewardFirst then
|
|
self.rewardFirst:setVisible(true)
|
|
self.rewardFirst:refreshByConfig(rewardFirst)
|
|
else
|
|
self.rewardFirst:setVisible(false)
|
|
end
|
|
self.rewardPass:refreshByConfig(rewardPass)
|
|
end
|
|
|
|
-- 是否是可扫荡关卡
|
|
function DungeonDifficultyUI:isCanSweepId()
|
|
return self.curId < DataManager.DungeonData:getUnlockMaxId(self.module)
|
|
end
|
|
|
|
--是否是能挑战的最大关卡
|
|
function DungeonDifficultyUI:isCanChallengeMaxId()
|
|
return self.curId == DataManager.DungeonData:getUnlockMaxId(self.module)
|
|
end
|
|
|
|
--是否是能挑战的最小关卡
|
|
function DungeonDifficultyUI:isCanChallengeMinId()
|
|
return self.curId == 1
|
|
end
|
|
|
|
return DungeonDifficultyUI |