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.icon = self.uiMap["dungeon_difficulty_ui.bg.title.icon_title"] 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.rewardTx = self.uiMap["dungeon_difficulty_ui.bg.reward_desc"] self.rewardFirst = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_first"] self.rewardFirstIcon = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_first.icon"] self.rewardFirstNum = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_first.num"] self.rewardPass = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_pass"] self.rewardPassIcon = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_pass.icon"] self.rewardPassNum = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_pass.num"] self.txFrist = self.uiMap["dungeon_difficulty_ui.bg.rewards.reward_first.tx_first"] self.txLock = self.uiMap["dungeon_difficulty_ui.bg.tx_lock"] self.btnGroup = self.uiMap["dungeon_difficulty_ui.bg.btns"] local iconPath = DataManager.DungeonData:getIcon(self.module) self.icon:setSprite(iconPath[1], iconPath[2], function() self.icon:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize() end) 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)) local timeString = ":" .. DataManager.DungeonData:getRemainTimes(self.module).."" self.txTime:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, timeString)) self.txFrist:setText(I18N:getGlobalText(I18N.GlobalConst.FIRST_PASS)) self.rewardTx:setText(I18N:getGlobalText(I18N.GlobalConst.REWARD_DESC)..":") self.txLock:setText(I18N:getGlobalText(I18N.GlobalConst.PASS_REQUIRE)) 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:isMinId() then return end self.curId = self.curId - 1 self:refreshDifficulty() end) self.arrowRight:addClickListener(function() if self:isMaxId() then return end self.curId = self.curId + 1 self:refreshDifficulty() end) self:addEventListener(EventManager.CUSTOM_EVENT.DUNGEON_CHALLENGE, function() self:closeUI() end) self:addEventListener(EventManager.CUSTOM_EVENT.DUNGEON_SWEEP, function() self:closeUI() end) end function DungeonDifficultyUI:refreshDifficulty() 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 local cfg = ConfigManager:getConfigWithOtherKey("buff", "name")[buff.type] self.txDesc:setActive(false) self.buffObj:setActive(true) self.txbuff:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_DESC)) self.iconBuff:setSprite(GConst.ATLAS_PATH.ICON_BUFF, cfg.icon) self.iconBuff:addClickListener(function() ModuleManager.TipsManager:showDescTips(GFunc.getBuffDesc(buff.type, buff.num), self.iconBuff) end) 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 -- 箭头 self.txLock:setActive(not self:isCanChallengeId()) self.btnGroup:setActive(self:isCanChallengeId()) self.arrowRight:setActive(not self:isMaxId()) self.arrowLeft:setActive(not self:isMinId()) -- 奖励 local reward = DataManager.DungeonData:getBoardShowRewardId(self.module) if reward ~= nil then -- 展示实际item local info = ConfigManager:getConfig("item")[reward] if info == nil then return end self.rewardFirstIcon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon) self.rewardPassIcon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon) self.rewardFirst:setTouchEnable(true) self.rewardPass:setTouchEnable(true) self.rewardFirst:addClickListener(function() ModuleManager.TipsManager:showRewardTips(reward, info.type, self.rewardFirst) end) self.rewardPass:addClickListener(function() ModuleManager.TipsManager:showRewardTips(reward, info.type, self.rewardPass) end) else reward = DataManager.DungeonData:getBoardShowRewardIcon(self.module) -- 展示icon图片 self.rewardFirstIcon:setSprite(reward[1], reward[2]) self.rewardPassIcon:setSprite(reward[1], reward[2]) self.rewardFirst:setTouchEnable(false) self.rewardPass:setTouchEnable(false) end local firstNum = DataManager.DungeonData:getFirstRewardNum(self.module, self.curId) local passNum = DataManager.DungeonData:getPassRewardNum(self.module, self.curId) if not self:isCanSweepId() and firstNum then self.rewardFirst:setActive(true) self.rewardFirstNum:setText(firstNum) else self.rewardFirst:setActive(false) end self.rewardPassNum:setText(passNum) end -- 是否是可扫荡关卡 function DungeonDifficultyUI:isCanSweepId() return self.curId < DataManager.DungeonData:getUnlockMaxId(self.module) end --是否是可挑战关卡 function DungeonDifficultyUI:isCanChallengeId() return self.curId <= DataManager.DungeonData:getUnlockMaxId(self.module) end -- 是最大副本id function DungeonDifficultyUI:isMaxId() return self.curId == DataManager.DungeonData:getConfigMaxId(self.module) end --是最小关卡 function DungeonDifficultyUI:isMinId() return self.curId == 1 end return DungeonDifficultyUI