diff --git a/lua/app/common/event_manager.lua b/lua/app/common/event_manager.lua index c4b8ff53..1e12eb58 100644 --- a/lua/app/common/event_manager.lua +++ b/lua/app/common/event_manager.lua @@ -33,6 +33,8 @@ EventManager.CUSTOM_EVENT = { CLOSE_BOX_HERO_UI = "CLOSE_BOX_HERO_UI", CLOSE_BOX_OPEN_UI = "CLOSE_BOX_OPEN_UI", BIND_ACCOUNT_SUCCESS = "BIND_ACCOUNT_SUCCESS", + DUNGEON_CHALLENGE = "DUNGEON_CHALLENGE",-- 副本开始挑战 + DUNGEON_SWEEP = "DUNGEON_SWEEP",-- 副本开始扫荡 -- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN", -- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER" } diff --git a/lua/app/module/dungeon/dungeon_manager.lua b/lua/app/module/dungeon/dungeon_manager.lua index 9a4afa25..dc44f858 100644 --- a/lua/app/module/dungeon/dungeon_manager.lua +++ b/lua/app/module/dungeon/dungeon_manager.lua @@ -32,6 +32,9 @@ end -- 内部接口-------------------------------------------------------------------------- function DungeonManager:checkDayChange() + if EDITOR_MODE then + Logger.logHighlight("检查跨天:".. tostring(DataManager.DungeonData:getIfCanReset())) + end if not DataManager.DungeonData:getIfCanReset() then return end @@ -44,7 +47,7 @@ end function DungeonManager:reqChallengeGold(id) local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD -- 判断次数 - if not (DataManager.DungeonData:getRemainTimes(moduleKey) > 0) then + if DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) return end @@ -70,6 +73,7 @@ function DungeonManager:respChallengeGold(result) DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_GOLD) DataManager.DungeonData:setCurFightChapterId(result.reqData.chapter_gold_id) ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DUNGEON_GOLD) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_CHALLENGE) end end @@ -98,7 +102,7 @@ end function DungeonManager:reqSweepGold(id) local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD -- 判断次数 - if not (DataManager.DungeonData:getRemainTimes(moduleKey) > 0) then + if DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) return end @@ -124,14 +128,15 @@ end function DungeonManager:respSweepGold(result) if result.err_code == GConst.ERROR_STR.SUCCESS then DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_GOLD) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_SWEEP) end end -- 请求挑战碎片副本 function DungeonManager:reqChallengeShards(id) - local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD + local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_SHARDS -- 判断次数 - if not (DataManager.DungeonData:getRemainTimes(moduleKey) > 0) then + if DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) return end @@ -157,6 +162,7 @@ function DungeonManager:respChallengeShards(result) DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_SHARDS) DataManager.DungeonData:setCurFightChapterId(result.reqData.chapter_shards_id) ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DUNGEON_SHARDS) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_CHALLENGE) end end @@ -184,7 +190,7 @@ end function DungeonManager:reqSweepShards(id) local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_SHARDS -- 判断次数 - if not (DataManager.DungeonData:getRemainTimes(moduleKey) > 0) then + if DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) return end @@ -210,6 +216,7 @@ end function DungeonManager:respSweepShards(result) if result.err_code == GConst.ERROR_STR.SUCCESS then DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_SHARDS) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_SWEEP) end end diff --git a/lua/app/ui/dungeon/dungeon_difficulty_ui.lua b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua index 0f31f396..f7bb1a0c 100644 --- a/lua/app/ui/dungeon/dungeon_difficulty_ui.lua +++ b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua @@ -100,6 +100,13 @@ function DungeonDifficultyUI:onLoadRootComplete() self.curId = self.curId + 1 self:refreshDifficulty() end) + + self:addEventListener(EventManager.CUSTOM_EVENT.DUNGEON_CHALLENGE, function() + self:closeUI() + end) + self:addEventListener(EventManager.CUSTOM_EVENT.DUNGEON_SWEEP, function() + self:closeUI() + end) end function DungeonDifficultyUI:refreshDifficulty() diff --git a/lua/app/ui/main_city/component/dungeon_comp.lua b/lua/app/ui/main_city/component/dungeon_comp.lua index c5e72239..192883ae 100644 --- a/lua/app/ui/main_city/component/dungeon_comp.lua +++ b/lua/app/ui/main_city/component/dungeon_comp.lua @@ -41,6 +41,9 @@ function DungeonComp:init() end function DungeonComp:refreshShow() + if EDITOR_MODE then + Logger.logHighlight("更新副本显示."..tostring(Time:getTodaySurplusTime())) + end self.openDungeons = DataManager.DungeonData:getOpenDungeons() if self.scrollRectComp:getTotalCount() ~= #self.openDungeons then self.scrollRectComp:clearCells() @@ -56,7 +59,7 @@ function DungeonComp:refreshShow() end self.countdownSid = self:getBaseObject():scheduleGlobal(function() ModuleManager.DungeonManager:checkDayChange() - end, Time:getTodaySurplusTime()) + end, Time:getTodaySurplusTime() + 1) end diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 83a183b6..a8fadff1 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -237,7 +237,7 @@ function MainCityUI:_bind() end end) - self:bind(DataManager.DailyChallengeData, "isDirty", function() + 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() diff --git a/lua/app/userdata/dungeon/dungeon_data.lua b/lua/app/userdata/dungeon/dungeon_data.lua index 3d2fd1c5..d04dc6fb 100644 --- a/lua/app/userdata/dungeon/dungeon_data.lua +++ b/lua/app/userdata/dungeon/dungeon_data.lua @@ -21,6 +21,11 @@ function DungeonData:initDungeonGold(data) return end + if EDITOR_MODE then + Logger.logHighlight("更新金币副本数据") + Logger.printTable(data) + end + self:initAllDataClass() self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_GOLD]:init(data) self.data.gold = data @@ -33,6 +38,11 @@ function DungeonData:initDungeonShards(data) return end + if EDITOR_MODE then + Logger.logHighlight("更新碎片副本数据") + Logger.printTable(data) + end + self:initAllDataClass() self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_SHARDS]:init(data) self.data.shards = data @@ -45,6 +55,10 @@ function DungeonData:initAllDataClass() self.dataDungeons = {} self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_GOLD] = require "app/userdata/dungeon/dungeon_gold_data_comp":create() self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_SHARDS] = require "app/userdata/dungeon/dungeon_shards_data_comp":create() + + if EDITOR_MODE then + Logger.logHighlight("星期".. tostring(Time:getWeekByTimeStamp())) + end end self.initDay = Time:getBeginningOfServerToday() @@ -60,7 +74,7 @@ function DungeonData:onDayChange() self.data.shards.today_challenge_count = 0 self:initDungeonGold(self.data.gold) - self:initDungeonGold(self.data.shards) + self:initDungeonShards(self.data.shards) end -- 客户端处理副本次数+1的情况 @@ -70,7 +84,7 @@ function DungeonData:onFightCountReduce(moduleKey) self:initDungeonGold(self.data.gold) elseif moduleKey == ModuleManager.MODULE_KEY.DUNGEON_SHARDS then self.data.shards.today_challenge_count = self.data.shards.today_challenge_count + 1 - self:initDungeonGold(self.data.shards) + self:initDungeonShards(self.data.shards) end end diff --git a/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua b/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua index 69f89208..6bf0eb71 100644 --- a/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua +++ b/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua @@ -37,6 +37,10 @@ function DungeonShardsDataComp:getTitleString() return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_SHARDS_TITLE) end +function DungeonShardsDataComp:getRuleString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_SHARDS_HELP) +end + function DungeonShardsDataComp:getOpenWeekString() return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_SHARDS_OPEN) end