diff --git a/lua/app/module/daily_challenge/daily_challenge_manager.lua b/lua/app/module/daily_challenge/daily_challenge_manager.lua index 05efa73c..b2ca0144 100644 --- a/lua/app/module/daily_challenge/daily_challenge_manager.lua +++ b/lua/app/module/daily_challenge/daily_challenge_manager.lua @@ -1,236 +1,240 @@ local DailyChallengeManager = class("DailyChallengeManager", BaseModule) function DailyChallengeManager:init() - self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(idx) - DataManager.DailyChallengeData:setShowingMainComp(idx == GConst.MainCityConst.BOTTOM_PAGE.MAIN) - end) - self:addEventListener(EventManager.CUSTOM_EVENT.UI_CLOSE, function(index) + self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(idx) + DataManager.DailyChallengeData:setShowingMainComp(idx == GConst.MainCityConst.BOTTOM_PAGE.MAIN) + end) + self:addEventListener(EventManager.CUSTOM_EVENT.UI_CLOSE, function(index) if index == UIManager.UI_PATH.MAINCITY_UI then DataManager.DailyChallengeData:setShowingMainComp(false) end end) end +function DailyChallengeManager:showDailyChallengeUI() + UIManager:showUI("app/ui/battle/daily_challenge_ui") +end + function DailyChallengeManager:showBattleBuffUI() - UIManager:showUI("app/ui/battle/battle_daily_challenge_buff_ui") + UIManager:showUI("app/ui/battle/battle_daily_challenge_buff_ui") end function DailyChallengeManager:showBattleTaskUI() - UIManager:showUI("app/ui/daily_challenge/daily_challenge_task_ui") + UIManager:showUI("app/ui/daily_challenge/daily_challenge_task_ui") end function DailyChallengeManager:getBuffDesc(id) - local desc = I18N:getText("buff_daily_challenge", id, "desc") - return desc + local desc = I18N:getText("buff_daily_challenge", id, "desc") + return desc end function DailyChallengeManager:checkDayChange() - if not DataManager.DailyChallengeData:getIfCanReset() then + if not DataManager.DailyChallengeData:getIfCanReset() then + return + end + if not DataManager.DailyChallengeData:isShowingMainComp() then return end - if not DataManager.DailyChallengeData:isShowingMainComp() then - return - end - -- 跨天了,请求新数据 - self:performWithDelayGlobal(function() - self:onResetState() - end, math.random()) + -- 跨天了,请求新数据 + self:performWithDelayGlobal(function() + self:onResetState() + end, math.random()) end -- 开始挑战 function DailyChallengeManager:startChallenge() - -- 判断次数 - if not DataManager.DailyChallengeData:isEnoughChallengeTime() then - GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) - return - end + -- 判断次数 + if not DataManager.DailyChallengeData:isEnoughChallengeTime() then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) + return + end - -- 判断体力 - if not DataManager.DailyChallengeData:isEnoughHp() then - GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT) - ModuleManager.CommerceManager:showBuyVitUI() - return - end + -- 判断体力 + if not DataManager.DailyChallengeData:isEnoughHp() then + GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT) + ModuleManager.CommerceManager:showBuyVitUI() + return + end - -- 检查阵容 - if not DataManager.FormationData:formationIsFull(GConst.BattleConst.FORMATION_TYPE.STAGE) then - GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8)) - return - end + -- 检查阵容 + if not DataManager.FormationData:formationIsFull(GConst.BattleConst.FORMATION_TYPE.STAGE) then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8)) + return + end - if not DataManager.DailyChallengeData:isMeetChallenge() then - return - end + if not DataManager.DailyChallengeData:isMeetChallenge() then + return + end - local parmas = {} - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE) + local parmas = {} + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE) end function DailyChallengeManager:rspStartChallenge(result) - if result.err_code == GConst.ERROR_STR.SUCCESS then - DataManager.DailyChallengeData:onFightCountReduce() - DataManager.DailyChallengeData:setFixedChapterId(result.today_fixed_chapter_id) - ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE) - end + if result.err_code == GConst.ERROR_STR.SUCCESS then + DataManager.DailyChallengeData:onFightCountReduce() + DataManager.DailyChallengeData:setFixedChapterId(result.today_fixed_chapter_id) + ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE) + end end -- 挑战结束 function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgress, heroInfo, taskCurProgress) - local parmas = { - win = combatReport.victory, - chapter_id = chapterId, - hero_info = heroInfo, - task_stat = taskProgress, - combatReport = combatReport, - taskCurProgress = taskCurProgress - } + local parmas = { + win = combatReport.victory, + chapter_id = chapterId, + hero_info = heroInfo, + task_stat = taskProgress, + combatReport = combatReport, + taskCurProgress = taskCurProgress + } - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeSettlementReq, parmas, {}, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeSettlementReq, parmas, {}, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END) end function DailyChallengeManager:endChallengeFinish(result) - if result.err_code == GConst.ERROR_STR.SUCCESS then - if not result.reqData then - return - end - local reqData = result.reqData - local rewards = result.rewards - ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, rewards, reqData.combatReport) - DataManager.DailyChallengeData:init(result.daily_challenge) - ModuleManager.TaskManager:addFightTaskProgress(reqData.task_stat) + if result.err_code == GConst.ERROR_STR.SUCCESS then + if not result.reqData then + return + end + local reqData = result.reqData + local rewards = result.rewards + ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, rewards, reqData.combatReport) + DataManager.DailyChallengeData:init(result.daily_challenge) + ModuleManager.TaskManager:addFightTaskProgress(reqData.task_stat) - -- bi日志上报任务完成情况 - local taskProgress = reqData.taskCurProgress or {} - local completedCount = 0 - local taskInfo = {} - local tasks = DataManager.DailyChallengeData:getTasks() - for index, info in ipairs(tasks) do - local id = info.task_id - local idStr = tostring(id) - taskInfo[idStr] = GFunc.getTable(info) - taskInfo[idStr].curProgress = 0 - local progress = taskProgress[id] - if progress then - if type(progress) == "table" then - taskInfo[idStr].curProgress = progress[info.param] or 0 - else - taskInfo[idStr].curProgress = progress - end - end - if info.claimed or DataManager.DailyChallengeData:canClaimTask(index) then - completedCount = completedCount + 1 - if taskInfo[idStr].curProgress < (taskInfo[idStr].progress or 0) then - taskInfo[idStr].curProgress = taskInfo[idStr].progress or 0 - end - end - end - BIReport:postDailyChallengeTaskState(completedCount, taskInfo) + -- bi日志上报任务完成情况 + local taskProgress = reqData.taskCurProgress or {} + local completedCount = 0 + local taskInfo = {} + local tasks = DataManager.DailyChallengeData:getTasks() + for index, info in ipairs(tasks) do + local id = info.task_id + local idStr = tostring(id) + taskInfo[idStr] = GFunc.getTable(info) + taskInfo[idStr].curProgress = 0 + local progress = taskProgress[id] + if progress then + if type(progress) == "table" then + taskInfo[idStr].curProgress = progress[info.param] or 0 + else + taskInfo[idStr].curProgress = progress + end + end + if info.claimed or DataManager.DailyChallengeData:canClaimTask(index) then + completedCount = completedCount + 1 + if taskInfo[idStr].curProgress < (taskInfo[idStr].progress or 0) then + taskInfo[idStr].curProgress = taskInfo[idStr].progress or 0 + end + end + end + BIReport:postDailyChallengeTaskState(completedCount, taskInfo) - if result.reqData.win then - ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_DAILY_CHALLENGE_SUCCESS) - end - end + if result.reqData.win then + ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_DAILY_CHALLENGE_SUCCESS) + end + end end function DailyChallengeManager:onResetState() - if not DataManager.DailyChallengeData:isOpen() then - return - end - if DataManager.DailyChallengeData:getIsInReset() then - return - end - DataManager.DailyChallengeData:setInReset(true) - self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, {}, {}, self.rspResetState, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET) + if not DataManager.DailyChallengeData:isOpen() then + return + end + if DataManager.DailyChallengeData:getIsInReset() then + return + end + DataManager.DailyChallengeData:setInReset(true) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, {}, {}, self.rspResetState, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET) end function DailyChallengeManager:rspResetState(result) - DataManager.DailyChallengeData:setInReset(false) - DataManager.DailyChallengeData:init(result.daily_challenge) + DataManager.DailyChallengeData:setInReset(false) + DataManager.DailyChallengeData:init(result.daily_challenge) end -- 获取任务(箱子)奖励 function DailyChallengeManager:getTaskReward(idx) - self.getRewardTaskIdx = idx - local parmas = { - idx = idx, - } - self:sendMessage(ProtoMsgType.FromMsgEnum.DailyChallengeTaskAwardReq, parmas, {}, self.getTaskRewardFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_TASK_REWARD) + self.getRewardTaskIdx = idx + local parmas = { + idx = idx, + } + self:sendMessage(ProtoMsgType.FromMsgEnum.DailyChallengeTaskAwardReq, parmas, {}, self.getTaskRewardFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_TASK_REWARD) end function DailyChallengeManager:getTaskRewardFinish(result) - if result.err_code == GConst.ERROR_STR.SUCCESS then - GFunc.showRewardBox(result.rewards) - DataManager.DailyChallengeData:onGetedTaskReward(self.getRewardTaskIdx) - end + if result.err_code == GConst.ERROR_STR.SUCCESS then + GFunc.showRewardBox(result.rewards) + DataManager.DailyChallengeData:onGetedTaskReward(self.getRewardTaskIdx) + end end function DailyChallengeManager:dealTaskProgress(battleController) - local teamEntity = battleController.battleData:getAtkTeam() - local members = teamEntity:getAllMembers() - local heroInfo = {} - for k, v in pairs(members) do - heroInfo[v:getId()] = { - skill_cast = v:getActiveSkillReleaseCount(), - Damage = v:getDamageCount(), - } - end + local teamEntity = battleController.battleData:getAtkTeam() + local members = teamEntity:getAllMembers() + local heroInfo = {} + for k, v in pairs(members) do + heroInfo[v:getId()] = { + skill_cast = v:getActiveSkillReleaseCount(), + Damage = v:getDamageCount(), + } + end - local comboOver10Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.COMBO_OVER_10] - local linkCountOver8Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.LINK_COUNT_OVER_8] + local comboOver10Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.COMBO_OVER_10] + local linkCountOver8Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.LINK_COUNT_OVER_8] - local skillCountMap = {} - local damageMatchTypeMap = {} - local damageHeroMap = {} - local totalDmg = 0 - for heroId, info in pairs(heroInfo) do - local entity = DataManager.HeroData:getHeroById(heroId) - if entity then - skillCountMap[entity:getMatchType()] = info.skill_cast - damageMatchTypeMap[entity:getMatchType()] = info.Damage - damageHeroMap[heroId] = info.Damage - totalDmg = totalDmg + info.Damage - end - end - if totalDmg <= 0 then - totalDmg = 1 - end + local skillCountMap = {} + local damageMatchTypeMap = {} + local damageHeroMap = {} + local totalDmg = 0 + for heroId, info in pairs(heroInfo) do + local entity = DataManager.HeroData:getHeroById(heroId) + if entity then + skillCountMap[entity:getMatchType()] = info.skill_cast + damageMatchTypeMap[entity:getMatchType()] = info.Damage + damageHeroMap[heroId] = info.Damage + totalDmg = totalDmg + info.Damage + end + end + if totalDmg <= 0 then + totalDmg = 1 + end - for matchType, damage in pairs(damageMatchTypeMap) do - damageMatchTypeMap[matchType] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001) - end + for matchType, damage in pairs(damageMatchTypeMap) do + damageMatchTypeMap[matchType] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001) + end - for heroId, damage in pairs(damageHeroMap) do - damageHeroMap[heroId] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001) - end + for heroId, damage in pairs(damageHeroMap) do + damageHeroMap[heroId] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001) + end - local taskProgress = { - [3] = comboOver10Count, - [4] = linkCountOver8Count, - [5] = skillCountMap, - [7] = damageHeroMap, - [8] = damageMatchTypeMap - } - return taskProgress + local taskProgress = { + [3] = comboOver10Count, + [4] = linkCountOver8Count, + [5] = skillCountMap, + [7] = damageHeroMap, + [8] = damageMatchTypeMap + } + return taskProgress end function DailyChallengeManager:getCurTaskProgress(battleController) - local taskCurProgress ={} - local taskProgress = self:dealTaskProgress(battleController) - local tasks = DataManager.DailyChallengeData:getTasks() - for index, info in ipairs(tasks) do - local id = info.task_id - local progress = taskProgress[id] - if progress then - if type(progress) == "table" then - taskCurProgress[id] = progress[info.param] or 0 - else - taskCurProgress[id] = progress - end - end - end + local taskCurProgress ={} + local taskProgress = self:dealTaskProgress(battleController) + local tasks = DataManager.DailyChallengeData:getTasks() + for index, info in ipairs(tasks) do + local id = info.task_id + local progress = taskProgress[id] + if progress then + if type(progress) == "table" then + taskCurProgress[id] = progress[info.param] or 0 + else + taskCurProgress[id] = progress + end + end + end - return taskCurProgress + return taskCurProgress end return DailyChallengeManager \ No newline at end of file diff --git a/lua/app/module/maincity/maincity_const.lua b/lua/app/module/maincity/maincity_const.lua index 79d19cb9..333b46c5 100644 --- a/lua/app/module/maincity/maincity_const.lua +++ b/lua/app/module/maincity/maincity_const.lua @@ -16,19 +16,6 @@ MainCityConst.BOTTOM_ICON = { MainCityConst.BOTTOM_CLOSE_ICON = { } --- main界面模块 -MainCityConst.MAIN_MODULE = { - -- 左侧模块,负数,绝对值升序 - ARENA = -1, - DAILY_CHALLENGE = -2, - - -- 主模块 - CHAPTER = 0, - - -- 右侧模块,正数,绝对值升序 - DUNGEON = 1, -} - MainCityConst.LEFT_SIDE_BARS = { "app/ui/main_city/cell/side_bar_idle_cell", "app/ui/main_city/cell/side_bar_growth_fund_cell", diff --git a/lua/app/module/maincity/maincity_manager.lua b/lua/app/module/maincity/maincity_manager.lua index ed638df8..cd1e1685 100644 --- a/lua/app/module/maincity/maincity_manager.lua +++ b/lua/app/module/maincity/maincity_manager.lua @@ -99,16 +99,4 @@ function MaincityManager:isActivSideBarModule(moduleKey) return mainUI:isActivSideBarModule(moduleKey) end -function MaincityManager:setCurModule(moduleKey) - self.curModule = moduleKey -end - -function MaincityManager:getCurModule() - if not self.curModule then - -- 默认进主线章节 - return GConst.MainCityConst.MAIN_MODULE.CHAPTER - end - return self.curModule -end - return MaincityManager \ No newline at end of file diff --git a/lua/app/ui/daily_challenge/daily_challenge_ui.lua b/lua/app/ui/daily_challenge/daily_challenge_ui.lua new file mode 100644 index 00000000..2b498887 --- /dev/null +++ b/lua/app/ui/daily_challenge/daily_challenge_ui.lua @@ -0,0 +1,159 @@ +local DailyChallengeUI = class("DailyChallengeUI", BaseUI) + +function DailyChallengeUI:getIsOpen() + return DataManager.DailyChallengeData:isOpen() +end + +function DailyChallengeUI:getEntranceName() + return I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE) +end + +function DailyChallengeUI:getShowEntranceRedPoint() + return DataManager.DailyChallengeData:isMeetChallenge() +end + +function DailyChallengeUI:onClickFight() + ModuleManager.DailyChallengeManager:startChallenge() +end + +function DailyChallengeUI:ctor() + ModuleManager.DailyChallengeManager:checkDayChange() +end + +function DailyChallengeUI:onLoadRootComplete() + local uiMap = self.root:genAllChildren() + + uiMap["daily_challenge_ui.title.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE)) + uiMap["daily_challenge_ui.record_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.DailyChallengeData:getMaxWave())) + + self.tasks = GFunc.getTable() + table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task1"]) + table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task2"]) + table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task3"]) + + self.buffObj = uiMap["daily_challenge_ui.challenge.buffs.buff.btn_buff"] + self.debuffObj = uiMap["daily_challenge_ui.challenge.buffs.debuff.btn_debuff"] + self.bossSpine = uiMap["daily_challenge_ui.challenge.spine_node"] + self.countdownTx = uiMap["daily_challenge_ui.challenge.info.countdown.time_tx"] + + self.fightBtn = uiMap["daily_challenge_ui.fight_btn"] + -- 体力消耗 + self.fightCost = uiMap["daily_challenge_ui.fight_btn.cost"] + self.costTxDesc = uiMap["daily_challenge_ui.fight_btn.cost.tx_desc"] + self.costTxCost = uiMap["daily_challenge_ui.fight_btn.cost.tx_cost"] + -- 剩余次数 + self.countTxNum = uiMap["daily_challenge_ui.fight_btn.tx_count"] + -- 按钮文本 + self.txFight = uiMap["daily_challenge_ui.fight_btn.tx_desc"] +end + + +function DailyChallengeUI:updateTime() + ModuleManager.DailyChallengeManager:checkDayChange() + local remainTime = Time:getTodaySurplusTime() + self.countdownTx:setText(GFunc.getTimeStrWithHMS(remainTime)) +end + +function DailyChallengeUI:onRefresh() + self:refreshTask() + self:refreshBuff() + self:refreshBoss() + self:updateTime() + self:refreshFightBtn() +end + +function DailyChallengeUI:refreshTask() + local tasksData = DataManager.DailyChallengeData:getTasks() + for i = 1, #self.tasks do + local taskObj = self.tasks[i] + if DataManager.DailyChallengeData:canClaimTask(i) then + -- 任务奖励可领取 + taskObj:addRedPoint(30, 30, 0.6) + taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1") + else + -- 任务奖励不可领取 + taskObj:removeRedPoint() + if not DataManager.DailyChallengeData:isTaskFinish(i) then + taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1") + else + taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_2") + end + end + taskObj:addClickListener(function() + if DataManager.DailyChallengeData:canClaimTask(i) then + ModuleManager.DailyChallengeManager:getTaskReward(i) + else + local rewards = DataManager.DailyChallengeData:getTaskRewards(tasksData[i].task_id) + local desc = DataManager.DailyChallengeData:getTaskDesc(tasksData[i].task_id) + ModuleManager.TipsManager:showRewardsTips(rewards, desc, taskObj, nil, nil, false, ModuleManager.TipsManager.REWARDS_TIPS_TYPE.TASK) + end + end) + end +end + +function DailyChallengeUI:refreshBuff() + local buffIds = DataManager.DailyChallengeData:getTodayBuffIds() + self.buffObj:addClickListener(function() + ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[1]), self.buffObj) + end) + + self.debuffObj:addClickListener(function() + ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[2]), self.debuffObj) + end) +end + +function DailyChallengeUI:refreshBoss() + local curBossInfo = DataManager.DailyChallengeData:getFinalBossInfo() + if not curBossInfo then + return + end + if self.curModelId == curBossInfo.model_id then + return + end + if self.spineBoss then + self.spineBoss:destroy() + self.spineBoss = nil + self.curModelId = nil + end + self.curModelId = curBossInfo.model_id + SpineManager:loadHeroAsync(self.curModelId, self.bossSpine, function(spineObject) + self.spineBoss = spineObject + self.spineBoss:setDefaultMix(0) + self.spineBoss:setLocalScale(curBossInfo.model_ui, curBossInfo.model_ui, curBossInfo.model_ui) + self.spineBoss:playAnimation(GConst.BattleConst.SPINE_ANIMATION_NAME.IDLE, true, false) + end) +end + +function MainComp:refreshFightBtn() + local isShowFight = false + + -- 体力消耗 + local cost = DataManager.DailyChallengeData:getChallengeHpCost() + if cost then + isShowFight = true + self.fightCost:setActive(true) + self.costTxDesc:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) + self.costTxCost:setText(GFunc.getRewardNum(cost)) + else + self.fightCost:setActive(false) + end + + -- 剩余次数 + local remainCount = DataManager.DailyChallengeData:getTodayRemainLimitCount() + if remainCount >= 0 then + isShowFight = true + self.countTxNum:setActive(true) + self.countTxNum:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, remainCount)) + else + self.countTxNum:setActive(false) + end + + if isShowFight then + self.fightBtn:setActive(true) + self.fightBtn:addClickListener(moduleCell.onClickFight) + else + self.fightBtn:setActive(false) + end +end + +return DailyChallengeUI \ No newline at end of file diff --git a/lua/app/ui/main_city/component/daily_challenge_comp.lua.meta b/lua/app/ui/daily_challenge/daily_challenge_ui.lua.meta similarity index 100% rename from lua/app/ui/main_city/component/daily_challenge_comp.lua.meta rename to lua/app/ui/daily_challenge/daily_challenge_ui.lua.meta diff --git a/lua/app/ui/main_city/component/chapter_comp.lua b/lua/app/ui/main_city/component/chapter_comp.lua deleted file mode 100644 index 5ce33eff..00000000 --- a/lua/app/ui/main_city/component/chapter_comp.lua +++ /dev/null @@ -1,711 +0,0 @@ -local ChapterCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell" -local ChapterComp = class("ChapterComp", ChapterCompBaseCell) - -local UISpineObject = require "app/bf/unity/ui_spine_object" - --- local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png" -local HERO_SPINE_ASSET_PATH = "assets/arts/spines/characters/%s/%s_skeletondata.asset" -local CHAPTER_PATH = "assets/arts/textures/background/main/%s.png" - -local BOX_ICON = { - "common_chest_1", - "common_chest_4" -} - -function ChapterComp:getIsOpen() - return true -end - -function ChapterComp:getEntranceName() - return I18N:getGlobalText(I18N.GlobalConst.MAIN_CHAPTER) -end - -function ChapterComp:isShowTopNode() - return true -end - -function ChapterComp:isShowSideBar() - return true -end - -function ChapterComp:isShowBounty() - return true -end - -function ChapterComp:isShowHeroFormation() - return true -end - -function ChapterComp:getFightHpCost() - return DataManager.ChapterData:getFightCost() -end - -function ChapterComp:onClickFight() - ModuleManager.ChapterManager:startFight() -end - -function ChapterComp:init() - self.uiMap = self:getBaseObject():genAllChildren() - self:initChapter() -end - -function ChapterComp:initChapter() - self.chapterImg = self.uiMap["chapter.img"] - self.chapterNameTx = self.uiMap["chapter.name_tx"] - self.chapterWavetx = self.uiMap["chapter.record_tx"] - self.leftArrow = self.uiMap["chapter.left_arrow"] - local leftArrowBtn = self.uiMap["chapter.left_arrow.btn"] - leftArrowBtn:addClickListener(function() - if DataManager.ChapterData:goLastChapter() then - self:refresh() - end - end) - self.rightArrow = self.uiMap["chapter.right_arrow"] - local rightArrowBtn = self.uiMap["chapter.right_arrow.btn"] - rightArrowBtn:addClickListener(function() - if DataManager.ChapterData:goNextChapter() then - self:refresh() - end - end) - - self.uiMap["chapter.effect_node.ui_spine_obj"]:playAnim("idle", true, false) - - self.chapterBg = self.uiMap["chapter_comp.bg"] - self.chapterBg:setAnchoredPositionX(-720) - self.bossSmoke = self.uiMap["chapter_comp.boss_smoke"] - self.bossSmoke:setAnchoredPositionX(10000) - self.smokeNodeTop = self.uiMap["chapter_comp.smoke_node_1"] - self.monsterNodeTop = self.uiMap["chapter_comp.monster_node_1"] - self.bossNode = self.uiMap["chapter_comp.boss_node"] - self.bossNode:setActive(false) - self.bossSpine = self.uiMap["chapter_comp.boss_node.boss"] - self.smokeNodeDown = self.uiMap["chapter_comp.smoke_node_2"] - self.monsterNodeDown = self.uiMap["chapter_comp.monster_node_2"] - self.dialogueTx = self.uiMap["chapter_comp.dialogue_node.bg.text"] - self.dialogueBg = self.uiMap["chapter_comp.dialogue_node.bg"] - self.dialogueNode = self.uiMap["chapter_comp.dialogue_node"] - self.dialogueNode:setAnchoredPositionX(0) - self.monsterSpineTopPool = {} - self.monsterSpineDownPool = {} - self.monsterSpineTopList = {} - self.monsterSpineDownList = {} - -- self.monsterShadowPool = {} - self.monsterSmokePool = {} - self.startMonsterAction = true -end - -function ChapterComp:refresh() - self:refreshChapter() -end - -function ChapterComp:refreshChapter(force) - local chapterId = DataManager.ChapterData:getChapterId() - if self.currChapterId ~= chapterId or force then - if DataManager.ChapterData:getIsFirstChapter(chapterId) then -- 第一章不需要左箭头 - self.leftArrow:setVisible(false) - self.rightArrow:setVisible(DataManager.ChapterData:getMaxChapterId() >= 1) - elseif chapterId == DataManager.ChapterData:getMaxChapterId() + 1 then -- 只能看打的最远的关卡 - self.leftArrow:setVisible(true) - self.rightArrow:setVisible(false) - else - self.leftArrow:setVisible(true) - self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId)) - end - - self.currChapterId = chapterId - local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] - local chapterI18NInfo = I18N:getConfig("chapter")[chapterId] - if chapterInfo then - local monsterIdList = chapterInfo.monster_id - if monsterIdList then - local bossId = monsterIdList[1] - if bossId then - local monsterCfg = ConfigManager:getConfig("monster_base") - local monsterInfo = monsterCfg[bossId] - if monsterInfo then - -- self.dialogueBg:setAnchoredPositionY(monsterInfo.blood * monsterInfo.ui/10 + 20) - end - end - end - -- main_bg_1 - -- self.chapterBg:setTexture(string.format(CHAPTER_PATH, chapterInfo.scenes_a)) end - self.chapterBg:setTexture(string.format(CHAPTER_PATH, "main_bg_1")) - end - if chapterI18NInfo then - self.chapterNameTx:setText(chapterI18NInfo.name) - end - self.chapterWavetx:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.ChapterData:getChapterMaxWave())) - - local slider = self.uiMap["chapter.progress_bg.slider"] - if not self.boxObjs then - self.boxObjs = {} - for i = 1, 3 do - self.boxObjs[i] = { - box = self.uiMap["chapter.progress_bg.box_" .. i], - desc = self.uiMap["chapter.progress_bg.box_desc_" .. i], - spineObj = self.uiMap["chapter.progress_bg.spine_node.ui_spine_obj_" .. i], - boxIcon = self.uiMap["chapter.progress_bg.box_" .. i .. ".box_icon"] - } - end - end - - local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId) - local mysteryBoxBg = self.uiMap["chapter_comp.img.bg"] - mysteryBoxBg:setVisible(mysteryBoxCount > 0) - local mysteryBoxIcon = self.uiMap["chapter.img.mystery_box_icon"] - mysteryBoxIcon:setVisible(mysteryBoxCount > 0) - if mysteryBoxCount > 0 then - local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId) - local desc = I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_2, gotCount, mysteryBoxCount) - self.uiMap["chapter.img.mystery_box_icon.desc"]:setText(desc) - end - - local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() - if rewardChapterId > chapterId then - rewardChapterId = chapterId - end - - local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId) - local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId) - local unitValue = 1 / boxCount - local sliderValue = 0 - local lastValue = 0 - for i = 1, boxCount do - if curMaxWave < lastValue then - break - end - local maxWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, i) - local wave = math.min(curMaxWave, maxWave) - sliderValue = sliderValue + unitValue * (wave - lastValue) / (maxWave - lastValue) - lastValue = maxWave - end - slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = sliderValue - - for index, objs in ipairs(self.boxObjs) do - local show = boxCount >= index - objs.box:setActive(show) - objs.desc:setActive(show) - objs.spineObj:setVisible(false) - if show then - local needWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) - local x = 370 * (index / boxCount) - local rewards = DataManager.ChapterData:getChapterBoxRewards(rewardChapterId, index) - local num = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) - local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(rewardChapterId, index) - local icon = BOX_ICON[1] - if rewardGot then - icon = BOX_ICON[2] - end - objs.box:addClickListener(function() - if needWave <= curMaxWave and not rewardGot then - objs.spineObj:setVisible(true) - objs.spineObj:playAnimComplete("open", false, false, function() - ModuleManager.ChapterManager:openBox(rewardChapterId, index) - end) - else - ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box) - end - end) - objs.boxIcon:setSprite(GConst.ATLAS_PATH.COMMON, icon) - objs.box:setAnchoredPositionX(x) - if needWave <= curMaxWave and not rewardGot then - objs.spineObj:setVisible(true) - objs.spineObj:playAnim("idle", true, false) - objs.spineObj:setAnchoredPositionX(x) - objs.boxIcon:setVisible(false) - else - objs.spineObj:setVisible(false) - objs.boxIcon:setVisible(true) - end - objs.desc:setAnchoredPositionX(x) - if boxCount == index then - objs.desc:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_DESC_1, rewardChapterId)) - else - objs.desc:setText(num) - end - end - end - - self:refreshFightBtn() - self:doBossAction() - end - self:doChapterMove() - self:doMonsterAction() -end - -function ChapterComp:onOpen() - self.startMonsterAction = true - if self.bossNode then - self.bossNode:setAnchoredPositionX(0) - end - -- if self.bossShadow then - -- self.bossShadow:setAnchoredPositionX(0) - -- end - if self.dialogueNode then - self.dialogueNode:setAnchoredPositionX(0) - end -end - -function ChapterComp:onClose() - if self.chapterMoveSeq then - self.chapterMoveSeq:Kill() - self.chapterMoveSeq = nil - end - if self.chapterMonsterGenerateSeq then - self.chapterMonsterGenerateSeq:Kill() - self.chapterMonsterGenerateSeq = nil - end - self.currChapterId = nil - self.isTopTurn = nil - self.startMonsterAction = false - GFunc.killDOTween(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) - self.monsterSpineTopPool = {} - self.monsterSpineDownPool = {} - self.monsterSpineTopList = {} - self.monsterSpineDownList = {} - -- self.monsterShadowPool = {} - self.monsterSmokePool = {} - self.monsterNodeTop:removeAllChildren() - self.monsterNodeDown:removeAllChildren() - -- self.shadowNode:removeAllChildren() - self.smokeNodeTop:removeAllChildren() - self.smokeNodeDown:removeAllChildren() -end - --- region 动画 -function ChapterComp:doChapterMove() - if self.chapterMoveSeq then - return - end - self.chapterBg:setAnchoredPositionX(-720) - self.chapterMoveSeq = self.chapterBg:createBindTweenSequence() - local moveTween = self.chapterBg:getTransform():DOAnchorPosX(720, 20):SetEase(CS.DG.Tweening.Ease.Linear) - self.chapterMoveSeq:Append(moveTween) - self.chapterMoveSeq:AppendCallback(function() - self.chapterBg:setAnchoredPositionX(-720) - end) - self.chapterMoveSeq:SetLoops(-1) -end - -function ChapterComp:doBossAction() - if self.currChapterId == nil then - return - end - local chapterInfo = ConfigManager:getConfig("chapter")[self.currChapterId] - if chapterInfo == nil then - return - end - local monsterIdList = chapterInfo.monster_id - monsterIdList = {20001, 10001, 10002} - if monsterIdList == nil then - return - end - self.chapterMonsterShowList = monsterIdList - if self.chapterBossId == nil then -- 还没显示boss模型 - self.chapterBossId = self.chapterMonsterShowList[1] - local chapterBossId = self.chapterBossId - local monsterCfg = ConfigManager:getConfig("monster_base") - local monsterInfo = monsterCfg[self.chapterBossId] - if monsterInfo then - local modelId = monsterInfo.model_id - local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId) - self.bossNode:setActive(false) - local scale = monsterInfo.ui or 1 - local shadowScale = (monsterInfo.shadow or 1) * scale - -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale - -- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale) - -- self.bossShadow:setAnchoredPosition(10000, shadowOffset) - self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) - self.bossSmoke:setAnchoredPositionX(10000) - self.bossSpine:loadAssetAsync(modelId, function() - if chapterBossId == self.chapterBossId then - self.bossNode:setActive(true) - self.bossSpine:setLocalScale(-scale, scale, scale) - self.bossSpine:playAnim("move", true, true, true) - -- self.bossShadow:setAnchoredPositionX(0) - self.bossSmoke:playAnim("idle", true, true, true) - self.bossSmoke:setAnchoredPositionX(0) - else -- 加载完成后,已经切换到其他boss了 - self:doChangeBossAction() - end - end, path) - end - else - local chapterBossId = self.chapterMonsterShowList[1] - if self.chapterBossId ~= chapterBossId then - self.chapterBossId = chapterBossId - self:doChangeBossAction() - end - end -end - --- 切换boss -function ChapterComp:doChangeBossAction() - local chapterBossId = self.chapterBossId - local monsterCfg = ConfigManager:getConfig("monster_base") - local monsterInfo = monsterCfg[self.chapterBossId] - if monsterInfo then - local modelId = monsterInfo.model_id - local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId) - self.bossNode:setActive(false) - local scale = monsterInfo.ui or 1 - local shadowScale = (monsterInfo.shadow or 1) * scale - -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale - -- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale) - -- self.bossShadow:setAnchoredPosition(10000, shadowOffset) - self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) - self.bossSmoke:setAnchoredPositionX(10000) - self.bossSpine:loadAssetAsync(modelId, function() - if chapterBossId == self.chapterBossId then - self.bossNode:setActive(true) - self.bossSpine:setLocalScale(-scale, scale, scale) - self.bossSpine:playAnim("move", true, true, true) - -- self.bossShadow:setAnchoredPositionX(0) - self.bossSmoke:playAnim("idle", true, true, true) - self.bossSmoke:setAnchoredPositionX(0) - else -- 加载完成后,已经切换到其他boss了 - self:doChangeBossAction() - end - end, path) - end -end - -function ChapterComp:doMonsterAction() - if self.chapterMonsterGenerateSeq then - return - end - self.chapterMonsterGenerateSeq = DOTweenManager:createSeqWithIntId() - local interval = GFunc.getConstValue("chapter_idel_monster_x") / 1000 - interval = 2 - self.chapterMonsterGenerateSeq:AppendCallback(function() - self:generateChapterMonsters() - end) - self.chapterMonsterGenerateSeq:AppendInterval(interval) - self.chapterMonsterGenerateSeq:SetLoops(-1) -end - -function ChapterComp:generateChapterMonsters() - local monsterId - if #self.chapterMonsterShowList <= 2 then - monsterId = self.chapterMonsterShowList[2] - else - monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)] - end - if monsterId == nil then - return - end - local monsterCfg = ConfigManager:getConfig("monster_base") - local monsterInfo = monsterCfg[monsterId] - if monsterInfo == nil then - return - end - if self.isTopTurn == nil then - self.isTopTurn = math.random(1, 100) > 50 - end - local modelId = monsterInfo.model_id - local pool - local list - local parent - local posY - if self.isTopTurn then -- 刷上面 - pool = self.monsterSpineTopPool[modelId] - list = self.monsterSpineTopList - parent = self.monsterNodeTop - posY = math.random(1, 300) - else -- 刷下面 - pool = self.monsterSpineDownPool[modelId] - list = self.monsterSpineDownList - parent = self.monsterNodeDown - posY = -math.random(1, 240) - end - self.isTopTurn = not self.isTopTurn - if pool and #pool > 0 then - local spine = table.remove(pool) - table.insert(list, spine) - spine:setActive(true) - self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) - else - SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine) - if not self.startMonsterAction then - spine:destroy() - return - end - table.insert(list, spine) - local scale = monsterInfo.ui or 1 - spine:setLocalScale(-scale, scale, scale) - self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) - end) - end -end - -function ChapterComp:doMonsterMove(modelId, spine, posY, monsterInfo, isTopTurn) - spine:playAnim("move", true, true, true) - local posX = GConst.UI_SCREEN_WIDTH / 2 + 100 - local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300 - spine:setAnchoredPosition(posX, posY) - local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) - if self.chapterMonsterSpeed == nil then - -- self.chapterMonsterSpeed = GFunc.getConstValue("chapter_idel_monstermove") - self.chapterMonsterSpeed = 150 - end - local distance = posX - targetPosX - local moveTime = distance / self.chapterMonsterSpeed - local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - seq:Append(moveTween) - - -- local monsterShadow = self:getMonsterShadow() - local scale = monsterInfo.ui or 1 - local shadowScale = (monsterInfo.shadow or 1) * scale - -- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale) - -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale - -- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset) - -- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - -- seq:Join(moveTween2) - - local monsterSmoke = self:getMonsterSmoke(isTopTurn) - monsterSmoke:setAnchoredPosition(posX, posY) - monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) - monsterSmoke:playAnim("idle", true, true, true) - local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - seq:Join(moveTween3) - - seq:AppendCallback(function() - spine:setActive(false) - -- monsterShadow:setAnchoredPositionX(10000) - -- table.insert(self.monsterShadowPool, monsterShadow) - monsterSmoke:setAnchoredPositionX(10000) - table.insert(self.monsterSmokePool, monsterSmoke) - if isTopTurn then - local pool = self.monsterSpineTopPool[modelId] - if pool == nil then - pool = {} - self.monsterSpineTopPool[modelId] = pool - end - table.insert(pool, spine) - for k, v in ipairs(self.monsterSpineTopList) do - if v == spine then - table.remove(self.monsterSpineTopList, k) - break - end - end - else - local pool = self.monsterSpineDownPool[modelId] - if pool == nil then - pool = {} - self.monsterSpineDownPool[modelId] = pool - end - table.insert(pool, spine) - for k, v in ipairs(self.monsterSpineDownList) do - if v == spine then - table.remove(self.monsterSpineDownList, k) - break - end - end - end - end) -end - -function ChapterComp:enterChapterBattle() - -- boss等一会再跑 - local bossWaitTime = GFunc.getConstValue("chapter_fight_bosswait") / 1000 - local bossSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) - bossSeq:AppendInterval(bossWaitTime) - local bossSpeed = GFunc.getConstValue("chapter_fight_bossmove") - local distance = GConst.UI_SCREEN_WIDTH/2 + 100 - local moveTime = distance / bossSpeed - local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300 - local moveTween = self.bossNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - bossSeq:Append(moveTween) - local moveTween2 = self.dialogueNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - bossSeq:Join(moveTween2) - -- local moveTween3 = self.bossShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - -- bossSeq:Join(moveTween3) - - - -- 出来一批小怪从右边跑向左边 - local monsterCount = GFunc.getConstIntValue("chapter_fight_monster_num") - self.chapterFightMonsterCount = monsterCount - local wave = 5 - local monsterCountPerWave = math.ceil(monsterCount / wave) - -- 分批处理 - local monsterSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) - for i = 1, wave do - monsterSeq:AppendCallback(function () - if monsterCountPerWave > monsterCount then - monsterCountPerWave = monsterCount - end - monsterCount = monsterCount - monsterCountPerWave - for j = 1, monsterCountPerWave do - self:generateChapterFightMonsters() - end - end) - monsterSeq:AppendInterval(0.03) - end - return GFunc.getConstValue("chapter_fight_wait") / 1000 -end - -function ChapterComp:generateChapterFightMonsters() - local monsterId - if #self.chapterMonsterShowList <= 2 then - monsterId = self.chapterMonsterShowList[2] - else - monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)] - end - if monsterId == nil then - return - end - local monsterCfg = ConfigManager:getConfig("monster_base") - local monsterInfo = monsterCfg[monsterId] - if monsterInfo == nil then - return - end - local modelId = monsterInfo.model_id - local pool - local list - local parent - local posY - if self.isTopTurn then -- 刷上面 - pool = self.monsterSpineTopPool[modelId] - list = self.monsterSpineTopList - parent = self.monsterNodeTop - posY = math.random(1, 300) - else -- 刷下面 - pool = self.monsterSpineDownPool[modelId] - list = self.monsterSpineDownList - parent = self.monsterNodeDown - posY = -math.random(1, 240) - end - self.isTopTurn = not self.isTopTurn - if pool and #pool > 0 then - local spine = table.remove(pool) - table.insert(list, spine) - spine:setActive(true) - self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) - else - SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine) - if not self.startMonsterAction then - spine:destroy() - return - end - table.insert(list, spine) - local scale = monsterInfo.ui or 1 - spine:setLocalScale(-scale, scale, scale) - self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) - end) - end -end - -function ChapterComp:doMonsterFightMove(modelId, spine, posY, monsterInfo, isTopTurn) - spine:playAnim("move", true, true, true) - local posX = GConst.UI_SCREEN_WIDTH / 2 + math.random(100, math.floor(GConst.UI_SCREEN_WIDTH*2/3)) - spine:setAnchoredPosition(posX, posY) - local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) - if self.chapterMonsterFightSpeed == nil then - -- self.chapterMonsterFightSpeed = GFunc.getConstValue("chapter_fight_monstermove") - self.chapterMonsterFightSpeed = 880 - end - local distance = posX + GConst.UI_SCREEN_WIDTH/2 + 100 - local moveTime = distance / self.chapterMonsterFightSpeed - local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 100 - local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - seq:Append(moveTween) - - -- local monsterShadow = self:getMonsterShadow() - local scale = monsterInfo.ui or 1 - local shadowScale = (monsterInfo.shadow or 1) * scale - -- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale) - -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale - -- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset) - -- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - -- seq:Join(moveTween2) - - local monsterSmoke = self:getMonsterSmoke(isTopTurn) - monsterSmoke:setAnchoredPosition(posX, posY) - monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) - monsterSmoke:playAnim("idle", true, true, true) - local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) - seq:Join(moveTween3) - - seq:AppendCallback(function() - spine:setActive(false) - -- monsterShadow:setAnchoredPositionX(10000) - -- table.insert(self.monsterShadowPool, monsterShadow) - monsterSmoke:setAnchoredPositionX(10000) - table.insert(self.monsterSmokePool, monsterSmoke) - if isTopTurn then - local pool = self.monsterSpineTopPool[modelId] - if pool == nil then - pool = {} - self.monsterSpineTopPool[modelId] = pool - end - table.insert(pool, spine) - for k, v in ipairs(self.monsterSpineTopList) do - if v == spine then - table.remove(self.monsterSpineTopList, k) - break - end - end - else - local pool = self.monsterSpineDownPool[modelId] - if pool == nil then - pool = {} - self.monsterSpineDownPool[modelId] = pool - end - table.insert(pool, spine) - for k, v in ipairs(self.monsterSpineDownList) do - if v == spine then - table.remove(self.monsterSpineDownList, k) - break - end - end - end - end) - - if self.chapterFightMonsterCount then - self.chapterFightMonsterCount = self.chapterFightMonsterCount - 1 - if self.chapterFightMonsterCount == 0 then -- 最后一个怪物生成完毕后,重新排一下序 - self:sortChapterFightMonstersOrder() - self:sortChapterFightMonstersOrder() - self:sortChapterFightMonstersOrder() - self:sortChapterFightMonstersOrder() - end - end -end - -function ChapterComp:sortChapterFightMonstersOrder() - self:sortChildrenOrder(self.monsterNodeTop) - self:sortChildrenOrder(self.monsterNodeDown) - self:sortChildrenOrder(self.smokeNodeTop) - self:sortChildrenOrder(self.smokeNodeDown) -end - -function ChapterComp:sortChildrenOrder(parent) - local children = parent:getChildList() - if children and #children > 0 then - table.sort(children, function(a, b) - return a:getAnchoredPositionY() > b:getAnchoredPositionY() - end) - - for i = #children, 1, -1 do - children[i]:getTransform():SetSiblingIndex(i - 1) - end - end -end - -function ChapterComp:getMonsterSmoke(isTop) - local monsterSmoke - if #self.monsterSmokePool > 0 then - monsterSmoke = table.remove(self.monsterSmokePool) - monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false) - else - local shadowObj = CS.UnityEngine.Object.Instantiate(self.bossSmoke:getGameObject()) - monsterSmoke = UISpineObject:create() - monsterSmoke:initWithPrefab(GConst.EMPTY_STRING, shadowObj) - monsterSmoke:getAnimationState() - monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false) - end - return monsterSmoke -end --- endregion - -return ChapterComp \ No newline at end of file diff --git a/lua/app/ui/main_city/component/chapter_comp.lua.meta b/lua/app/ui/main_city/component/chapter_comp.lua.meta deleted file mode 100644 index 376736c0..00000000 --- a/lua/app/ui/main_city/component/chapter_comp.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 86d90ec67bf352c4d916945ae3b6a5da -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/component/daily_challenge_comp.lua b/lua/app/ui/main_city/component/daily_challenge_comp.lua deleted file mode 100644 index a5a64207..00000000 --- a/lua/app/ui/main_city/component/daily_challenge_comp.lua +++ /dev/null @@ -1,152 +0,0 @@ -local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell" -local DailyChallengeComp = class("DailyChallengeComp", MainCompBaseCell) - -function DailyChallengeComp:getIsOpen() - return DataManager.DailyChallengeData:isOpen() -end - -function DailyChallengeComp:getEntranceName() - return I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE) -end - -function DailyChallengeComp:getShowEntranceRedPoint() - return DataManager.DailyChallengeData:isMeetChallenge() -end - -function DailyChallengeComp:isShowTopNode() - return true -end - -function DailyChallengeComp:isShowSideBar() - return true -end - -function DailyChallengeComp:isShowHeroFormation() - return true -end - -function DailyChallengeComp:getFightHpCost() - return DataManager.DailyChallengeData:getChallengeHpCost() -end - -function DailyChallengeComp:getFightTodayRemainCount() - return DataManager.DailyChallengeData:getTodayRemainLimitCount() -end - -function DailyChallengeComp:onClickFight() - ModuleManager.DailyChallengeManager:startChallenge() -end - -function DailyChallengeComp:ctor() - ModuleManager.DailyChallengeManager:checkDayChange() -end - -function DailyChallengeComp:init() - self.uiMap = self:getBaseObject():genAllChildren() - self:refreshShow() -end - -function DailyChallengeComp:refreshShow() - if not DataManager.DailyChallengeData:isOpen() then - return - end - self:refreshTxt() - self:refreshTask() - self:refreshBuff() - self:refreshBoss() - self:refreshCountdown() -end - -function DailyChallengeComp:refreshTxt() - self.uiMap["daily_challenge_comp.title.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE)) - self.uiMap["daily_challenge_comp.record_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.DailyChallengeData:getMaxWave())) -end - -function DailyChallengeComp:refreshTask() - if self.tasks == nil or #self.tasks < 3 then - self.tasks = GFunc.getTable() - table.insert(self.tasks, self.uiMap["daily_challenge_comp.challenge.task.icon_task1"]) - table.insert(self.tasks, self.uiMap["daily_challenge_comp.challenge.task.icon_task2"]) - table.insert(self.tasks, self.uiMap["daily_challenge_comp.challenge.task.icon_task3"]) - end - - local tasksData = DataManager.DailyChallengeData:getTasks() - for i = 1, #self.tasks do - local taskObj = self.tasks[i] - if DataManager.DailyChallengeData:canClaimTask(i) then - -- 任务奖励可领取 - taskObj:addRedPoint(30, 30, 0.6) - taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1") - else - -- 任务奖励不可领取 - taskObj:removeRedPoint() - if not DataManager.DailyChallengeData:isTaskFinish(i) then - taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1") - else - taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_2") - end - end - taskObj:addClickListener(function() - if DataManager.DailyChallengeData:canClaimTask(i) then - ModuleManager.DailyChallengeManager:getTaskReward(i) - else - local rewards = DataManager.DailyChallengeData:getTaskRewards(tasksData[i].task_id) - local desc = DataManager.DailyChallengeData:getTaskDesc(tasksData[i].task_id) - ModuleManager.TipsManager:showRewardsTips(rewards, desc, taskObj, nil, nil, false, ModuleManager.TipsManager.REWARDS_TIPS_TYPE.TASK) - end - end) - end -end - -function DailyChallengeComp:refreshBuff() - local buffObj = self.uiMap["daily_challenge_comp.challenge.buffs.buff.btn_buff"] - local buffIds = DataManager.DailyChallengeData:getTodayBuffIds() - buffObj:addClickListener(function() - ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[1]), buffObj) - end) - - local debuffObj = self.uiMap["daily_challenge_comp.challenge.buffs.debuff.btn_debuff"] - debuffObj:addClickListener(function() - ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[2]), debuffObj) - end) -end - -function DailyChallengeComp:refreshBoss() - local curBossInfo = DataManager.DailyChallengeData:getFinalBossInfo() - if not curBossInfo then - return - end - if self.curModelId == curBossInfo.model_id then - return - end - if self.spineBoss then - self.spineBoss:destroy() - self.spineBoss = nil - self.curModelId = nil - end - self.curModelId = curBossInfo.model_id - SpineManager:loadHeroAsync(self.curModelId, self.uiMap["daily_challenge_comp.boss.spine_node"], function(spineObject) - self.spineBoss = spineObject - self.spineBoss:setDefaultMix(0) - self.spineBoss:setLocalScale(curBossInfo.model_ui, curBossInfo.model_ui, curBossInfo.model_ui) - self.spineBoss:playAnimation(GConst.BattleConst.SPINE_ANIMATION_NAME.IDLE, true, false) - end) -end - -function DailyChallengeComp:refreshCountdown() - self.countdownTx = self.uiMap["daily_challenge_comp.countdown.time_tx"] - if not self.countdownSid then - self.countdownSid = self:getBaseObject():scheduleGlobal(function() - self:updateTime() - end, 1) - end - self:updateTime() -end - -function DailyChallengeComp:updateTime() - ModuleManager.DailyChallengeManager:checkDayChange() - local remainTime = Time:getTodaySurplusTime() - self.countdownTx:setText(GFunc.getTimeStrWithHMS(remainTime)) -end - -return DailyChallengeComp \ No newline at end of file diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 728131b2..8314669d 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -1,396 +1,710 @@ -local MainComp = class("MainComp", LuaComponent) -local CHAPTER_COMP = "app/ui/main_city/component/chapter_comp" -local DAILY_CHALLENGE_COMP = "app/ui/main_city/component/daily_challenge_comp" -local DUNGEON_COMP = "app/ui/main_city/component/dungeon_comp" -local ARENA_COMP = "app/ui/main_city/component/arena_comp" +local ChapterComp = class("ChapterComp", LuaComponent) -local BOTTOM_HEIGHT = 120 +local UISpineObject = require "app/bf/unity/ui_spine_object" -function MainComp:init() +-- local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png" +local HERO_SPINE_ASSET_PATH = "assets/arts/spines/characters/%s/%s_skeletondata.asset" +local CHAPTER_PATH = "assets/arts/textures/background/main/%s.png" + +local BOX_ICON = { + "common_chest_1", + "common_chest_4" +} + +function ChapterComp:getIsOpen() + return true +end + +function ChapterComp:getEntranceName() + return I18N:getGlobalText(I18N.GlobalConst.MAIN_CHAPTER) +end + +function ChapterComp:getFightHpCost() + return DataManager.ChapterData:getFightCost() +end + +function ChapterComp:onClickFight() + ModuleManager.ChapterManager:startFight() +end + +function ChapterComp:init() self.uiMap = self:getBaseObject():genAllChildren() - self:refreshModule(ModuleManager.MaincityManager:getCurModule()) + self.chapterImg = self.uiMap["main_comp.img"] + self.chapterNameTx = self.uiMap["main_comp.name_tx"] + self.chapterWavetx = self.uiMap["main_comp.record_tx"] + self.leftArrow = self.uiMap["main_comp.left_arrow"] + local leftArrowBtn = self.uiMap["main_comp.left_arrow.btn"] + leftArrowBtn:addClickListener(function() + if DataManager.ChapterData:goLastChapter() then + self:refresh() + end + end) + self.rightArrow = self.uiMap["main_comp.right_arrow"] + local rightArrowBtn = self.uiMap["main_comp.right_arrow.btn"] + rightArrowBtn:addClickListener(function() + if DataManager.ChapterData:goNextChapter() then + self:refresh() + end + end) + + self.uiMap["main_comp.effect_node.ui_spine_obj"]:playAnim("idle", true, false) + + self.chapterBg = self.uiMap["main_comp.bg"] + self.chapterBg:setAnchoredPositionX(-720) + self.bossSmoke = self.uiMap["main_comp.boss_smoke"] + self.bossSmoke:setAnchoredPositionX(10000) + self.smokeNodeTop = self.uiMap["main_comp.smoke_node_1"] + self.monsterNodeTop = self.uiMap["main_comp.monster_node_1"] + self.bossNode = self.uiMap["main_comp.boss_node"] + self.bossNode:setActive(false) + self.bossSpine = self.uiMap["main_comp.boss_node.boss"] + self.smokeNodeDown = self.uiMap["main_comp.smoke_node_2"] + self.monsterNodeDown = self.uiMap["main_comp.monster_node_2"] + self.dialogueTx = self.uiMap["main_comp.dialogue_node.bg.text"] + self.dialogueBg = self.uiMap["main_comp.dialogue_node.bg"] + self.dialogueNode = self.uiMap["main_comp.dialogue_node"] + self.dialogueNode:setAnchoredPositionX(0) + self.monsterSpineTopPool = {} + self.monsterSpineDownPool = {} + self.monsterSpineTopList = {} + self.monsterSpineDownList = {} + -- self.monsterShadowPool = {} + self.monsterSmokePool = {} + self.startMonsterAction = true + + self.fightBtn = self.uiMap["main_comp.fight_btn"] + -- 体力消耗 + self.fightCost = self.uiMap["main_comp.fight_btn.cost"] + self.costTxDesc = self.uiMap["main_comp.fight_btn.cost.tx_desc"] + self.costTxCost = self.uiMap["main_comp.fight_btn.cost.tx_cost"] + -- 按钮文本 + self.txFight = self.uiMap["main_comp.fight_btn.tx_desc"] + self.fightBtn:addClickListener(function () + ModuleManager.ChapterManager:startFight() + end) end -function MainComp:refreshTime() - if not self.moduleMap then +function ChapterComp:refresh() + self:refreshChapter() +end + +function ChapterComp:refreshChapter(force) + local chapterId = DataManager.ChapterData:getChapterId() + if self.currChapterId ~= chapterId or force then + if DataManager.ChapterData:getIsFirstChapter(chapterId) then -- 第一章不需要左箭头 + self.leftArrow:setVisible(false) + self.rightArrow:setVisible(DataManager.ChapterData:getMaxChapterId() >= 1) + elseif chapterId == DataManager.ChapterData:getMaxChapterId() + 1 then -- 只能看打的最远的关卡 + self.leftArrow:setVisible(true) + self.rightArrow:setVisible(false) + else + self.leftArrow:setVisible(true) + self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId)) + end + + self.currChapterId = chapterId + local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] + local chapterI18NInfo = I18N:getConfig("chapter")[chapterId] + if chapterInfo then + local monsterIdList = chapterInfo.monster_id + if monsterIdList then + local bossId = monsterIdList[1] + if bossId then + local monsterCfg = ConfigManager:getConfig("monster_base") + local monsterInfo = monsterCfg[bossId] + if monsterInfo then + -- self.dialogueBg:setAnchoredPositionY(monsterInfo.blood * monsterInfo.ui/10 + 20) + end + end + end + -- main_bg_1 + -- self.chapterBg:setTexture(string.format(CHAPTER_PATH, chapterInfo.scenes_a)) end + self.chapterBg:setTexture(string.format(CHAPTER_PATH, "main_bg_1")) + end + if chapterI18NInfo then + self.chapterNameTx:setText(chapterI18NInfo.name) + end + self.chapterWavetx:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.ChapterData:getChapterMaxWave())) + + local slider = self.uiMap["main_comp.progress_bg.slider"] + if not self.boxObjs then + self.boxObjs = {} + for i = 1, 3 do + self.boxObjs[i] = { + box = self.uiMap["main_comp.progress_bg.box_" .. i], + desc = self.uiMap["main_comp.progress_bg.box_desc_" .. i], + spineObj = self.uiMap["main_comp.progress_bg.spine_node.ui_spine_obj_" .. i], + boxIcon = self.uiMap["main_comp.progress_bg.box_" .. i .. ".box_icon"] + } + end + end + + local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId) + local mysteryBoxBg = self.uiMap["main_comp.img.bg"] + mysteryBoxBg:setVisible(mysteryBoxCount > 0) + local mysteryBoxIcon = self.uiMap["main_comp.img.mystery_box_icon"] + mysteryBoxIcon:setVisible(mysteryBoxCount > 0) + if mysteryBoxCount > 0 then + local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId) + local desc = I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_2, gotCount, mysteryBoxCount) + self.uiMap["main_comp.img.mystery_box_icon.desc"]:setText(desc) + end + + local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() + if rewardChapterId > chapterId then + rewardChapterId = chapterId + end + + local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId) + local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId) + local unitValue = 1 / boxCount + local sliderValue = 0 + local lastValue = 0 + for i = 1, boxCount do + if curMaxWave < lastValue then + break + end + local maxWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, i) + local wave = math.min(curMaxWave, maxWave) + sliderValue = sliderValue + unitValue * (wave - lastValue) / (maxWave - lastValue) + lastValue = maxWave + end + slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = sliderValue + + for index, objs in ipairs(self.boxObjs) do + local show = boxCount >= index + objs.box:setActive(show) + objs.desc:setActive(show) + objs.spineObj:setVisible(false) + if show then + local needWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) + local x = 370 * (index / boxCount) + local rewards = DataManager.ChapterData:getChapterBoxRewards(rewardChapterId, index) + local num = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) + local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(rewardChapterId, index) + local icon = BOX_ICON[1] + if rewardGot then + icon = BOX_ICON[2] + end + objs.box:addClickListener(function() + if needWave <= curMaxWave and not rewardGot then + objs.spineObj:setVisible(true) + objs.spineObj:playAnimComplete("open", false, false, function() + ModuleManager.ChapterManager:openBox(rewardChapterId, index) + end) + else + ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box) + end + end) + objs.boxIcon:setSprite(GConst.ATLAS_PATH.COMMON, icon) + objs.box:setAnchoredPositionX(x) + if needWave <= curMaxWave and not rewardGot then + objs.spineObj:setVisible(true) + objs.spineObj:playAnim("idle", true, false) + objs.spineObj:setAnchoredPositionX(x) + objs.boxIcon:setVisible(false) + else + objs.spineObj:setVisible(false) + objs.boxIcon:setVisible(true) + end + objs.desc:setAnchoredPositionX(x) + if boxCount == index then + objs.desc:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_DESC_1, rewardChapterId)) + else + objs.desc:setText(num) + end + end + end + + self:refreshFightBtn() + self:doBossAction() + end + self:doChapterMove() + self:doMonsterAction() +end + +function ChapterComp:onOpen() + self.startMonsterAction = true + if self.bossNode then + self.bossNode:setAnchoredPositionX(0) + end + -- if self.bossShadow then + -- self.bossShadow:setAnchoredPositionX(0) + -- end + if self.dialogueNode then + self.dialogueNode:setAnchoredPositionX(0) + end +end + +function ChapterComp:onClose() + if self.chapterMoveSeq then + self.chapterMoveSeq:Kill() + self.chapterMoveSeq = nil + end + if self.chapterMonsterGenerateSeq then + self.chapterMonsterGenerateSeq:Kill() + self.chapterMonsterGenerateSeq = nil + end + self.currChapterId = nil + self.isTopTurn = nil + self.startMonsterAction = false + GFunc.killDOTween(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) + self.monsterSpineTopPool = {} + self.monsterSpineDownPool = {} + self.monsterSpineTopList = {} + self.monsterSpineDownList = {} + -- self.monsterShadowPool = {} + self.monsterSmokePool = {} + self.monsterNodeTop:removeAllChildren() + self.monsterNodeDown:removeAllChildren() + -- self.shadowNode:removeAllChildren() + self.smokeNodeTop:removeAllChildren() + self.smokeNodeDown:removeAllChildren() +end + +function ChapterComp:refreshFightBtn() + -- 体力消耗 + local cost = DataManager.ChapterData:getFightCost() + self.fightCost:setActive(true) + self.costTxDesc:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) + self.costTxCost:setText(GFunc.getRewardNum(cost)) +end + +-- region 动画 +function ChapterComp:doChapterMove() + if self.chapterMoveSeq then return end - if self.moduleMap[self.curModuleType] and self.moduleMap[self.curModuleType].refreshTime then - self.moduleMap[self.curModuleType]:refreshTime() + self.chapterBg:setAnchoredPositionX(-720) + self.chapterMoveSeq = self.chapterBg:createBindTweenSequence() + local moveTween = self.chapterBg:getTransform():DOAnchorPosX(720, 20):SetEase(CS.DG.Tweening.Ease.Linear) + self.chapterMoveSeq:Append(moveTween) + self.chapterMoveSeq:AppendCallback(function() + self.chapterBg:setAnchoredPositionX(-720) + end) + self.chapterMoveSeq:SetLoops(-1) +end + +function ChapterComp:doBossAction() + if self.currChapterId == nil then + return + end + local chapterInfo = ConfigManager:getConfig("chapter")[self.currChapterId] + if chapterInfo == nil then + return + end + local monsterIdList = chapterInfo.monster_id + monsterIdList = {20001, 10001, 10002} + if monsterIdList == nil then + return + end + self.chapterMonsterShowList = monsterIdList + if self.chapterBossId == nil then -- 还没显示boss模型 + self.chapterBossId = self.chapterMonsterShowList[1] + local chapterBossId = self.chapterBossId + local monsterCfg = ConfigManager:getConfig("monster_base") + local monsterInfo = monsterCfg[self.chapterBossId] + if monsterInfo then + local modelId = monsterInfo.model_id + local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId) + self.bossNode:setActive(false) + local scale = monsterInfo.ui or 1 + local shadowScale = (monsterInfo.shadow or 1) * scale + -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale + -- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale) + -- self.bossShadow:setAnchoredPosition(10000, shadowOffset) + self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) + self.bossSmoke:setAnchoredPositionX(10000) + self.bossSpine:loadAssetAsync(modelId, function() + if chapterBossId == self.chapterBossId then + self.bossNode:setActive(true) + self.bossSpine:setLocalScale(-scale, scale, scale) + self.bossSpine:playAnim("move", true, true, true) + -- self.bossShadow:setAnchoredPositionX(0) + self.bossSmoke:playAnim("idle", true, true, true) + self.bossSmoke:setAnchoredPositionX(0) + else -- 加载完成后,已经切换到其他boss了 + self:doChangeBossAction() + end + end, path) + end + else + local chapterBossId = self.chapterMonsterShowList[1] + if self.chapterBossId ~= chapterBossId then + self.chapterBossId = chapterBossId + self:doChangeBossAction() + end end end -function MainComp:refreshModule(selectModule) - if not self.moduleMap then - self.moduleMap = {} - -- 章节 - local chapterComp = self.uiMap["main_comp.chapter_comp"] - self.chapterComp = CellManager:addCellComp(chapterComp, CHAPTER_COMP) - self.chapterComp:initWithParentUI(self) - self.moduleMap[GConst.MainCityConst.MAIN_MODULE.CHAPTER] = self.chapterComp - -- 每日挑战 - local dailyChallengeComp = self.uiMap["main_comp.daily_challenge_comp"] - self.dailyChallengeComp = CellManager:addCellComp(dailyChallengeComp, DAILY_CHALLENGE_COMP) - self.dailyChallengeComp:initWithParentUI(self) - self.moduleMap[GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE] = self.dailyChallengeComp - -- 活动副本 - local dungeonComp = self.uiMap["main_comp.dungeon_comp"] - self.dungeonComp = CellManager:addCellComp(dungeonComp, DUNGEON_COMP) - self.dungeonComp:initWithParentUI(self) - self.moduleMap[GConst.MainCityConst.MAIN_MODULE.DUNGEON] = self.dungeonComp - -- 竞技场 - local arenaComp = self.uiMap["main_comp.arena_comp"] - self.arenaComp = CellManager:addCellComp(arenaComp, ARENA_COMP) - self.arenaComp:initWithParentUI(self) - self.moduleMap[GConst.MainCityConst.MAIN_MODULE.ARENA] = self.arenaComp - end - - -- 左侧活动入口 - if not self.leftEntrance then - self.leftEntrance = {} - self.leftEntrance[GConst.MainCityConst.MAIN_MODULE.CHAPTER] = self.uiMap["main_comp.left.chapter"] - self.leftEntrance[GConst.MainCityConst.MAIN_MODULE.ARENA] = self.uiMap["main_comp.left.arena"] - self.leftEntrance[GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE] = self.uiMap["main_comp.left.daily_challenge"] - end - - -- 右侧活动入口 - if not self.rightEntrance then - self.rightEntrance = {} - self.rightEntrance[GConst.MainCityConst.MAIN_MODULE.CHAPTER] = self.uiMap["main_comp.right.chapter"] - self.rightEntrance[GConst.MainCityConst.MAIN_MODULE.DUNGEON] = self.uiMap["main_comp.right.dungeon"] - end - - if self.curModuleType ~= selectModule then - self.curModuleType = selectModule - ModuleManager.MaincityManager:setCurModule(self.curModuleType) - - if self.curModuleType == GConst.MainCityConst.MAIN_MODULE.CHAPTER then - -- 切换到主线章节 - elseif self.curModuleType == GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE then - -- 切换到每日挑战 - if not DataManager.TutorialData:getIsInTutorial() and DataManager.DailyChallengeData:getIsPopTask() then - ModuleManager.DailyChallengeManager:showBattleTaskUI() +-- 切换boss +function ChapterComp:doChangeBossAction() + local chapterBossId = self.chapterBossId + local monsterCfg = ConfigManager:getConfig("monster_base") + local monsterInfo = monsterCfg[self.chapterBossId] + if monsterInfo then + local modelId = monsterInfo.model_id + local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId) + self.bossNode:setActive(false) + local scale = monsterInfo.ui or 1 + local shadowScale = (monsterInfo.shadow or 1) * scale + -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale + -- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale) + -- self.bossShadow:setAnchoredPosition(10000, shadowOffset) + self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) + self.bossSmoke:setAnchoredPositionX(10000) + self.bossSpine:loadAssetAsync(modelId, function() + if chapterBossId == self.chapterBossId then + self.bossNode:setActive(true) + self.bossSpine:setLocalScale(-scale, scale, scale) + self.bossSpine:playAnim("move", true, true, true) + -- self.bossShadow:setAnchoredPositionX(0) + self.bossSmoke:playAnim("idle", true, true, true) + self.bossSmoke:setAnchoredPositionX(0) + else -- 加载完成后,已经切换到其他boss了 + self:doChangeBossAction() end - elseif self.curModuleType == GConst.MainCityConst.MAIN_MODULE.DUNGEON then - -- 切换到活动副本 - elseif self.curModuleType == GConst.MainCityConst.MAIN_MODULE.ARENA then - -- 切换到竞技场 - ModuleManager.ArenaManager:reqArenaInfo() - end - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_COMP_MODULE, self.curModuleType) + end, path) end +end - if self.curModuleType == GConst.MainCityConst.MAIN_MODULE.ARENA then - if DataManager.ArenaData:getGiftId() then - local showType = BIReport.PAY_UI_SHOW_TYPE.ENTER_SHOW - if DataManager.ArenaData:needShowPopGift() then - showType = BIReport.PAY_UI_SHOW_TYPE.TRIGGER_POP - end - local mainUI = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI) - if mainUI and mainUI.isFirstEnter then - showType = BIReport.PAY_UI_SHOW_TYPE.LOGIN_POP - end - ModuleManager.ArenaManager:showGiftPopUI(showType) - end - local adBoxState = ModuleManager.ArenaManager:getAdBoxState() - if adBoxState ~= nil then - ModuleManager.ShopManager:showArenaAdBoxUI(adBoxState) - ModuleManager.ArenaManager:markAdBox(nil) - end - -- 是否是否有英雄解锁弹窗 - if DataManager.HeroData:getIfCanShowHeroUnlock() then - local list = DataManager.HeroData:getHeroChapterUnlockList() - DataManager.HeroData:markShowHeroUnlock() - if list and #list > 0 then - ModuleManager.HeroManager:showHeroUnlockUI(list) +function ChapterComp:doMonsterAction() + if self.chapterMonsterGenerateSeq then + return + end + self.chapterMonsterGenerateSeq = DOTweenManager:createSeqWithIntId() + local interval = GFunc.getConstValue("chapter_idel_monster_x") / 1000 + interval = 2 + self.chapterMonsterGenerateSeq:AppendCallback(function() + self:generateChapterMonsters() + end) + self.chapterMonsterGenerateSeq:AppendInterval(interval) + self.chapterMonsterGenerateSeq:SetLoops(-1) +end + +function ChapterComp:generateChapterMonsters() + local monsterId + if #self.chapterMonsterShowList <= 2 then + monsterId = self.chapterMonsterShowList[2] + else + monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)] + end + if monsterId == nil then + return + end + local monsterCfg = ConfigManager:getConfig("monster_base") + local monsterInfo = monsterCfg[monsterId] + if monsterInfo == nil then + return + end + if self.isTopTurn == nil then + self.isTopTurn = math.random(1, 100) > 50 + end + local modelId = monsterInfo.model_id + local pool + local list + local parent + local posY + if self.isTopTurn then -- 刷上面 + pool = self.monsterSpineTopPool[modelId] + list = self.monsterSpineTopList + parent = self.monsterNodeTop + posY = math.random(1, 300) + else -- 刷下面 + pool = self.monsterSpineDownPool[modelId] + list = self.monsterSpineDownList + parent = self.monsterNodeDown + posY = -math.random(1, 240) + end + self.isTopTurn = not self.isTopTurn + if pool and #pool > 0 then + local spine = table.remove(pool) + table.insert(list, spine) + spine:setActive(true) + self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) + else + SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine) + if not self.startMonsterAction then + spine:destroy() return end - end - elseif self.curModuleType == GConst.MainCityConst.MAIN_MODULE.DUNGEON then - if DataManager.TutorialData:getIsInTutorial() then - local moduleKey = DataManager.TutorialData:getTargetFuncId() - if moduleKey then - local dungeonComp = self.moduleMap[self.curModuleType] - dungeonComp:refreshShow(moduleKey) + table.insert(list, spine) + local scale = monsterInfo.ui or 1 + spine:setLocalScale(-scale, scale, scale) + self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) + end) + end +end + +function ChapterComp:doMonsterMove(modelId, spine, posY, monsterInfo, isTopTurn) + spine:playAnim("move", true, true, true) + local posX = GConst.UI_SCREEN_WIDTH / 2 + 100 + local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300 + spine:setAnchoredPosition(posX, posY) + local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) + if self.chapterMonsterSpeed == nil then + -- self.chapterMonsterSpeed = GFunc.getConstValue("chapter_idel_monstermove") + self.chapterMonsterSpeed = 150 + end + local distance = posX - targetPosX + local moveTime = distance / self.chapterMonsterSpeed + local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + seq:Append(moveTween) + + -- local monsterShadow = self:getMonsterShadow() + local scale = monsterInfo.ui or 1 + local shadowScale = (monsterInfo.shadow or 1) * scale + -- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale) + -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale + -- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset) + -- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + -- seq:Join(moveTween2) + + local monsterSmoke = self:getMonsterSmoke(isTopTurn) + monsterSmoke:setAnchoredPosition(posX, posY) + monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) + monsterSmoke:playAnim("idle", true, true, true) + local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + seq:Join(moveTween3) + + seq:AppendCallback(function() + spine:setActive(false) + -- monsterShadow:setAnchoredPositionX(10000) + -- table.insert(self.monsterShadowPool, monsterShadow) + monsterSmoke:setAnchoredPositionX(10000) + table.insert(self.monsterSmokePool, monsterSmoke) + if isTopTurn then + local pool = self.monsterSpineTopPool[modelId] + if pool == nil then + pool = {} + self.monsterSpineTopPool[modelId] = pool end - end - end - - for idx, cell in pairs(self.moduleMap) do - cell:getBaseObject():setActive(self.curModuleType == idx) - end - - self:refreshBtns() -end - -function MainComp:refreshBtns() - self:refreshFightBtn() - self:refreshLeftBtn() - self:refreshRightBtn() -end - -function MainComp:refreshFightBtn() - if self.fightBtn == nil then - self.fightBtn = self.uiMap["main_comp.fight_btn"] - -- 体力消耗 - self.fightCost = self.uiMap["main_comp.fight_btn.cost"] - self.costTxDesc = self.uiMap["main_comp.fight_btn.cost.tx_desc"] - self.costTxCost = self.uiMap["main_comp.fight_btn.cost.tx_cost"] - -- 剩余次数 - self.countTxNum = self.uiMap["main_comp.fight_btn.tx_count"] - -- 按钮文本 - self.txFight = self.uiMap["main_comp.fight_btn.tx_desc"] - end - - local moduleCell = self.moduleMap[self.curModuleType] - local isShowFight = false - - -- 体力消耗 - local cost = moduleCell:getFightHpCost() - if cost then - isShowFight = true - self.fightCost:setActive(true) - self.costTxDesc:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) - self.costTxCost:setText(GFunc.getRewardNum(cost)) - else - self.fightCost:setActive(false) - end - - -- 剩余次数 - local remainCount = moduleCell:getFightTodayRemainCount() - if remainCount >= 0 then - isShowFight = true - self.countTxNum:setActive(true) - self.countTxNum:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, remainCount)) - else - self.countTxNum:setActive(false) - end - - -- 按钮描述 - local fightDesc = moduleCell:getFightDesc() - if fightDesc then - isShowFight = true - self.txFight:setActive(true) - self.txFight:setText(fightDesc) - self.fightBtn:setSizeDelta(286, 119) - else - self.txFight:setActive(false) - self.fightBtn:setSizeDelta(334, 122) - end - - if isShowFight then - self.fightBtn:setActive(true) - self.fightBtn:addClickListener(moduleCell.onClickFight) - -- self.fightBtn:setAnchoredPositionY(self.btnPosY) - else - self.fightBtn:setActive(false) - end -end - --- 刷新左侧活动模块入口 -function MainComp:refreshLeftBtn() - local showCount = 0 - local leftIdxList = self:getCurLeftModuleIdxList() - for module, entrance in pairs(self.leftEntrance) do - if leftIdxList ~= nil and table.containValue(leftIdxList, module) then - local isShow = self:refreshModuleEntrance(entrance, module, true) - if isShow then - showCount = showCount + 1 + table.insert(pool, spine) + for k, v in ipairs(self.monsterSpineTopList) do + if v == spine then + table.remove(self.monsterSpineTopList, k) + break + end end else - entrance:setActive(false) - end - end - - if showCount >= 2 then - -- self.uiMap["main_comp.left"]:setAnchoredPositionY(self.btnPosY - 20) - table.foreach(self.leftEntrance, function(idx, entrance) - entrance:setLocalScale(0.8,0.8) - end) - else - -- self.uiMap["main_comp.left"]:setAnchoredPositionY(self.btnPosY) - table.foreach(self.leftEntrance, function(idx, entrance) - entrance:setLocalScale(1,1) - end) - end -end - --- 刷新右侧活动模块入口 -function MainComp:refreshRightBtn() - local showCount = 0 - local rightIdxList = self:getCurRightModuleIdxList() - for module, entrance in pairs(self.rightEntrance) do - if rightIdxList ~= nil and table.containValue(rightIdxList, module) then - local isShow = self:refreshModuleEntrance(entrance, module, false) - if isShow then - showCount = showCount + 1 + local pool = self.monsterSpineDownPool[modelId] + if pool == nil then + pool = {} + self.monsterSpineDownPool[modelId] = pool + end + table.insert(pool, spine) + for k, v in ipairs(self.monsterSpineDownList) do + if v == spine then + table.remove(self.monsterSpineDownList, k) + break + end end - else - entrance:setActive(false) end - end - - if showCount >= 2 then - -- self.uiMap["main_comp.right"]:setAnchoredPositionY(self.btnPosY - 20) - table.foreach(self.rightEntrance, function(idx, entrance) - entrance:setLocalScale(0.8,0.8) - end) - else - -- self.uiMap["main_comp.right"]:setAnchoredPositionY(self.btnPosY) - table.foreach(self.rightEntrance, function(idx, entrance) - entrance:setLocalScale(1,1) - end) - end -end - --- 刷新活动模块入口 -function MainComp:refreshModuleEntrance(entrance, moduleType, isLeft) - entrance:setActive(false) - local module = self.moduleMap[moduleType] - if moduleType == nil or module == nil then - return false - end - if not module:getIsOpen() then - return false - end - - entrance:setActive(true) - local uiMap = entrance:genAllChildren() - uiMap["desc"]:setText(module:getEntranceName()) - -- 竞技场图标显示特殊处理 - if moduleType == GConst.MainCityConst.MAIN_MODULE.ARENA then - local curId = DataManager.ArenaData:getGradingId() - uiMap["img_num"]:setSprite(GConst.ATLAS_PATH.ARENA, DataManager.ArenaData:getGradingNumName(curId)) - uiMap["icon"]:setSprite(GConst.ATLAS_PATH.ARENA, DataManager.ArenaData:getGradingIconName(curId)) - end - - if module:getShowEntranceRedPoint() then - if isLeft then - entrance:addRedPoint(65, 35, 0.6) - else - entrance:addRedPoint(-65, 35, 0.6) - end - else - entrance:removeRedPoint() - end - entrance:addClickListener(function() - self:refreshModule(moduleType) end) - return true end --- 获取当前左侧活动type list -function MainComp:getCurLeftModuleIdxList() - if self.curModuleType < GConst.MainCityConst.MAIN_MODULE.CHAPTER then - return nil - end +function ChapterComp:enterChapterBattle() + -- boss等一会再跑 + local bossWaitTime = GFunc.getConstValue("chapter_fight_bosswait") / 1000 + local bossSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) + bossSeq:AppendInterval(bossWaitTime) + local bossSpeed = GFunc.getConstValue("chapter_fight_bossmove") + local distance = GConst.UI_SCREEN_WIDTH/2 + 100 + local moveTime = distance / bossSpeed + local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300 + local moveTween = self.bossNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + bossSeq:Append(moveTween) + local moveTween2 = self.dialogueNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + bossSeq:Join(moveTween2) + -- local moveTween3 = self.bossShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + -- bossSeq:Join(moveTween3) - local leftIdx = {} - if self.curModuleType == GConst.MainCityConst.MAIN_MODULE.CHAPTER then - for module, idx in pairs(GConst.MainCityConst.MAIN_MODULE) do - if idx < GConst.MainCityConst.MAIN_MODULE.CHAPTER then - table.insert(leftIdx, idx) + + -- 出来一批小怪从右边跑向左边 + local monsterCount = GFunc.getConstIntValue("chapter_fight_monster_num") + self.chapterFightMonsterCount = monsterCount + local wave = 5 + local monsterCountPerWave = math.ceil(monsterCount / wave) + -- 分批处理 + local monsterSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) + for i = 1, wave do + monsterSeq:AppendCallback(function () + if monsterCountPerWave > monsterCount then + monsterCountPerWave = monsterCount + end + monsterCount = monsterCount - monsterCountPerWave + for j = 1, monsterCountPerWave do + self:generateChapterFightMonsters() + end + end) + monsterSeq:AppendInterval(0.03) + end + return GFunc.getConstValue("chapter_fight_wait") / 1000 +end + +function ChapterComp:generateChapterFightMonsters() + local monsterId + if #self.chapterMonsterShowList <= 2 then + monsterId = self.chapterMonsterShowList[2] + else + monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)] + end + if monsterId == nil then + return + end + local monsterCfg = ConfigManager:getConfig("monster_base") + local monsterInfo = monsterCfg[monsterId] + if monsterInfo == nil then + return + end + local modelId = monsterInfo.model_id + local pool + local list + local parent + local posY + if self.isTopTurn then -- 刷上面 + pool = self.monsterSpineTopPool[modelId] + list = self.monsterSpineTopList + parent = self.monsterNodeTop + posY = math.random(1, 300) + else -- 刷下面 + pool = self.monsterSpineDownPool[modelId] + list = self.monsterSpineDownList + parent = self.monsterNodeDown + posY = -math.random(1, 240) + end + self.isTopTurn = not self.isTopTurn + if pool and #pool > 0 then + local spine = table.remove(pool) + table.insert(list, spine) + spine:setActive(true) + self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) + else + SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine) + if not self.startMonsterAction then + spine:destroy() + return + end + table.insert(list, spine) + local scale = monsterInfo.ui or 1 + spine:setLocalScale(-scale, scale, scale) + self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn) + end) + end +end + +function ChapterComp:doMonsterFightMove(modelId, spine, posY, monsterInfo, isTopTurn) + spine:playAnim("move", true, true, true) + local posX = GConst.UI_SCREEN_WIDTH / 2 + math.random(100, math.floor(GConst.UI_SCREEN_WIDTH*2/3)) + spine:setAnchoredPosition(posX, posY) + local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER) + if self.chapterMonsterFightSpeed == nil then + -- self.chapterMonsterFightSpeed = GFunc.getConstValue("chapter_fight_monstermove") + self.chapterMonsterFightSpeed = 880 + end + local distance = posX + GConst.UI_SCREEN_WIDTH/2 + 100 + local moveTime = distance / self.chapterMonsterFightSpeed + local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 100 + local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + seq:Append(moveTween) + + -- local monsterShadow = self:getMonsterShadow() + local scale = monsterInfo.ui or 1 + local shadowScale = (monsterInfo.shadow or 1) * scale + -- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale) + -- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale + -- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset) + -- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + -- seq:Join(moveTween2) + + local monsterSmoke = self:getMonsterSmoke(isTopTurn) + monsterSmoke:setAnchoredPosition(posX, posY) + monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale) + monsterSmoke:playAnim("idle", true, true, true) + local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear) + seq:Join(moveTween3) + + seq:AppendCallback(function() + spine:setActive(false) + -- monsterShadow:setAnchoredPositionX(10000) + -- table.insert(self.monsterShadowPool, monsterShadow) + monsterSmoke:setAnchoredPositionX(10000) + table.insert(self.monsterSmokePool, monsterSmoke) + if isTopTurn then + local pool = self.monsterSpineTopPool[modelId] + if pool == nil then + pool = {} + self.monsterSpineTopPool[modelId] = pool + end + table.insert(pool, spine) + for k, v in ipairs(self.monsterSpineTopList) do + if v == spine then + table.remove(self.monsterSpineTopList, k) + break + end + end + else + local pool = self.monsterSpineDownPool[modelId] + if pool == nil then + pool = {} + self.monsterSpineDownPool[modelId] = pool + end + table.insert(pool, spine) + for k, v in ipairs(self.monsterSpineDownList) do + if v == spine then + table.remove(self.monsterSpineDownList, k) + break + end end end - table.sort(leftIdx, function(a, b) - return math.abs(a) < math.abs(b) - end) - else - table.insert(leftIdx, GConst.MainCityConst.MAIN_MODULE.CHAPTER) - end + end) - return leftIdx -end - --- 获取当前右侧活动type list -function MainComp:getCurRightModuleIdxList() - if self.curModuleType > GConst.MainCityConst.MAIN_MODULE.CHAPTER then - return nil - end - - local rightIdx = {} - if self.curModuleType == GConst.MainCityConst.MAIN_MODULE.CHAPTER then - for module, idx in pairs(GConst.MainCityConst.MAIN_MODULE) do - if idx > GConst.MainCityConst.MAIN_MODULE.CHAPTER then - table.insert(rightIdx, idx) - end - end - table.sort(rightIdx, function(a, b) - return math.abs(a) < math.abs(b) - end) - else - table.insert(rightIdx, GConst.MainCityConst.MAIN_MODULE.CHAPTER) - end - - return rightIdx -end - -function MainComp:refresh() - self:refreshChallenge() - self:refreshDungeon() - self:refreshArena() -end - -function MainComp:onClose() - for type, cell in pairs(self.moduleMap) do - if cell.onClose then - cell:onClose() + if self.chapterFightMonsterCount then + self.chapterFightMonsterCount = self.chapterFightMonsterCount - 1 + if self.chapterFightMonsterCount == 0 then -- 最后一个怪物生成完毕后,重新排一下序 + self:sortChapterFightMonstersOrder() + self:sortChapterFightMonstersOrder() + self:sortChapterFightMonstersOrder() + self:sortChapterFightMonstersOrder() end end end -function MainComp:getCurModuleType() - return self.curModuleType +function ChapterComp:sortChapterFightMonstersOrder() + self:sortChildrenOrder(self.monsterNodeTop) + self:sortChildrenOrder(self.monsterNodeDown) + self:sortChildrenOrder(self.smokeNodeTop) + self:sortChildrenOrder(self.smokeNodeDown) end -function MainComp:getCurModule() - return self.moduleMap[self.curModuleType] -end +function ChapterComp:sortChildrenOrder(parent) + local children = parent:getChildList() + if children and #children > 0 then + table.sort(children, function(a, b) + return a:getAnchoredPositionY() > b:getAnchoredPositionY() + end) -function MainComp:refreshChapter(force) - self.chapterComp:refreshChapter(force) -end - -function MainComp:refreshChallenge() - self:refreshBtns() - self.dailyChallengeComp:refreshShow() -end - -function MainComp:refreshDungeon() - self:refreshBtns() - self.dungeonComp:refreshShow() -end - -function MainComp:refreshArena() - self:refreshBtns() - self.arenaComp:refreshShow() -end - -function MainComp:getDailyChallengeIconPos() - local idx = table.indexof(self:getCurLeftModuleIdxList(), GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE) - if idx and self.leftEntrance[idx] then - return self.leftEntrance[idx]:getPosition() - end - idx = table.indexof(self:getCurRightModuleIdxList(), GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE) - if idx and self.rightEntrance[idx] then - return self.rightEntrance[idx]:getPosition() + for i = #children, 1, -1 do + children[i]:getTransform():SetSiblingIndex(i - 1) + end end end -function MainComp:getLeftOrRightEntrancePos(module) - if self.leftEntrance[module] then - return self.leftEntrance[module]:getPosition() - end - if self.rightEntrance[module] then - return self.rightEntrance[module]:getPosition() +function ChapterComp:getMonsterSmoke(isTop) + local monsterSmoke + if #self.monsterSmokePool > 0 then + monsterSmoke = table.remove(self.monsterSmokePool) + monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false) + else + local shadowObj = CS.UnityEngine.Object.Instantiate(self.bossSmoke:getGameObject()) + monsterSmoke = UISpineObject:create() + monsterSmoke:initWithPrefab(GConst.EMPTY_STRING, shadowObj) + monsterSmoke:getAnimationState() + monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false) end + return monsterSmoke end +-- endregion -function MainComp:refreshArenaBounty() - if self.arenaComp then - self.arenaComp:refreshBounty() - end -end - -return MainComp \ No newline at end of file +return ChapterComp \ No newline at end of file diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index a62f2631..b9b53c51 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -16,7 +16,7 @@ local BOTTOM_BTN_CELL = "app/ui/main_city/cell/bottom_btn_cell" MainCityUI.CLICK_BTN_TYPE = { [1] = "HOME", [2] = "HERO", - [3] = "SHOP", + [3] = "SHOP", } function MainCityUI:getUIType() @@ -24,701 +24,696 @@ function MainCityUI:getUIType() end function MainCityUI:getBGMId() - return AudioManager.BGM_ID.MAINCITY + return AudioManager.BGM_ID.MAINCITY end function MainCityUI:getCurrencyParams() - if self.currencyParams == nil then - self.currencyParams = { - itemIds = {} - } - end + if self.currencyParams == nil then + self.currencyParams = { + itemIds = {} + } + end self.selectedIndex = self.selectedIndex or GConst.MainCityConst.BOTTOM_PAGE.MAIN - self.currencyParams.showType = GConst.CURRENCY_TYPE.HORIZONTAL - for k, v in ipairs(self.currencyParams.itemIds) do - table.remove(self.currencyParams.itemIds) - end + self.currencyParams.showType = GConst.CURRENCY_TYPE.HORIZONTAL + for k, v in ipairs(self.currencyParams.itemIds) do + table.remove(self.currencyParams.itemIds) + end if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - if self.mainComp and self.mainComp:getCurModuleType() == GConst.MainCityConst.MAIN_MODULE.ARENA then - self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GEM - self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_ARENA_TICKET - else - self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD - self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GEM - self.currencyParams.itemIds[3] = GConst.ItemConst.ITEM_ID_VIT - end + self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD + self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GEM + self.currencyParams.itemIds[3] = GConst.ItemConst.ITEM_ID_VIT elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then - self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD - self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_VIT - elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP then - self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD - self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GEM - self.currencyParams.itemIds[3] = GConst.ItemConst.ITEM_ID_VIT + self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD + self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_VIT + elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP then + self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD + self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GEM + self.currencyParams.itemIds[3] = GConst.ItemConst.ITEM_ID_VIT end return self.currencyParams end function MainCityUI:onPressBackspace() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - local params = { - content = I18N:getGlobalText(I18N.GlobalConst.CONF_BE_SURE_QUIT_GAME), - okFunc = function() - CS.UnityEngine.Application.Quit() - end, - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, - } - GFunc.showMessageBox(params) - end + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + local params = { + content = I18N:getGlobalText(I18N.GlobalConst.CONF_BE_SURE_QUIT_GAME), + okFunc = function() + CS.UnityEngine.Application.Quit() + end, + boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, + } + GFunc.showMessageBox(params) + end end function MainCityUI:getPrefabPath() - return "assets/prefabs/ui/main_city/main_ui.prefab" + return "assets/prefabs/ui/main_city/main_ui.prefab" end function MainCityUI:ctor(params) - self.isFirstEnter = params and params.isFirstEnter - self.targetIndex = params and params.targetIndex + self.isFirstEnter = params and params.isFirstEnter + self.targetIndex = params and params.targetIndex - print("当前 Lua 版本: ", _VERSION) -- 输出:Lua 5.1 + print("当前 Lua 版本: ", _VERSION) -- 输出:Lua 5.1 end function MainCityUI:onLoadRootComplete() - local uiMap = self.root:genAllChildren() - self.uiMap = uiMap - self.bottomBgSelected = uiMap["main_ui.bottom_node.bottom_bg_selected"] - self.bottomBgSelected:setLocalPositionX(0) + local uiMap = self.root:genAllChildren() + self.uiMap = uiMap + self.bottomBgSelected = uiMap["main_ui.bottom_node.bottom_bg_selected"] + self.bottomBgSelected:setLocalPositionX(0) - self:_display() - self:_addListeners() - self:_bind() - self:refreshBottomRp() + self:_display() + self:_addListeners() + self:_bind() + self:refreshBottomRp() - self:updateTime() + self:updateTime() self:scheduleGlobal(function() - self:updateSideBarStatus() - self:updateTime() + self:updateSideBarStatus() + self:updateTime() end, 1) end function MainCityUI:onRefresh() - self:refreshAllSideBars() - self:refreshSettingBtn() + self:refreshAllSideBars() + self:refreshSettingBtn() end function MainCityUI:onClose() - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:onClose() - self.subComps = nil + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:onClose() + self.subComps = nil end function MainCityUI:refreshAllSideBars() - self:refreshLeftBtns() - self:refreshRightBtns() - self:updateSideBarStatus() + self:refreshLeftBtns() + self:refreshRightBtns() + self:updateSideBarStatus() end function MainCityUI:onReshow() - self:checkMainPop() - self:checkSideBarOpenStatus() + self:checkMainPop() + self:checkSideBarOpenStatus() end function MainCityUI:onSetUIOrder() - if self.subComps then - for index, comp in pairs(self.subComps) do - local order = self._baseRootCanvas.sortingOrder - local uiHelper = comp:getGameObject():GetComponent(BF_UI_HELPER) - if uiHelper then - uiHelper:SetSortingOrder(order + 1) - end - end - end + if self.subComps then + for index, comp in pairs(self.subComps) do + local order = self._baseRootCanvas.sortingOrder + local uiHelper = comp:getGameObject():GetComponent(BF_UI_HELPER) + if uiHelper then + uiHelper:SetSortingOrder(order + 1) + end + end + end end function MainCityUI:_display() - self:initBottomUI() - self:initComp() - self:initLeftRightBtns() - self:initTopNode() - self:refreshBottom() + self:initBottomUI() + self:initComp() + self:initLeftRightBtns() + self:initTopNode() + self:refreshBottom() end function MainCityUI:_addListeners() - self:addEventListener(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL, function() + self:addEventListener(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL, function() local time = math.random(10000, 30000) / 20000 ModuleManager.MailManager:performWithDelayGlobal(function() ModuleManager.MailManager:getTriggeredTimeMail() end, time) end) - -- self:addEventListener(EventManager.CUSTOM_EVENT.TUTORIAL_TASK_STOP, function() - -- -- 引导完成时 检测主界面的弹窗是否要触发 - -- if not self:checkTutorial(true) then - -- self:checkGift() - -- end - -- end) - self:addEventListener(EventManager.CUSTOM_EVENT.GO_SHOP, function(params) - if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, false) then - local page = params and params.page or GConst.ShopConst.PAGE_TYPE.MAIN -- 默认主要商品 - local subType = params.subType - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP then - if self.subComps and self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(page) - if page == GConst.ShopConst.PAGE_TYPE.MAIN and subType then - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:goSubType(subType) - end - end - return - end - self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:playAnimComplete("born1", false, false, function() - self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:playAnimComplete("born2", false, false, function() - self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:playAnim("idle", false, false) - end) - end) - self:refreshBottom(GConst.MainCityConst.BOTTOM_PAGE.SHOP, true) - if self.subComps and self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(page) - if page == GConst.ShopConst.PAGE_TYPE.MAIN and subType then - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:goSubType(subType) - end - end - end - end) + -- self:addEventListener(EventManager.CUSTOM_EVENT.TUTORIAL_TASK_STOP, function() + -- -- 引导完成时 检测主界面的弹窗是否要触发 + -- if not self:checkTutorial(true) then + -- self:checkGift() + -- end + -- end) + self:addEventListener(EventManager.CUSTOM_EVENT.GO_SHOP, function(params) + if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, false) then + local page = params and params.page or GConst.ShopConst.PAGE_TYPE.MAIN -- 默认主要商品 + local subType = params.subType + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP then + if self.subComps and self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(page) + if page == GConst.ShopConst.PAGE_TYPE.MAIN and subType then + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:goSubType(subType) + end + end + return + end + self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:playAnimComplete("born1", false, false, function() + self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:playAnimComplete("born2", false, false, function() + self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:playAnim("idle", false, false) + end) + end) + self:refreshBottom(GConst.MainCityConst.BOTTOM_PAGE.SHOP, true) + if self.subComps and self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] then + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:switchPage(page) + if page == GConst.ShopConst.PAGE_TYPE.MAIN and subType then + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:goSubType(subType) + end + end + end + end) - self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_COMP_MODULE, function(module) - self:switchMainCompModule(module) - end) + self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_COMP_MODULE, function(module) + self:switchMainCompModule(module) + end) - self:addEventListener(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_SIDE_BAR, function(module) - self:checkSideBarOpenStatus() - end) - DataManager.MailData:checkNewMail() + self:addEventListener(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_SIDE_BAR, function(module) + self:checkSideBarOpenStatus() + end) + DataManager.MailData:checkNewMail() end function MainCityUI:_bind() - self:bind(DataManager.ChapterData, "isDirty", function() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refreshChapter(true) - end - end - end, true) - self:bind(DataManager.PlayerData, "dirty", function(binder, value) - self:refreshPlayerInfo() - end, true) - self:bind(DataManager.FormationData, "dirty", function(binder, value) - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then - self.subComps[self.selectedIndex]:refresh(GConst.BattleConst.BATTLE_TYPE.STAGE) - end - end) + self:bind(DataManager.ChapterData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refreshChapter(true) + end + end + end, true) + self:bind(DataManager.PlayerData, "dirty", function(binder, value) + self:refreshPlayerInfo() + end, true) + self:bind(DataManager.FormationData, "dirty", function(binder, value) + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then + self.subComps[self.selectedIndex]:refresh(GConst.BattleConst.BATTLE_TYPE.STAGE) + end + end) self:bind(DataManager.HeroData, "isDirty", function(binder, value) - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refresh(GConst.BattleConst.BATTLE_TYPE.STAGE) - end - end - self:refreshBottomRp() - end) - - self:bind(DataManager.CollectionData, "isDirty", function() - self:refreshBottomRp() - end) - - self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value) - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN and self.subComps[self.selectedIndex] then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refreshBtns() - end - end - end) - - self:bind(DataManager.DailyTaskData, "redPointFlag", function() - self:refreshTask() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refresh(GConst.BattleConst.BATTLE_TYPE.STAGE) + end + end + self:refreshBottomRp() end) - self:bind(DataManager.BountyData, "dirty", function() - self:refreshBounty() - end) - self:bind(DataManager.ArenaBountyData, "dirty", function() - self:refreshArenaBounty() + self:bind(DataManager.CollectionData, "isDirty", function() + self:refreshBottomRp() end) - self:bind(DataManager.MailData, "redPoint", function() - self:refreshSettingBtn() + self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value) + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN and self.subComps[self.selectedIndex] then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refreshBtns() + end + end end) - self:bind(DataManager.ShopData, "isDirty", function() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP and self.subComps[self.selectedIndex] then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refresh() - end - end - self:refreshBottomRp() - end) - self:bind(DataManager.SummonData, "isDirty", function() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP and self.subComps[self.selectedIndex] then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refresh() - end - end - end) + self:bind(DataManager.DailyTaskData, "redPointFlag", function() + self:refreshTask() + end) - self:bind(DataManager.DailyChallengeData, "isDirty", function() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refreshChallenge() - end - end - end) + self:bind(DataManager.BountyData, "dirty", function() + self:refreshBounty() + end) + self:bind(DataManager.ArenaBountyData, "dirty", function() + self:refreshArenaBounty() + end) - self:bind(DataManager.DungeonData, "isDirty", function() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refreshDungeon() - end - end - end) + self:bind(DataManager.MailData, "redPoint", function() + self:refreshSettingBtn() + end) - self:bind(DataManager.ArenaData, "isDirty", function() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refreshArena() - end - end - end) + self:bind(DataManager.ShopData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP and self.subComps[self.selectedIndex] then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refresh() + end + end + self:refreshBottomRp() + end) + self:bind(DataManager.SummonData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP and self.subComps[self.selectedIndex] then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refresh() + end + end + end) - self:bind(DataManager.AIHelperData, "isDirty", function() - self:refreshSettingBtn() + self:bind(DataManager.DailyChallengeData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refreshChallenge() + end + end + end) + + self:bind(DataManager.DungeonData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refreshDungeon() + end + end + end) + + self:bind(DataManager.ArenaData, "isDirty", function() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + if self.subComps[self.selectedIndex] then + self.subComps[self.selectedIndex]:refreshArena() + end + end + end) + + self:bind(DataManager.AIHelperData, "isDirty", function() + self:refreshSettingBtn() end) end function MainCityUI:initBottomUI() - local uiMap = self.root:genAllChildren() - self.bottomBtnCells = {} - self.bottomBtnSpines = {} - for i = 1, 5 do - local cellCom = CellManager:addCellComp(uiMap["main_ui.bottom_node.bottom_btn_cell_" .. i], BOTTOM_BTN_CELL) - cellCom:addClickListener(function() - if i == 1 then -- 商城有开启条件 - if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, false) then - return - end - end - if self.selectedIndex == i then - return - end + local uiMap = self.root:genAllChildren() + self.bottomBtnCells = {} + self.bottomBtnSpines = {} + for i = 1, 5 do + local cellCom = CellManager:addCellComp(uiMap["main_ui.bottom_node.bottom_btn_cell_" .. i], BOTTOM_BTN_CELL) + cellCom:addClickListener(function() + if i == 1 then -- 商城有开启条件 + if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, false) then + return + end + end + if self.selectedIndex == i then + return + end - if i <= #MainCityUI.CLICK_BTN_TYPE then - BIReport:postHomeBtnCilck(BIReport.CLICK_BTN_TYPE[MainCityUI.CLICK_BTN_TYPE[i]]) - end + if i <= #MainCityUI.CLICK_BTN_TYPE then + BIReport:postHomeBtnCilck(BIReport.CLICK_BTN_TYPE[MainCityUI.CLICK_BTN_TYPE[i]]) + end - -- self.bottomBtnSpines[i]:playAnimComplete("born1", false, false, function() - -- self.bottomBtnSpines[i]:playAnimComplete("born2", false, false, function() - -- self.bottomBtnSpines[i]:playAnim("idle", false, false) - -- end) - -- end) - self:refreshBottom(i, true) - end) - table.insert(self.bottomBtnCells, cellCom) + -- self.bottomBtnSpines[i]:playAnimComplete("born1", false, false, function() + -- self.bottomBtnSpines[i]:playAnimComplete("born2", false, false, function() + -- self.bottomBtnSpines[i]:playAnim("idle", false, false) + -- end) + -- end) + self:refreshBottom(i, true) + end) + table.insert(self.bottomBtnCells, cellCom) - self.bottomBtnSpines[i] = uiMap["main_ui.bottom_node.icons.ui_spine_obj_" .. i] - self.bottomBtnSpines[i]:playAnim("idle", false, false) - end + self.bottomBtnSpines[i] = uiMap["main_ui.bottom_node.icons.ui_spine_obj_" .. i] + self.bottomBtnSpines[i]:playAnim("idle", false, false) + end end function MainCityUI:initComp() - if not self.subComps then - local uiMap = self.root:genAllChildren() - self.subComps = {} + if not self.subComps then + local uiMap = self.root:genAllChildren() + self.subComps = {} -- 主城 - local mainComp = uiMap["main_ui.sub_ui_node.main_comp"] - mainComp:initPrefabHelper() - mainComp:genAllChildren() + local mainComp = uiMap["main_ui.sub_ui_node.main_comp"] + mainComp:initPrefabHelper() + mainComp:genAllChildren() self.mainComp = mainComp:addLuaComponent(MAIN_COMP) - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN] = self.mainComp - -- 英雄 - local heroComp = uiMap["main_ui.sub_ui_node.hero_ui"] - heroComp:initPrefabHelper() - heroComp:genAllChildren() - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.HERO] = heroComp:addLuaComponent(HERO_COMP) - self:onSetUIOrder() - -- 商城 - local shopComp = uiMap["main_ui.sub_ui_node.shop_comp"] - shopComp:initPrefabHelper() - shopComp:genAllChildren() - self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] = shopComp:addLuaComponent(SHOP_COMP) - end + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN] = self.mainComp + -- 英雄 + local heroComp = uiMap["main_ui.sub_ui_node.hero_ui"] + heroComp:initPrefabHelper() + heroComp:genAllChildren() + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.HERO] = heroComp:addLuaComponent(HERO_COMP) + self:onSetUIOrder() + -- 商城 + local shopComp = uiMap["main_ui.sub_ui_node.shop_comp"] + shopComp:initPrefabHelper() + shopComp:genAllChildren() + self.subComps[GConst.MainCityConst.BOTTOM_PAGE.SHOP] = shopComp:addLuaComponent(SHOP_COMP) + end end function MainCityUI:refreshBottom(selectedIndex, playAnim) - if self.targetIndex then - selectedIndex = self.targetIndex - playAnim = true - self.targetIndex = nil - end + if self.targetIndex then + selectedIndex = self.targetIndex + playAnim = true + self.targetIndex = nil + end - if selectedIndex and (not self.subComps[selectedIndex]) then - return - end - local oldIndex = self.selectedIndex - self.selectedIndex = selectedIndex and selectedIndex or GConst.MainCityConst.BOTTOM_PAGE.MAIN - self:switchComp() + if selectedIndex and (not self.subComps[selectedIndex]) then + return + end + local oldIndex = self.selectedIndex + self.selectedIndex = selectedIndex and selectedIndex or GConst.MainCityConst.BOTTOM_PAGE.MAIN + self:switchComp() - if oldIndex ~= selectedIndex then - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, self.selectedIndex) - end + if oldIndex ~= selectedIndex then + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, self.selectedIndex) + end - -- 动效 - if playAnim and (oldIndex ~= selectedIndex) then - local targetX = self.bottomBtnCells[self.selectedIndex]:getCurLocalPosX() - local isLeft = self.selectedIndex < oldIndex - local offset = isLeft and -20 or 20 - GFunc.goTargetPosXShake(self.bottomBgSelected, nil, targetX, offset) - self:refreshBottomCell(true) - else - self:refreshBottomCell(false) - end + -- 动效 + if playAnim and (oldIndex ~= selectedIndex) then + local targetX = self.bottomBtnCells[self.selectedIndex]:getCurLocalPosX() + local isLeft = self.selectedIndex < oldIndex + local offset = isLeft and -20 or 20 + GFunc.goTargetPosXShake(self.bottomBgSelected, nil, targetX, offset) + self:refreshBottomCell(true) + else + self:refreshBottomCell(false) + end end function MainCityUI:refreshBottomCell(showAni) - for i, cell in ipairs(self.bottomBtnCells) do - cell:refresh(i, i == self.selectedIndex, showAni) - end + for i, cell in ipairs(self.bottomBtnCells) do + cell:refresh(i, i == self.selectedIndex, showAni) + end end function MainCityUI:initLeftRightBtns() - self.leftNode = self.uiMap["main_ui.left_node"] - self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"] - self.leftSideBar:setAnchorMin(0, 1) - self.leftSideBar:setAnchorMax(0, 1) - self.leftSideBar:getTransform().pivot = BF.Vector2(0, 1) - local addY = SafeAreaManager:getNotchScreenHeight() - self.leftSideBar:setAnchoredPosition(17, -280 - addY) - self.leftArrowBtn = self.uiMap["main_ui.left_node.arrow_node"] - self.leftArrowBtn:setAnchorMin(0, 1) - self.leftArrowBtn:setAnchorMax(0, 1) - self.leftArrowBtn:addClickListener(function() - self:openOrCloseLeftSideBar() - end) - self.leftArrowImg = self.uiMap["main_ui.left_node.arrow_node.arrow"] + self.leftNode = self.uiMap["main_ui.left_node"] + self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"] + self.leftSideBar:setAnchorMin(0, 1) + self.leftSideBar:setAnchorMax(0, 1) + self.leftSideBar:getTransform().pivot = BF.Vector2(0, 1) + local addY = SafeAreaManager:getNotchScreenHeight() + self.leftSideBar:setAnchoredPosition(17, -280 - addY) + self.leftArrowBtn = self.uiMap["main_ui.left_node.arrow_node"] + self.leftArrowBtn:setAnchorMin(0, 1) + self.leftArrowBtn:setAnchorMax(0, 1) + self.leftArrowBtn:addClickListener(function() + self:openOrCloseLeftSideBar() + end) + self.leftArrowImg = self.uiMap["main_ui.left_node.arrow_node.arrow"] - self.rightNode = self.uiMap["main_ui.right_node"] - self.rightSideBar = self.uiMap["main_ui.right_node.side_bar"] - self.rightSideBar:setAnchorMin(1, 1) - self.rightSideBar:setAnchorMax(1, 1) - self.rightSideBar:getTransform().pivot = BF.Vector2(1, 1) - self.rightSideBar:setAnchoredPosition(-17, -280 - addY) - self.rightArrowBtn = self.uiMap["main_ui.right_node.arrow_node"] - self.rightArrowBtn:setAnchorMin(1, 1) - self.rightArrowBtn:setAnchorMax(1, 1) - self.rightArrowBtn:addClickListener(function() - self:openOrCloseRightSideBar() - end) - self.rightArrowImg = self.uiMap["main_ui.right_node.arrow_node.arrow"] + self.rightNode = self.uiMap["main_ui.right_node"] + self.rightSideBar = self.uiMap["main_ui.right_node.side_bar"] + self.rightSideBar:setAnchorMin(1, 1) + self.rightSideBar:setAnchorMax(1, 1) + self.rightSideBar:getTransform().pivot = BF.Vector2(1, 1) + self.rightSideBar:setAnchoredPosition(-17, -280 - addY) + self.rightArrowBtn = self.uiMap["main_ui.right_node.arrow_node"] + self.rightArrowBtn:setAnchorMin(1, 1) + self.rightArrowBtn:setAnchorMax(1, 1) + self.rightArrowBtn:addClickListener(function() + self:openOrCloseRightSideBar() + end) + self.rightArrowImg = self.uiMap["main_ui.right_node.arrow_node.arrow"] - self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_cell"] - local w, h = self.sideBarCellObject:fastGetSizeDelta() - self.sideBarHeight = h - self.sideBarMaxCount = 4 - if self.leftBarList == nil then - self.leftBarList = {} - end - if self.rightBarList == nil then - self.rightBarList = {} - end - if self.sideBarClassMap == nil then - self.sideBarClassMap = {} - end - if self.sideBarCellMap == nil then - self.sideBarCellMap = {} - end - self:recycleSideBarCells(self.leftSideBar) - self:recycleSideBarCells(self.rightSideBar) + self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_cell"] + local w, h = self.sideBarCellObject:fastGetSizeDelta() + self.sideBarHeight = h + self.sideBarMaxCount = 4 + if self.leftBarList == nil then + self.leftBarList = {} + end + if self.rightBarList == nil then + self.rightBarList = {} + end + if self.sideBarClassMap == nil then + self.sideBarClassMap = {} + end + if self.sideBarCellMap == nil then + self.sideBarCellMap = {} + end + self:recycleSideBarCells(self.leftSideBar) + self:recycleSideBarCells(self.rightSideBar) end function MainCityUI:recycleSideBarCells(list) - local childList = list:getChildList() - if childList and #childList > 0 then - local count = #childList - for i = count, 1, -1 do - local child = childList[i] - local name = child:getName() - if name and name ~= "" then - child:setVisible(false) - self.sideBarCellMap[name] = child:getLuaComponent(name) - else - child:destroy() - table.remove(childList, i) - end - end - end + local childList = list:getChildList() + if childList and #childList > 0 then + local count = #childList + for i = count, 1, -1 do + local child = childList[i] + local name = child:getName() + if name and name ~= "" then + child:setVisible(false) + self.sideBarCellMap[name] = child:getLuaComponent(name) + else + child:destroy() + table.remove(childList, i) + end + end + end end function MainCityUI:addSideBarCellComp(cellClassPath) - local prefab = CS.UnityEngine.Object.Instantiate(self.sideBarCellObject:getGameObject()) - local prefabObject = UIPrefabObject:create() - prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) - prefabObject:initPrefabHelper() - prefabObject:genAllChildren() - prefabObject:setName(cellClassPath) - return prefabObject:addLuaComponent(cellClassPath) + local prefab = CS.UnityEngine.Object.Instantiate(self.sideBarCellObject:getGameObject()) + local prefabObject = UIPrefabObject:create() + prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) + prefabObject:initPrefabHelper() + prefabObject:genAllChildren() + prefabObject:setName(cellClassPath) + return prefabObject:addLuaComponent(cellClassPath) end function MainCityUI:openOrCloseLeftSideBar() - ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose() - if self.isShowLeftSideBarArrowRedPoint ~= nil then - local isShowLeftSideBarArrowRedPoint = self.isShowLeftSideBarArrowRedPoint - self.isShowLeftSideBarArrowRedPoint = nil - self:setLeftSideBarArrowRedPoint(isShowLeftSideBarArrowRedPoint) - end + ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose() + if self.isShowLeftSideBarArrowRedPoint ~= nil then + local isShowLeftSideBarArrowRedPoint = self.isShowLeftSideBarArrowRedPoint + self.isShowLeftSideBarArrowRedPoint = nil + self:setLeftSideBarArrowRedPoint(isShowLeftSideBarArrowRedPoint) + end end function MainCityUI:refreshLeftBtns() - self:clearSideBarList(self.leftBarList) - local list = GConst.MainCityConst.LEFT_SIDE_BARS - if #list <= 0 then - return - end - local isClose = ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose() - for k, v in ipairs(list) do - local CellClass = self.sideBarClassMap[v] - if CellClass == nil then - CellClass = require(v) - self.sideBarClassMap[v] = CellClass - end - if CellClass:checkIsOpen() then - local cell = self.sideBarCellMap[v] - if cell == nil then - cell = self:addSideBarCellComp(v) - cell:getBaseObject():setParent(self.leftSideBar, false) - cell:getBaseObject():setAnchorMin(0, 1) - cell:getBaseObject():setAnchorMax(0, 1) - end - cell:initWithParentUI(self, v, true) - table.insert(self.leftBarList, cell) - end - end - local sideBarShowCount = #self.leftBarList - if sideBarShowCount <= 0 then - self.leftNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) - return - end - self.leftNode:setAnchoredPositionX(0) - local y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - local x = 60 - local maxCount = self.sideBarMaxCount - local minY = y - local bgSizeX = 112 - local otherColumn = false - if isClose then -- 只显示3个 - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.leftBarList[i] - if i <= sideBarShowCount then - sideBarBtn:setAnchoredPositionX(x) - sideBarBtn:setAnchoredPositionY(y) - sideBarBtn:refresh() - sideBarBtn:setActive(true) - sideBarBtn:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - for i = minCount + 1, sideBarShowCount do - self.leftBarList[i]:refresh() - self.leftBarList[i]:setActive(true) - self.leftBarList[i]:setVisible(false) - end - else - for k, v in ipairs(self.leftBarList) do - if maxCount == 0 then -- 换行 - y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - x = x + 110 - bgSizeX = 228 - otherColumn = true - end + self:clearSideBarList(self.leftBarList) + local list = GConst.MainCityConst.LEFT_SIDE_BARS + if #list <= 0 then + return + end + local isClose = ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose() + for k, v in ipairs(list) do + local CellClass = self.sideBarClassMap[v] + if CellClass == nil then + CellClass = require(v) + self.sideBarClassMap[v] = CellClass + end + if CellClass:checkIsOpen() then + local cell = self.sideBarCellMap[v] + if cell == nil then + cell = self:addSideBarCellComp(v) + cell:getBaseObject():setParent(self.leftSideBar, false) + cell:getBaseObject():setAnchorMin(0, 1) + cell:getBaseObject():setAnchorMax(0, 1) + end + cell:initWithParentUI(self, v, true) + table.insert(self.leftBarList, cell) + end + end + local sideBarShowCount = #self.leftBarList + if sideBarShowCount <= 0 then + self.leftNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) + return + end + self.leftNode:setAnchoredPositionX(0) + local y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 + local x = 60 + local maxCount = self.sideBarMaxCount + local minY = y + local bgSizeX = 112 + local otherColumn = false + if isClose then -- 只显示3个 + local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT + for i = 1, minCount do + local sideBarBtn = self.leftBarList[i] + if i <= sideBarShowCount then + sideBarBtn:setAnchoredPositionX(x) + sideBarBtn:setAnchoredPositionY(y) + sideBarBtn:refresh() + sideBarBtn:setActive(true) + sideBarBtn:setVisible(true) + y = y - self.sideBarHeight - SIDE_BAR_INTERVAL + if minY > y then + minY = y + end + end + end + for i = minCount + 1, sideBarShowCount do + self.leftBarList[i]:refresh() + self.leftBarList[i]:setActive(true) + self.leftBarList[i]:setVisible(false) + end + else + for k, v in ipairs(self.leftBarList) do + if maxCount == 0 then -- 换行 + y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 + x = x + 110 + bgSizeX = 228 + otherColumn = true + end - maxCount = maxCount - 1 - v:setAnchoredPositionX(x) - v:setAnchoredPositionY(y) - v:refresh() - v:setActive(true) - v:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - if sideBarShowCount <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then -- 小于3个不显示箭头 - y = y + self.sideBarHeight / 2 - if minY > y then - minY = y - end - self.leftSideBar:setSizeDeltaX(bgSizeX) - self.leftSideBar:setSizeDeltaY(-minY) - self.leftArrowBtn:stopClickAnimation() - self.leftArrowBtn:setVisible(false) - else - local arrowHeight = self.leftArrowBtn:getRectHeight() - y = y + self.sideBarHeight/2 - SIDE_BAR_ARROW_INTERVAL - arrowHeight - if minY > y then - minY = y - end - self.leftSideBar:setSizeDeltaX(bgSizeX) - self.leftSideBar:setSizeDeltaY(-minY) - self.leftArrowImg:setLocalScale(1, isClose and -1 or 1, 1) - self.leftArrowBtn:setVisible(true) - self.leftArrowBtn:setAnchoredPositionY(self.leftSideBar:fastGetAnchoredPositionY() + minY + arrowHeight/2 + SIDE_BAR_BORDER_OFFSET) - if otherColumn then - self.leftArrowBtn:setAnchoredPositionX(133) - else - self.leftArrowBtn:setAnchoredPositionX(73) - end - end + maxCount = maxCount - 1 + v:setAnchoredPositionX(x) + v:setAnchoredPositionY(y) + v:refresh() + v:setActive(true) + v:setVisible(true) + y = y - self.sideBarHeight - SIDE_BAR_INTERVAL + if minY > y then + minY = y + end + end + end + if sideBarShowCount <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then -- 小于3个不显示箭头 + y = y + self.sideBarHeight / 2 + if minY > y then + minY = y + end + self.leftSideBar:setSizeDeltaX(bgSizeX) + self.leftSideBar:setSizeDeltaY(-minY) + self.leftArrowBtn:stopClickAnimation() + self.leftArrowBtn:setVisible(false) + else + local arrowHeight = self.leftArrowBtn:getRectHeight() + y = y + self.sideBarHeight/2 - SIDE_BAR_ARROW_INTERVAL - arrowHeight + if minY > y then + minY = y + end + self.leftSideBar:setSizeDeltaX(bgSizeX) + self.leftSideBar:setSizeDeltaY(-minY) + self.leftArrowImg:setLocalScale(1, isClose and -1 or 1, 1) + self.leftArrowBtn:setVisible(true) + self.leftArrowBtn:setAnchoredPositionY(self.leftSideBar:fastGetAnchoredPositionY() + minY + arrowHeight/2 + SIDE_BAR_BORDER_OFFSET) + if otherColumn then + self.leftArrowBtn:setAnchoredPositionX(133) + else + self.leftArrowBtn:setAnchoredPositionX(73) + end + end end function MainCityUI:openOrCloseRightSideBar() - ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose() - if self.isShowRightSideBarArrowRedPoint ~= nil then - local isShowRightSideBarArrowRedPoint = self.isShowRightSideBarArrowRedPoint - self.isShowRightSideBarArrowRedPoint = nil - self:setRightSideBarArrowRedPoint(isShowRightSideBarArrowRedPoint) - end + ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose() + if self.isShowRightSideBarArrowRedPoint ~= nil then + local isShowRightSideBarArrowRedPoint = self.isShowRightSideBarArrowRedPoint + self.isShowRightSideBarArrowRedPoint = nil + self:setRightSideBarArrowRedPoint(isShowRightSideBarArrowRedPoint) + end end function MainCityUI:refreshRightBtns() - self:clearSideBarList(self.rightBarList) - local list = GConst.MainCityConst.RIGHT_SIDE_BARS - if #list <= 0 then - return - end - local isClose = ModuleManager.MaincityManager:getIsMainCityRightSideBarClose() - for k, v in ipairs(list) do - local CellClass = self.sideBarClassMap[v] - if CellClass == nil then - CellClass = require(v) - self.sideBarClassMap[v] = CellClass - end - if CellClass:checkIsOpen() then - local cell = self.sideBarCellMap[v] - if cell == nil then - cell = self:addSideBarCellComp(v) - cell:getBaseObject():setParent(self.rightSideBar, false) - cell:getBaseObject():setAnchorMin(1, 1) - cell:getBaseObject():setAnchorMax(1, 1) - end - cell:initWithParentUI(self, v, false) - table.insert(self.rightBarList, cell) - end - end - local sideBarShowCount = #self.rightBarList - if #self.rightBarList <= 0 then - self.rightNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) - return - end - self.rightNode:setAnchoredPositionX(0) - local y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - local x = -60 - local maxCount = self.sideBarMaxCount - local minY = y - local bgSizeX = 112 - local otherColumn = false - if isClose then -- 只显示一个 - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.rightBarList[i] - if i <= sideBarShowCount then - sideBarBtn:setAnchoredPositionX(x) - sideBarBtn:setAnchoredPositionY(y) - sideBarBtn:refresh() - sideBarBtn:setActive(true) - sideBarBtn:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - for i = minCount + 1, sideBarShowCount do - self.rightBarList[i]:refresh() - self.rightBarList[i]:setActive(true) - self.rightBarList[i]:setVisible(false) - end - else - for k, v in ipairs(self.rightBarList) do - if maxCount == 0 then -- 换行 - y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 - x = x - 110 - bgSizeX = 228 - otherColumn = true - end - maxCount = maxCount - 1 - v:setAnchoredPositionX(x) - v:setAnchoredPositionY(y) - v:refresh() - v:setActive(true) - v:setVisible(true) - y = y - self.sideBarHeight - SIDE_BAR_INTERVAL - if minY > y then - minY = y - end - end - end - if sideBarShowCount <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then - y = y + self.sideBarHeight / 2 - y = y + self.sideBarHeight / 2 - if minY > y then - minY = y - end - self.rightSideBar:setSizeDeltaX(bgSizeX) - self.rightSideBar:setSizeDeltaY(-minY) - self.rightArrowBtn:stopClickAnimation() - self.rightArrowBtn:setVisible(false) - else - local arrowHeight = self.rightArrowBtn:getRectHeight() - y = y + self.sideBarHeight / 2 - SIDE_BAR_ARROW_INTERVAL - arrowHeight - if minY > y then - minY = y - end - self.rightSideBar:setSizeDeltaX(bgSizeX) - self.rightSideBar:setSizeDeltaY(-minY) - self.rightArrowImg:setLocalScale(1, isClose and -1 or 1, 1) - self.rightArrowBtn:setVisible(true) - self.rightArrowBtn:setAnchoredPositionY(self.rightSideBar:fastGetAnchoredPositionY() + minY + arrowHeight/2 + SIDE_BAR_BORDER_OFFSET) - if otherColumn then - self.rightArrowBtn:setAnchoredPositionX(-133) - else - self.rightArrowBtn:setAnchoredPositionX(-73) - end - end + self:clearSideBarList(self.rightBarList) + local list = GConst.MainCityConst.RIGHT_SIDE_BARS + if #list <= 0 then + return + end + local isClose = ModuleManager.MaincityManager:getIsMainCityRightSideBarClose() + for k, v in ipairs(list) do + local CellClass = self.sideBarClassMap[v] + if CellClass == nil then + CellClass = require(v) + self.sideBarClassMap[v] = CellClass + end + if CellClass:checkIsOpen() then + local cell = self.sideBarCellMap[v] + if cell == nil then + cell = self:addSideBarCellComp(v) + cell:getBaseObject():setParent(self.rightSideBar, false) + cell:getBaseObject():setAnchorMin(1, 1) + cell:getBaseObject():setAnchorMax(1, 1) + end + cell:initWithParentUI(self, v, false) + table.insert(self.rightBarList, cell) + end + end + local sideBarShowCount = #self.rightBarList + if #self.rightBarList <= 0 then + self.rightNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) + return + end + self.rightNode:setAnchoredPositionX(0) + local y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 + local x = -60 + local maxCount = self.sideBarMaxCount + local minY = y + local bgSizeX = 112 + local otherColumn = false + if isClose then -- 只显示一个 + local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT + for i = 1, minCount do + local sideBarBtn = self.rightBarList[i] + if i <= sideBarShowCount then + sideBarBtn:setAnchoredPositionX(x) + sideBarBtn:setAnchoredPositionY(y) + sideBarBtn:refresh() + sideBarBtn:setActive(true) + sideBarBtn:setVisible(true) + y = y - self.sideBarHeight - SIDE_BAR_INTERVAL + if minY > y then + minY = y + end + end + end + for i = minCount + 1, sideBarShowCount do + self.rightBarList[i]:refresh() + self.rightBarList[i]:setActive(true) + self.rightBarList[i]:setVisible(false) + end + else + for k, v in ipairs(self.rightBarList) do + if maxCount == 0 then -- 换行 + y = -SIDE_BAR_BORDER_OFFSET - self.sideBarHeight/2 + x = x - 110 + bgSizeX = 228 + otherColumn = true + end + maxCount = maxCount - 1 + v:setAnchoredPositionX(x) + v:setAnchoredPositionY(y) + v:refresh() + v:setActive(true) + v:setVisible(true) + y = y - self.sideBarHeight - SIDE_BAR_INTERVAL + if minY > y then + minY = y + end + end + end + if sideBarShowCount <= GConst.MainCityConst.SIDE_BAR_MIN_COUNT then + y = y + self.sideBarHeight / 2 + y = y + self.sideBarHeight / 2 + if minY > y then + minY = y + end + self.rightSideBar:setSizeDeltaX(bgSizeX) + self.rightSideBar:setSizeDeltaY(-minY) + self.rightArrowBtn:stopClickAnimation() + self.rightArrowBtn:setVisible(false) + else + local arrowHeight = self.rightArrowBtn:getRectHeight() + y = y + self.sideBarHeight / 2 - SIDE_BAR_ARROW_INTERVAL - arrowHeight + if minY > y then + minY = y + end + self.rightSideBar:setSizeDeltaX(bgSizeX) + self.rightSideBar:setSizeDeltaY(-minY) + self.rightArrowImg:setLocalScale(1, isClose and -1 or 1, 1) + self.rightArrowBtn:setVisible(true) + self.rightArrowBtn:setAnchoredPositionY(self.rightSideBar:fastGetAnchoredPositionY() + minY + arrowHeight/2 + SIDE_BAR_BORDER_OFFSET) + if otherColumn then + self.rightArrowBtn:setAnchoredPositionX(-133) + else + self.rightArrowBtn:setAnchoredPositionX(-73) + end + end end function MainCityUI:clearSideBarList(sideBarList) - local count = #sideBarList - for i = 1, count do - local cell = table.remove(sideBarList) - cell:setActive(false) - cell:setVisible(false) - self.sideBarCellMap[cell:getCellPath()] = cell - end + local count = #sideBarList + for i = 1, count do + local cell = table.remove(sideBarList) + cell:setActive(false) + cell:setVisible(false) + self.sideBarCellMap[cell:getCellPath()] = cell + end end function MainCityUI:setSideBarVisible(visible) - self.leftNode:setVisible(visible) - self.rightNode:setVisible(visible) + self.leftNode:setVisible(visible) + self.rightNode:setVisible(visible) end function MainCityUI:refreshPlayerInfo() - if not self.playerInfoCell then - self.playerInfoCell = CellManager:addCellComp(self.uiMap["main_ui.player_info_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_INFO_CELL) - end - self.playerInfoCell:refresh() + if not self.playerInfoCell then + self.playerInfoCell = CellManager:addCellComp(self.uiMap["main_ui.player_info_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_INFO_CELL) + end + self.playerInfoCell:refresh() end function MainCityUI:initTopNode() - self.topNode = self.uiMap["main_ui.top_node"] - self:initTask() + self.topNode = self.uiMap["main_ui.top_node"] + self:initTask() self:initBounty() self:initSetting() end @@ -726,656 +721,639 @@ end function MainCityUI:initTask() self.taskBtn = self.uiMap["main_ui.top_node.task_btn"] self.taskBtn:addClickListener(function() - ModuleManager.TaskManager:showTaskMainUI() + ModuleManager.TaskManager:showTaskMainUI() end) end function MainCityUI:initBounty() self.bountyNode = self.uiMap["main_ui.top_node.bounty_node"] self.bountyBanner = self.uiMap["main_ui.top_node.bounty_node.banner"] - self.bountyBanner:addClickListener(function() - ModuleManager.BountyManager:showBountyMainUI() - end) - self.bountyRewardSpine = self.uiMap["main_ui.top_node.bounty_node.banner.spine"] - self.bountyBannerInfo = self.uiMap["main_ui.top_node.bounty_node.banner.info"] - self.bountyBannerDescTx = self.uiMap["main_ui.top_node.bounty_node.banner.desc"] - self.bountyBannerSlider = self.uiMap["main_ui.top_node.bounty_node.banner.info.progress_bg.slider"] - self.bountyBannerSliderTx = self.uiMap["main_ui.top_node.bounty_node.banner.info.progress_bg.slider_tx"] - self.bountyBannerLvTx = self.uiMap["main_ui.top_node.bounty_node.banner.info.progress_bg.lv_tx"] - self.uiMap["main_ui.top_node.bounty_node.banner.info.name"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_TITLE)) + self.bountyBanner:addClickListener(function() + ModuleManager.BountyManager:showBountyMainUI() + end) + self.bountyRewardSpine = self.uiMap["main_ui.top_node.bounty_node.banner.spine"] + self.bountyBannerInfo = self.uiMap["main_ui.top_node.bounty_node.banner.info"] + self.bountyBannerDescTx = self.uiMap["main_ui.top_node.bounty_node.banner.desc"] + self.bountyBannerSlider = self.uiMap["main_ui.top_node.bounty_node.banner.info.progress_bg.slider"] + self.bountyBannerSliderTx = self.uiMap["main_ui.top_node.bounty_node.banner.info.progress_bg.slider_tx"] + self.bountyBannerLvTx = self.uiMap["main_ui.top_node.bounty_node.banner.info.progress_bg.lv_tx"] + self.uiMap["main_ui.top_node.bounty_node.banner.info.name"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_TITLE)) end function MainCityUI:initSetting() self.settingbtn = self.uiMap["main_ui.top_node.setting_btn"] self.settingbtn:addClickListener(function() - ModuleManager.GameSettingManager:showSelectOtherBtnUI() + ModuleManager.GameSettingManager:showSelectOtherBtnUI() end) end function MainCityUI:setTopNodeVisible(visible) - self.topNode:setVisible(visible) + self.topNode:setVisible(visible) end function MainCityUI:refreshTopNode() - self:refreshBounty() - self:refreshTask() + self:refreshBounty() + self:refreshTask() end function MainCityUI:refreshBounty() local isOpen = DataManager.BountyData:getIsOpen() - if not isOpen or not self.mainComp:getCurModule():isShowBounty() or GFunc.isShenhe() then + if not isOpen or GFunc.isShenhe() then self.bountyNode:setVisible(false) - self.bountyRewardSpine:getSkeletonGraphic().enabled = false + self.bountyRewardSpine:getSkeletonGraphic().enabled = false return end self.bountyNode:setVisible(true) - if DataManager.BountyData:getIfCanClaimReward() then - self.bountyRewardSpine:setVisible(true) - self.bountyRewardSpine:playAnim("idle", true) - self.bountyRewardSpine:getSkeletonGraphic().enabled = true - self.bountyBannerInfo:setVisible(false) - self.bountyBannerDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.COLLET_REWARDS)) - else - self.bountyRewardSpine:setVisible(false) - self.bountyRewardSpine:getSkeletonGraphic().enabled = false - local bannerName = DataManager.BountyData:getBannerName() - self.bountyBanner:setSprite(GConst.ATLAS_PATH.BOUNTY, bannerName) - self.bountyBannerInfo:setVisible(true) - self.bountyBannerDescTx:setText(GConst.EMPTY_STRING) - local exp = DataManager.BountyData:getExp() - local lvUpExp = DataManager.BountyData:getLvUpExp() - local level = DataManager.BountyData:getLevel() - local maxLevel = DataManager.BountyData:getMaxLevel() - self.bountyBannerSliderTx:setText(exp .. "/" .. lvUpExp) - self.bountyBannerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = exp / lvUpExp - if level >= maxLevel then - self.bountyBannerLvTx:setText(I18N:getGlobalText(I18N.GlobalConst.STR_MAX)) - else - self.bountyBannerLvTx:setText(tostring(level)) - end - end + if DataManager.BountyData:getIfCanClaimReward() then + self.bountyRewardSpine:setVisible(true) + self.bountyRewardSpine:playAnim("idle", true) + self.bountyRewardSpine:getSkeletonGraphic().enabled = true + self.bountyBannerInfo:setVisible(false) + self.bountyBannerDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.COLLET_REWARDS)) + else + self.bountyRewardSpine:setVisible(false) + self.bountyRewardSpine:getSkeletonGraphic().enabled = false + local bannerName = DataManager.BountyData:getBannerName() + self.bountyBanner:setSprite(GConst.ATLAS_PATH.BOUNTY, bannerName) + self.bountyBannerInfo:setVisible(true) + self.bountyBannerDescTx:setText(GConst.EMPTY_STRING) + local exp = DataManager.BountyData:getExp() + local lvUpExp = DataManager.BountyData:getLvUpExp() + local level = DataManager.BountyData:getLevel() + local maxLevel = DataManager.BountyData:getMaxLevel() + self.bountyBannerSliderTx:setText(exp .. "/" .. lvUpExp) + self.bountyBannerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = exp / lvUpExp + if level >= maxLevel then + self.bountyBannerLvTx:setText(I18N:getGlobalText(I18N.GlobalConst.STR_MAX)) + else + self.bountyBannerLvTx:setText(tostring(level)) + end + end end function MainCityUI:refreshArenaBounty() - if self.mainComp then - self.mainComp:refreshArenaBounty() - end + if self.mainComp then + self.mainComp:refreshArenaBounty() + end end function MainCityUI:refreshTask() - local isOpen = DataManager.DailyTaskData:getIsOpen() + local isOpen = DataManager.DailyTaskData:getIsOpen() if not isOpen then self.taskBtn:setVisible(false) return end self.taskBtn:setVisible(true) - local showRedPoint = DataManager.DailyTaskData:getIsShowRedPoint() - if showRedPoint then - self.taskBtn:addRedPoint(38, 34, 0.7) - else - self.taskBtn:removeRedPoint() - end + local showRedPoint = DataManager.DailyTaskData:getIsShowRedPoint() + if showRedPoint then + self.taskBtn:addRedPoint(38, 34, 0.7) + else + self.taskBtn:removeRedPoint() + end end function MainCityUI:switchComp(index) - index = index or self.selectedIndex - for i, comp in pairs(self.subComps) do - comp:getBaseObject():setActive(i == index) - if i == index then - if index == GConst.MainCityConst.BOTTOM_PAGE.SHOP then - comp:clearPostFlag() - comp:refresh() - elseif index == GConst.MainCityConst.BOTTOM_PAGE.HERO then - comp:refresh(GConst.BattleConst.BATTLE_TYPE.STAGE) - else - comp:refresh() - end + index = index or self.selectedIndex + for i, comp in pairs(self.subComps) do + comp:getBaseObject():setActive(i == index) + if i == index then + if index == GConst.MainCityConst.BOTTOM_PAGE.SHOP then + comp:clearPostFlag() + comp:refresh() + elseif index == GConst.MainCityConst.BOTTOM_PAGE.HERO then + comp:refresh(GConst.BattleConst.BATTLE_TYPE.STAGE) + else + comp:refresh() + end - self:updateTime() - end - end - self:updateCurrencyBar() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then - self:refreshTopNode() - self:switchMainCompModule() - else - self:setTopNodeVisible(false) - self:setSideBarVisible(false) - end + self:updateTime() + end + end + self:updateCurrencyBar() + if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then + self:refreshTopNode() + self:switchMainCompModule() + else + self:setTopNodeVisible(false) + self:setSideBarVisible(false) + end end -- 切换主界面活动模块 function MainCityUI:switchMainCompModule(moduleKey) - if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then - return - end - self.mainComp:refreshModule(ModuleManager.MaincityManager:getCurModule()) - if ModuleManager.MaincityManager:getCurModule() == GConst.MainCityConst.MAIN_MODULE.CHAPTER then - self:checkMainPop() - end - local module = self.mainComp:getCurModule() - if module then - self:setTopNodeVisible(module:isShowTopNode()) - self:setSideBarVisible(module:isShowSideBar()) - self:refreshBounty() - UIManager:updateBarsState(self) - end + if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then + return + end + self.mainComp:refresh() + self:checkMainPop() + self:setTopNodeVisible(true) + self:setSideBarVisible(true) + self:refreshBounty() + UIManager:updateBarsState(self) end function MainCityUI:updateTime() - if self.subComps[self.selectedIndex] and self.subComps[self.selectedIndex].refreshTime then - self.subComps[self.selectedIndex]:refreshTime() - end - self.inSideBarUpdate = true - if self.leftBarList then - for k, v in ipairs(self.leftBarList) do - v:updateTime() - end - end - if self.waitRefreshSideBar then - self:refreshLeftBtns() - self.waitRefreshSideBar = false - end - if self.rightBarList then - for k, v in ipairs(self.rightBarList) do - v:updateTime() - end - end - self.inSideBarUpdate = false - if self.waitRefreshSideBar then - self:refreshRightBtns() - self.waitRefreshSideBar = false - end + if self.subComps[self.selectedIndex] and self.subComps[self.selectedIndex].refreshTime then + self.subComps[self.selectedIndex]:refreshTime() + end + self.inSideBarUpdate = true + if self.leftBarList then + for k, v in ipairs(self.leftBarList) do + v:updateTime() + end + end + if self.waitRefreshSideBar then + self:refreshLeftBtns() + self.waitRefreshSideBar = false + end + if self.rightBarList then + for k, v in ipairs(self.rightBarList) do + v:updateTime() + end + end + self.inSideBarUpdate = false + if self.waitRefreshSideBar then + self:refreshRightBtns() + self.waitRefreshSideBar = false + end - if DataManager.AIHelperData:getNeedReqTime() then - ModuleManager.GameSettingManager:reqAiHelper() - end + if DataManager.AIHelperData:getNeedReqTime() then + ModuleManager.GameSettingManager:reqAiHelper() + end end function MainCityUI:updateSideBarStatus() - if self.leftBarList then - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.leftBarList[i] - if sideBarBtn then - if sideBarBtn:getIsShowRedPoint() then - sideBarBtn:showRedPoint() - else - sideBarBtn:hideRedPoint() - end - end - end - local sideBarCount = #self.leftBarList - if sideBarCount > minCount then - local count = 0 - for i = minCount + 1, sideBarCount do - if self.leftBarList[i]:getIsShowRedPoint() then - self.leftBarList[i]:showRedPoint() - count = count + 1 - else - self.leftBarList[i]:hideRedPoint() - end - end - if count > 0 then - self:setLeftSideBarArrowRedPoint(true) - else - self:setLeftSideBarArrowRedPoint(false) - end - else - self:setLeftSideBarArrowRedPoint(false) - end - end - if self.rightBarList then - local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT - for i = 1, minCount do - local sideBarBtn = self.rightBarList[i] - if sideBarBtn then - if sideBarBtn:getIsShowRedPoint() then - sideBarBtn:showRedPoint() - else - sideBarBtn:hideRedPoint() - end - end - end - local sideBarCount = #self.rightBarList - if sideBarCount > minCount then - local count = 0 - for i = minCount + 1, sideBarCount do - if self.rightBarList[i]:getIsShowRedPoint() then - self.rightBarList[i]:showRedPoint() - count = count + 1 - else - self.rightBarList[i]:hideRedPoint() - end - end - if count > 0 then - self:setRightSideBarArrowRedPoint(true) - else - self:setRightSideBarArrowRedPoint(false) - end - else - self:setRightSideBarArrowRedPoint(false) - end - end + if self.leftBarList then + local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT + for i = 1, minCount do + local sideBarBtn = self.leftBarList[i] + if sideBarBtn then + if sideBarBtn:getIsShowRedPoint() then + sideBarBtn:showRedPoint() + else + sideBarBtn:hideRedPoint() + end + end + end + local sideBarCount = #self.leftBarList + if sideBarCount > minCount then + local count = 0 + for i = minCount + 1, sideBarCount do + if self.leftBarList[i]:getIsShowRedPoint() then + self.leftBarList[i]:showRedPoint() + count = count + 1 + else + self.leftBarList[i]:hideRedPoint() + end + end + if count > 0 then + self:setLeftSideBarArrowRedPoint(true) + else + self:setLeftSideBarArrowRedPoint(false) + end + else + self:setLeftSideBarArrowRedPoint(false) + end + end + if self.rightBarList then + local minCount = GConst.MainCityConst.SIDE_BAR_MIN_COUNT + for i = 1, minCount do + local sideBarBtn = self.rightBarList[i] + if sideBarBtn then + if sideBarBtn:getIsShowRedPoint() then + sideBarBtn:showRedPoint() + else + sideBarBtn:hideRedPoint() + end + end + end + local sideBarCount = #self.rightBarList + if sideBarCount > minCount then + local count = 0 + for i = minCount + 1, sideBarCount do + if self.rightBarList[i]:getIsShowRedPoint() then + self.rightBarList[i]:showRedPoint() + count = count + 1 + else + self.rightBarList[i]:hideRedPoint() + end + end + if count > 0 then + self:setRightSideBarArrowRedPoint(true) + else + self:setRightSideBarArrowRedPoint(false) + end + else + self:setRightSideBarArrowRedPoint(false) + end + end end function MainCityUI:setLeftSideBarArrowRedPoint(isShow) - if self.isShowLeftSideBarArrowRedPoint == isShow then - return - end - if isShow then - if ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose() then - self.leftArrowBtn:addRedPoint(19, 10, 0.6) - else - self.leftArrowBtn:removeRedPoint() - end - else - self.leftArrowBtn:removeRedPoint() - end + if self.isShowLeftSideBarArrowRedPoint == isShow then + return + end + if isShow then + if ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose() then + self.leftArrowBtn:addRedPoint(19, 10, 0.6) + else + self.leftArrowBtn:removeRedPoint() + end + else + self.leftArrowBtn:removeRedPoint() + end end function MainCityUI:setRightSideBarArrowRedPoint(isShow) - if self.isShowRightSideBarArrowRedPoint == isShow then - return - end - if isShow then - if ModuleManager.MaincityManager:getIsMainCityRightSideBarClose() then - self.rightArrowBtn:addRedPoint(19, 10, 0.6) - else - self.rightArrowBtn:removeRedPoint() - end - else - self.rightArrowBtn:removeRedPoint() - end + if self.isShowRightSideBarArrowRedPoint == isShow then + return + end + if isShow then + if ModuleManager.MaincityManager:getIsMainCityRightSideBarClose() then + self.rightArrowBtn:addRedPoint(19, 10, 0.6) + else + self.rightArrowBtn:removeRedPoint() + end + else + self.rightArrowBtn:removeRedPoint() + end end function MainCityUI:closeSideBarBtn(isLeft) - if self.inSideBarUpdate then - self.waitRefreshSideBar = true - else - self.waitRefreshSideBar = false - if isLeft then - self:refreshLeftBtns() - else - self:refreshRightBtns() - end - end + if self.inSideBarUpdate then + self.waitRefreshSideBar = true + else + self.waitRefreshSideBar = false + if isLeft then + self:refreshLeftBtns() + else + self:refreshRightBtns() + end + end end function MainCityUI:refreshBottomRp() - local uiMap = self.root:genAllChildren() - local heroRpObj = uiMap["main_ui.bottom_node.icons.ui_spine_obj_2.rp_node"] - if DataManager.HeroData:getRp() then - heroRpObj:addRedPoint(0, 0, 0.7) - else - heroRpObj:removeRedPoint() - end - local shopRpObj = uiMap["main_ui.bottom_node.icons.ui_spine_obj_3.rp_node"] - if DataManager.ShopData:getRp() then - shopRpObj:addRedPoint(0, 0, 0.7) - else - shopRpObj:removeRedPoint() - end + local uiMap = self.root:genAllChildren() + local heroRpObj = uiMap["main_ui.bottom_node.icons.ui_spine_obj_2.rp_node"] + if DataManager.HeroData:getRp() then + heroRpObj:addRedPoint(0, 0, 0.7) + else + heroRpObj:removeRedPoint() + end + local shopRpObj = uiMap["main_ui.bottom_node.icons.ui_spine_obj_3.rp_node"] + if DataManager.ShopData:getRp() then + shopRpObj:addRedPoint(0, 0, 0.7) + else + shopRpObj:removeRedPoint() + end end function MainCityUI:refreshSettingBtn() - if (DataManager.MailData:getIsOpen() and DataManager.MailData:getRedPoint()) or DataManager.AIHelperData:getRp() then - self.settingbtn:addRedPoint(40, 40, 0.7) - else - self.settingbtn:removeRedPoint() - end + if (DataManager.MailData:getIsOpen() and DataManager.MailData:getRedPoint()) or DataManager.AIHelperData:getRp() then + self.settingbtn:addRedPoint(40, 40, 0.7) + else + self.settingbtn:removeRedPoint() + end end function MainCityUI:checkSideBarOpenStatus() - -- 检查目前没开的侧边栏功能是否有可以开启的 - for k, CellClass in pairs(self.sideBarClassMap) do - local cell = self.sideBarCellMap[k] - if cell and cell:getIsActive() then - if not CellClass:checkIsOpen() then - return self:refreshAllSideBars() - end - else - if CellClass:checkIsOpen() then - return self:refreshAllSideBars() - end - end - end + -- 检查目前没开的侧边栏功能是否有可以开启的 + for k, CellClass in pairs(self.sideBarClassMap) do + local cell = self.sideBarCellMap[k] + if cell and cell:getIsActive() then + if not CellClass:checkIsOpen() then + return self:refreshAllSideBars() + end + else + if CellClass:checkIsOpen() then + return self:refreshAllSideBars() + end + end + end end -- 弹窗优先级: 升级>功能弹窗>英雄解锁弹窗>礼包弹窗>引导 function MainCityUI:checkMainPop() - -- 续关 - if self.isFirstEnter then - local battleSnapshot = LocalData:getBattleSnapshot() - if battleSnapshot.battleType then - if battleSnapshot.currentVersion == Platform:getClientVersion() then - local snapshotTime = battleSnapshot.snapShotTime - if snapshotTime and Time:getOverOfServerToday(snapshotTime) >= Time:getOverOfServerToday() then - BIReport:postBatttleSnapshotOpen() - local params = { - content = I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_14), - okFunc = function() - LocalData:saveBattleSnapshot({}) - ModuleManager.BattleManager:playBattle(battleSnapshot.battleType, battleSnapshot.parmas, nil, battleSnapshot) - end, - cancelFunc = function() - LocalData:saveBattleSnapshot({}) - end, - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, - } - GFunc.showMessageBox(params) - return - end - end - end - end + -- 续关 + if self.isFirstEnter then + local battleSnapshot = LocalData:getBattleSnapshot() + if battleSnapshot.battleType then + if battleSnapshot.currentVersion == Platform:getClientVersion() then + local snapshotTime = battleSnapshot.snapShotTime + if snapshotTime and Time:getOverOfServerToday(snapshotTime) >= Time:getOverOfServerToday() then + BIReport:postBatttleSnapshotOpen() + local params = { + content = I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_14), + okFunc = function() + LocalData:saveBattleSnapshot({}) + ModuleManager.BattleManager:playBattle(battleSnapshot.battleType, battleSnapshot.parmas, nil, battleSnapshot) + end, + cancelFunc = function() + LocalData:saveBattleSnapshot({}) + end, + boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, + } + GFunc.showMessageBox(params) + return + end + end + end + end - if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then - return - end + if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then + return + end - if ModuleManager.MaincityManager:getCurModule() ~= GConst.MainCityConst.MAIN_MODULE.CHAPTER then -- 当前不是关卡界面不触发 - return - end + -- 检查是否升级 + if DataManager.PlayerData:getIfCanLevelUp() then + ModuleManager.PlayerManager:levelUp() + return + end + -- 检查功能弹窗 + if DataManager.PlayerData:getIfCanShowModuleUnlock() and not GFunc.isShenhe() then + ModuleManager.MaincityManager:showModuleUnlockUI() + return + end + -- 是否是否有英雄解锁弹窗 + if DataManager.HeroData:getIfCanShowHeroUnlock() then + local list = DataManager.HeroData:getHeroChapterUnlockList() + DataManager.HeroData:markShowHeroUnlock() + if list and #list > 0 then + ModuleManager.HeroManager:showHeroUnlockUI(list) + return + end + end - -- 检查是否升级 - if DataManager.PlayerData:getIfCanLevelUp() then - ModuleManager.PlayerManager:levelUp() - return - end - -- 检查功能弹窗 - if DataManager.PlayerData:getIfCanShowModuleUnlock() and not GFunc.isShenhe() then - ModuleManager.MaincityManager:showModuleUnlockUI() - return - end - -- 是否是否有英雄解锁弹窗 - if DataManager.HeroData:getIfCanShowHeroUnlock() then - local list = DataManager.HeroData:getHeroChapterUnlockList() - DataManager.HeroData:markShowHeroUnlock() - if list and #list > 0 then - ModuleManager.HeroManager:showHeroUnlockUI(list) - return - end - end + -- 引导 + if self:checkTutorial() then + return + end - -- 引导 - if self:checkTutorial() then - return - end + -- 礼包 + if self:checkGift() then + return + end - -- 礼包 - if self:checkGift() then - return - end + -- 圆月活动 + local showType = DataManager.FullMoonData:getNeedShowActPanel() + if showType then + ModuleManager.FullMoonManager:showActMainUI(showType) + return + end - -- 圆月活动 - local showType = DataManager.FullMoonData:getNeedShowActPanel() - if showType then - ModuleManager.FullMoonManager:showActMainUI(showType) - return - end + -- 金猪满了后下次进主城要弹出来 + if DataManager.GoldPigData:getPopFlag() and not DataManager.TutorialData:getIsInTutorial() then + DataManager.GoldPigData:markPop() + local showType = BIReport.PAY_UI_SHOW_TYPE.TRIGGER_POP + if self.isFirstEnter then + showType = BIReport.PAY_UI_SHOW_TYPE.LOGIN_POP + end + ModuleManager.ActivityManager:showGoldPigUI(showType) + return + end - -- 金猪满了后下次进主城要弹出来 - if DataManager.GoldPigData:getPopFlag() and not DataManager.TutorialData:getIsInTutorial() then - DataManager.GoldPigData:markPop() - local showType = BIReport.PAY_UI_SHOW_TYPE.TRIGGER_POP - if self.isFirstEnter then - showType = BIReport.PAY_UI_SHOW_TYPE.LOGIN_POP - end - ModuleManager.ActivityManager:showGoldPigUI(showType) - return - end - - if DataManager.ActBossRushData:getIsOpen() and not DataManager.TutorialData:getIsInTutorial() then -- 弹窗 - if not DataManager.ActBossRushData:getMarkPoped() then - if ModuleManager.ActBossRushManager:showPopUI() then - return - end - end - end + if DataManager.ActBossRushData:getIsOpen() and not DataManager.TutorialData:getIsInTutorial() then -- 弹窗 + if not DataManager.ActBossRushData:getMarkPoped() then + if ModuleManager.ActBossRushManager:showPopUI() then + return + end + end + end end -- 检查引导 function MainCityUI:checkTutorial(onlyCheck) - if DataManager.ChapterData:getMaxChapterId() == 1 then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.PASS_ONE_CHAPTER, onlyCheck) then - return true - end - end + if DataManager.ChapterData:getMaxChapterId() == 1 then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.PASS_ONE_CHAPTER, onlyCheck) then + return true + end + end - if DataManager.ChapterData:boxCanGet(2, 1) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.TWO_CHAPTER_BOX_CAN_GOT, onlyCheck) then - return true - end - end + if DataManager.ChapterData:boxCanGet(2, 1) then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.TWO_CHAPTER_BOX_CAN_GOT, onlyCheck) then + return true + end + end - if DataManager.ChapterData:getMaxChapterId() == 2 then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.PASS_THREE_CHAPTER, onlyCheck) then - return true - end - end + if DataManager.ChapterData:getMaxChapterId() == 2 then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.PASS_THREE_CHAPTER, onlyCheck) then + return true + end + end - if DataManager.DailyChallengeData:isOpen() then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_DAILY_CHALLENGE, onlyCheck) then - return true - end - end + if DataManager.DailyChallengeData:isOpen() then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_DAILY_CHALLENGE, onlyCheck) then + return true + end + end - if DataManager.DungeonData:isOpenAnyone() then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_DUNGEON, onlyCheck) then - return true - end - end + if DataManager.DungeonData:isOpenAnyone() then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_DUNGEON, onlyCheck) then + return true + end + end - if DataManager.ArenaData:isOpen() then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_ARENA, onlyCheck) then - return true - end - end + if DataManager.ArenaData:isOpen() then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_ARENA, onlyCheck) then + return true + end + end - if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_WEAPON) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.WEAPON_DUNGEON, onlyCheck) then - return true - end - end + if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_WEAPON) then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.WEAPON_DUNGEON, onlyCheck) then + return true + end + end - if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_ARMOR) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.ARMOR_DUNGEON, onlyCheck) then - return true - end - end + if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_ARMOR) then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.ARMOR_DUNGEON, onlyCheck) then + return true + end + end - if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.RUNES_OPEN) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.RUNE_DUNGEON, onlyCheck) then - return true - end - end + if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.RUNES_OPEN) then + if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.RUNE_DUNGEON, onlyCheck) then + return true + end + end end -- 检查礼包(首充(作废)/入门/章节/新手/助力/成长/金币顺序) function MainCityUI:checkGift() - local showType = BIReport.PAY_UI_SHOW_TYPE.TRIGGER_POP - if self.isFirstEnter then - showType = BIReport.PAY_UI_SHOW_TYPE.LOGIN_POP - end - -- 审核模式不弹礼包 - if GFunc.isShenhe() then - return - end - -- 引导其间不处理 - if DataManager.TutorialData:getIsHaveTutorial() then - return - end - -- 非主线章节界面不处理(只在主线章节也就是主界面弹) - if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN or self.subComps[self.selectedIndex]:getCurModuleType() ~= GConst.MainCityConst.MAIN_MODULE.CHAPTER then - return - end - -- 章节礼包 - local chapterPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT) - -- 通用礼包 - local summerGiftIds - local beginnerGiftIds - local levelUpGiftIds - local firstRechargeIds - local introductGiftIds - local actPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.ACT_GIFT) - if actPopUpGifts and #actPopUpGifts > 0 then - -- 先遍历找出符合弹出的类型 - for _, actId in ipairs(actPopUpGifts) do - local cfgInfo = DataManager.ShopData:getActGiftConfig()[actId] - if cfgInfo then - -- 夏日活动礼包 - if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.ACT_SUMMER then - if not summerGiftIds then - summerGiftIds = {} - end - table.insert(summerGiftIds, actId) - end - -- 新手礼包 - if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT then - if not beginnerGiftIds then - beginnerGiftIds = {} - end - table.insert(beginnerGiftIds, actId) - end - -- 助力礼包 - if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT then - if not levelUpGiftIds then - levelUpGiftIds = {} - end - table.insert(levelUpGiftIds, actId) - end - -- 首充礼包 - if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE then - if not firstRechargeIds then - firstRechargeIds = {} - end - table.insert(firstRechargeIds, actId) - end - -- 入门礼包 - if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.INTRODUCTORY_GIFT then - if not introductGiftIds then - introductGiftIds = {} - end - table.insert(introductGiftIds, actId) - end - end - end - end - -- 特殊的 成长礼包 - local growUpPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW) - -- 按顺序弹出(首充/章节/新手/助力/成长/金币顺序) - -- 首充礼包 - -- if firstRechargeIds and #firstRechargeIds > 0 then - -- ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, firstRechargeIds[1]) - -- return true - -- end - -- 夏日礼包在最前 - if summerGiftIds and #summerGiftIds > 0 then - ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, summerGiftIds[1], showType) - return true - end - -- 入门礼包 - if introductGiftIds and #introductGiftIds > 0 then - ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, introductGiftIds[1], showType) - return true - end - ---- 试玩弹窗在章节礼包前 - local heroId, chapterId = DataManager.ChapterData:getCacheTrialHeroIdAndChapterId() - if heroId and chapterId then - ModuleManager.ChapterManager:showHeroTrialUI(heroId, chapterId) - return true - end - -- 章节礼包 - if chapterPopUpGifts and #chapterPopUpGifts > 0 then - ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, chapterPopUpGifts[1], showType) - return true - end - -- 新手礼包 - if beginnerGiftIds and #beginnerGiftIds > 0 then - ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, beginnerGiftIds[1], showType) - return true - end - -- 助力礼包 - if levelUpGiftIds and #levelUpGiftIds then - ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, levelUpGiftIds[1], showType) - return true - end - -- 成长礼包 - if growUpPopUpGifts and #growUpPopUpGifts > 0 then - ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW, growUpPopUpGifts[1], showType) - return true - end + local showType = BIReport.PAY_UI_SHOW_TYPE.TRIGGER_POP + if self.isFirstEnter then + showType = BIReport.PAY_UI_SHOW_TYPE.LOGIN_POP + end + -- 审核模式不弹礼包 + if GFunc.isShenhe() then + return + end + -- 引导其间不处理 + if DataManager.TutorialData:getIsHaveTutorial() then + return + end + -- 非主线章节界面不处理(只在主线章节也就是主界面弹) + if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then + return + end + -- 章节礼包 + local chapterPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT) + -- 通用礼包 + local summerGiftIds + local beginnerGiftIds + local levelUpGiftIds + local firstRechargeIds + local introductGiftIds + local actPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.ACT_GIFT) + if actPopUpGifts and #actPopUpGifts > 0 then + -- 先遍历找出符合弹出的类型 + for _, actId in ipairs(actPopUpGifts) do + local cfgInfo = DataManager.ShopData:getActGiftConfig()[actId] + if cfgInfo then + -- 夏日活动礼包 + if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.ACT_SUMMER then + if not summerGiftIds then + summerGiftIds = {} + end + table.insert(summerGiftIds, actId) + end + -- 新手礼包 + if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT then + if not beginnerGiftIds then + beginnerGiftIds = {} + end + table.insert(beginnerGiftIds, actId) + end + -- 助力礼包 + if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT then + if not levelUpGiftIds then + levelUpGiftIds = {} + end + table.insert(levelUpGiftIds, actId) + end + -- 首充礼包 + if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE then + if not firstRechargeIds then + firstRechargeIds = {} + end + table.insert(firstRechargeIds, actId) + end + -- 入门礼包 + if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.INTRODUCTORY_GIFT then + if not introductGiftIds then + introductGiftIds = {} + end + table.insert(introductGiftIds, actId) + end + end + end + end + -- 特殊的 成长礼包 + local growUpPopUpGifts = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW) + -- 按顺序弹出(首充/章节/新手/助力/成长/金币顺序) + -- 首充礼包 + -- if firstRechargeIds and #firstRechargeIds > 0 then + -- ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, firstRechargeIds[1]) + -- return true + -- end + -- 夏日礼包在最前 + if summerGiftIds and #summerGiftIds > 0 then + ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, summerGiftIds[1], showType) + return true + end + -- 入门礼包 + if introductGiftIds and #introductGiftIds > 0 then + ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, introductGiftIds[1], showType) + return true + end + ---- 试玩弹窗在章节礼包前 + local heroId, chapterId = DataManager.ChapterData:getCacheTrialHeroIdAndChapterId() + if heroId and chapterId then + ModuleManager.ChapterManager:showHeroTrialUI(heroId, chapterId) + return true + end + -- 章节礼包 + if chapterPopUpGifts and #chapterPopUpGifts > 0 then + ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, chapterPopUpGifts[1], showType) + return true + end + -- 新手礼包 + if beginnerGiftIds and #beginnerGiftIds > 0 then + ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, beginnerGiftIds[1], showType) + return true + end + -- 助力礼包 + if levelUpGiftIds and #levelUpGiftIds then + ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, levelUpGiftIds[1], showType) + return true + end + -- 成长礼包 + if growUpPopUpGifts and #growUpPopUpGifts > 0 then + ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW, growUpPopUpGifts[1], showType) + return true + end end function MainCityUI:getTaskIconPos() - return self.taskBtn:getPosition() + return self.taskBtn:getPosition() end function MainCityUI:getMallIconPos() - return self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:getPosition() + return self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:getPosition() end function MainCityUI:getDailyChallengeIconPos() - return self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:getDailyChallengeIconPos() -end - -function MainCityUI:getLeftOrRightEntrancePos(module) - return self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:getLeftOrRightEntrancePos(module) -end - -function MainCityUI:getArenaIconPos() - return self:getLeftOrRightEntrancePos(GConst.MainCityConst.MAIN_MODULE.ARENA) + return self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:getDailyChallengeIconPos() end function MainCityUI:getSideBarActIconPos(moduleKey) - for name, cell in pairs(self.leftBarList) do - if moduleKey == cell:getModuleKey() then - return cell:getBaseObject():getPosition() - end - end - for name, cell in pairs(self.rightBarList) do - if moduleKey == cell:getModuleKey() then - return cell:getBaseObject():getPosition() - end - end - return nil + for name, cell in pairs(self.leftBarList) do + if moduleKey == cell:getModuleKey() then + return cell:getBaseObject():getPosition() + end + end + for name, cell in pairs(self.rightBarList) do + if moduleKey == cell:getModuleKey() then + return cell:getBaseObject():getPosition() + end + end + return nil end function MainCityUI:isInSideBarLeft(moduleKey) - for name, cell in pairs(self.leftBarList) do - if moduleKey == cell:getModuleKey() then - return true - end - end - return false + for name, cell in pairs(self.leftBarList) do + if moduleKey == cell:getModuleKey() then + return true + end + end + return false end function MainCityUI:isInSideBarRight(moduleKey) - for name, cell in pairs(self.rightBarList) do - if moduleKey == cell:getModuleKey() then - return true - end - end - return false + for name, cell in pairs(self.rightBarList) do + if moduleKey == cell:getModuleKey() then + return true + end + end + return false end function MainCityUI:isActivSideBarModule(moduleKey) - for name, cell in pairs(self.leftBarList) do - if moduleKey == cell:getModuleKey() then - return cell:getIsActive() and cell:getIsVisible() - end - end - for name, cell in pairs(self.rightBarList) do - if moduleKey == cell:getModuleKey() then - return cell:getIsActive() and cell:getIsVisible() - end - end - return nil + for name, cell in pairs(self.leftBarList) do + if moduleKey == cell:getModuleKey() then + return cell:getIsActive() and cell:getIsVisible() + end + end + for name, cell in pairs(self.rightBarList) do + if moduleKey == cell:getModuleKey() then + return cell:getIsActive() and cell:getIsVisible() + end + end + return nil end function MainCityUI:getHeroComp() - return self.subComps[GConst.MainCityConst.BOTTOM_PAGE.HERO] + return self.subComps[GConst.MainCityConst.BOTTOM_PAGE.HERO] end return MainCityUI \ No newline at end of file