From 9830ac3cbdccd8a59144dc1b65a4a4ec661f73eb Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 24 May 2023 18:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E6=8C=91=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/data_manager.lua | 3 + lua/app/common/module_manager.lua | 5 +- lua/app/module/daily_challenge.meta | 8 + .../daily_challenge_manager.lua | 27 ++ .../daily_challenge_manager.lua.meta | 10 + lua/app/module/maincity/maincity_const.lua | 2 + .../ui/main_city/component/chapter_comp.lua | 157 +++++++++ .../main_city/component/chapter_comp.lua.meta | 10 + .../component/daily_challenge_comp.lua | 10 + .../component/daily_challenge_comp.lua.meta | 10 + lua/app/ui/main_city/component/main_comp.lua | 298 +++++++++--------- lua/app/userdata/daily_challenge.meta | 8 + .../daily_challenge/daily_challenge_data.lua | 67 ++++ .../daily_challenge_data.lua.meta | 10 + 14 files changed, 471 insertions(+), 154 deletions(-) create mode 100644 lua/app/module/daily_challenge.meta create mode 100644 lua/app/module/daily_challenge/daily_challenge_manager.lua create mode 100644 lua/app/module/daily_challenge/daily_challenge_manager.lua.meta create mode 100644 lua/app/ui/main_city/component/chapter_comp.lua create mode 100644 lua/app/ui/main_city/component/chapter_comp.lua.meta create mode 100644 lua/app/ui/main_city/component/daily_challenge_comp.lua create mode 100644 lua/app/ui/main_city/component/daily_challenge_comp.lua.meta create mode 100644 lua/app/userdata/daily_challenge.meta create mode 100644 lua/app/userdata/daily_challenge/daily_challenge_data.lua create mode 100644 lua/app/userdata/daily_challenge/daily_challenge_data.lua.meta diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index 192e8d2f..baee6529 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -8,6 +8,7 @@ function DataManager:init() self:initManager("GameSettingData", "app/userdata/game_setting/game_setting_data") self:initManager("PlayerData", "app/userdata/player/player_data") self:initManager("ChapterData", "app/userdata/chapter/chapter_data") + self:initManager("DailyChallengeData", "app/userdata/daily_challenge/daily_challenge_data") self:initManager("HeroData", "app/userdata/hero/hero_data") self:initManager("BagData", "app/userdata/bag/bag_data") self:initManager("BattleData", "app/userdata/battle/battle_data") @@ -83,6 +84,7 @@ function DataManager:clear() self.cdCallBack = {} self.PlayerData:clear() self.ChapterData:clear() + self.DailyChallengeData:clear() self.HeroData:clear() self.BagData:clear() self.FormationData:clear() @@ -115,6 +117,7 @@ function DataManager:initWithServerData(data) self.todayFirstLogin = data.today_first_login self.PlayerData:init(data) self.ChapterData:init(data.chapter) + self.DailyChallengeData:init(data.daily_challenge) self.HeroData:init(data.bag.heroes) self.BagData:init(data.bag) self.FormationData:init(data.fight_info) diff --git a/lua/app/common/module_manager.lua b/lua/app/common/module_manager.lua index 290a7089..6368edf2 100644 --- a/lua/app/common/module_manager.lua +++ b/lua/app/common/module_manager.lua @@ -23,6 +23,8 @@ local MODULE_PATHS = { HeroManager = "app/module/hero/hero_manager", -- 主线关卡 ChapterManager = "app/module/chapter/chapter_manager", + -- 每日挑战 + DailyChallengeManager = "app/module/daily_challenge/daily_challenge", -- 挂机 IdleManager = "app/module/idle/idle_manager", -- 七天乐 @@ -60,7 +62,8 @@ ModuleManager.MODULE_KEY = { IDLE_DROP = "idle_drop", MALL = "mall", -- 商城 MALL_DAILY = "mall_daily", -- 每日商城 - FUND = "act_level_gift" -- 成长基金 + FUND = "act_level_gift", -- 成长基金 + DAILY_CHALLENGE = "daily_challenge", -- 每日挑战 } local _moduleMgrs = {} diff --git a/lua/app/module/daily_challenge.meta b/lua/app/module/daily_challenge.meta new file mode 100644 index 00000000..9fdaf574 --- /dev/null +++ b/lua/app/module/daily_challenge.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 435eab567f894094e81a6a21e2d27c81 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/module/daily_challenge/daily_challenge_manager.lua b/lua/app/module/daily_challenge/daily_challenge_manager.lua new file mode 100644 index 00000000..6127e421 --- /dev/null +++ b/lua/app/module/daily_challenge/daily_challenge_manager.lua @@ -0,0 +1,27 @@ +local DailyChallengeManager = class("DailyChallengeManager", BaseModule) + +function DailyChallengeManager:init() + -- body +end + +-- 开始挑战 +function DailyChallengeManager:startChallenge() + -- body +end + +-- 挑战结束 +function DailyChallengeManager:endChallenge() + -- 挑战完成固定会给战斗奖励 +end + +-- 获取波次(战斗)奖励 +function DailyChallengeManager:getWaveReward() + -- body +end + +-- 获取任务(箱子)奖励 +function DailyChallengeManager:getTaskReward(taskId) + -- 跨天通关时,不算完成第二天的任务 +end + +return DailyChallengeManager \ No newline at end of file diff --git a/lua/app/module/daily_challenge/daily_challenge_manager.lua.meta b/lua/app/module/daily_challenge/daily_challenge_manager.lua.meta new file mode 100644 index 00000000..925317e2 --- /dev/null +++ b/lua/app/module/daily_challenge/daily_challenge_manager.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b274d9b19c46e4e45833236e6f87983b +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/module/maincity/maincity_const.lua b/lua/app/module/maincity/maincity_const.lua index 1ec1011a..26dc2d3f 100644 --- a/lua/app/module/maincity/maincity_const.lua +++ b/lua/app/module/maincity/maincity_const.lua @@ -13,6 +13,8 @@ MainCityConst.BOTTOM_CLOSE_ICON = { } MainCityConst.BOTTOM_MODULE_KEY = { + DAILY_CHALLENGE = 1, + CHAPTER = 2, } MainCityConst.LEFT_SIDE_BARS = { diff --git a/lua/app/ui/main_city/component/chapter_comp.lua b/lua/app/ui/main_city/component/chapter_comp.lua new file mode 100644 index 00000000..dbeb7425 --- /dev/null +++ b/lua/app/ui/main_city/component/chapter_comp.lua @@ -0,0 +1,157 @@ +local ChapterComp = class("ChapterComp", LuaComponent) +local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png" + +local BOX_ICON = { + "common_chest_1", + "common_chest_4" +} + +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) +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 + self.chapterImg:setTexture(string.format(CHAPTER_PATH, chapterInfo.icon)) + 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 mysteryBoxIcon = self.uiMap["chapter.img.mystery_box_icon"] + mysteryBoxIcon:setVisible(mysteryBoxCount > 0) + if mysteryBoxCount > 0 then + local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId) + self.uiMap["chapter.img.mystery_box_icon.desc"]:setText(gotCount .. "/" .. mysteryBoxCount) + 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", true, false, function() + objs.spineObj:setVisible(false) + 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.root:refreshFightBtn() + end +end + +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 new file mode 100644 index 00000000..376736c0 --- /dev/null +++ b/lua/app/ui/main_city/component/chapter_comp.lua.meta @@ -0,0 +1,10 @@ +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 new file mode 100644 index 00000000..66195e77 --- /dev/null +++ b/lua/app/ui/main_city/component/daily_challenge_comp.lua @@ -0,0 +1,10 @@ +local DailyChallengeComp = class("DailyChallengeComp", LuaComponent) + +function DailyChallengeComp:ctor() +end + +function DailyChallengeComp:init() + self.uiMap = self:getBaseObject():genAllChildren() +end + +return DailyChallengeComp \ No newline at end of file diff --git a/lua/app/ui/main_city/component/daily_challenge_comp.lua.meta b/lua/app/ui/main_city/component/daily_challenge_comp.lua.meta new file mode 100644 index 00000000..2f1694e1 --- /dev/null +++ b/lua/app/ui/main_city/component/daily_challenge_comp.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 78833330e8bfc1f418a078dbd9058f86 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index db1172a7..f8e14f60 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -1,41 +1,157 @@ local MainComp = class("MainComp", LuaComponent) -local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png" +local CHAPTER_COMP = "app/ui/main_city/component/chapter_comp" +local DAILY_CHALLENGE_COMP = "app/ui/main_city/component/daily_challenge_comp" -local BOX_ICON = { - "common_chest_1", - "common_chest_4" +local MODULE_DATA = { + [1] = { + ["type"] = GConst.MainCityConst.BOTTOM_MODULE_KEY.DAILY_CHALLENGE, + ["title"] = "每日挑战",-- 标题 + ["atlas"] = GConst.ATLAS_PATH.ICON_ITEM,-- 图集路径 + ["icon"] = "1",-- 图片名 + ["numFunc"] = function()-- 挑战按钮显示数值 + return nil + end, + ["clickFunc"] = function()-- 点击回调 + Logger.logHighlight("点击每日挑战") + end + }, + [2] = { + ["type"] = GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER, + ["title"] = "主线章节", + ["atlas"] = GConst.ATLAS_PATH.ICON_ITEM, + ["icon"] = "2", + ["numFunc"] = function() + return DataManager.ChapterData:getFightCost() + end, + ["clickFunc"] = function() + ModuleManager.ChapterManager:startFight() + end + } } function MainComp:init() self.uiMap = self:getBaseObject():genAllChildren() - self:initChapter() + + self.curModuleType = GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER + self:initStageFormation() + self:refreshBtns() + self:refreshModuleComp() end -function MainComp:initChapter() - self.chapterImg = self.uiMap["main_comp.chapter.img"] - self.chapterNameTx = self.uiMap["main_comp.chapter.name_tx"] - self.chapterWavetx = self.uiMap["main_comp.chapter.record_tx"] - self.leftArrow = self.uiMap["main_comp.chapter.left_arrow"] - local leftArrowBtn = self.uiMap["main_comp.chapter.left_arrow.btn"] - leftArrowBtn:addClickListener(function() - if DataManager.ChapterData:goLastChapter() then - self:refresh() - end - end) - self.rightArrow = self.uiMap["main_comp.chapter.right_arrow"] - local rightArrowBtn = self.uiMap["main_comp.chapter.right_arrow.btn"] - rightArrowBtn:addClickListener(function() - if DataManager.ChapterData:goNextChapter() then - self:refresh() - end - end) - local fightBtn = self.uiMap["main_comp.fight_btn"] - fightBtn:addClickListener(function() - self:onFightBtnClick() - end) +function MainComp:refreshModuleComp() + if not self.chapterComp then + -- 章节 + local chapterComp = self.uiMap["main_comp.chapter_comp"] + chapterComp:initPrefabHelper() + chapterComp:genAllChildren() + self.chapterComp = chapterComp:addLuaComponent(CHAPTER_COMP) + self.chapterComp.root = self + end - self.uiMap["main_comp.chapter.effect_node.ui_spine_obj"]:playAnim("idle", true, false) + if not self.dailyChallengeComp then + -- 每日挑战 + local dailyChallengeComp = self.uiMap["main_comp.daily_challenge_comp"] + dailyChallengeComp:initPrefabHelper() + dailyChallengeComp:genAllChildren() + dailyChallengeComp:setActive(false) + self.dailyChallengeComp = dailyChallengeComp:addLuaComponent(DAILY_CHALLENGE_COMP) + self.dailyChallengeComp.root = self + end + + self.chapterComp:getBaseObject():setActive(false) + self.dailyChallengeComp:getBaseObject():setActive(false) + if self.curModuleType == GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER then + self.chapterComp:getBaseObject():setActive(true) + elseif self.curModuleType == GConst.MainCityConst.BOTTOM_MODULE_KEY.DAILY_CHALLENGE then + self.dailyChallengeComp:getBaseObject():setActive(true) + end +end + +function MainComp:refreshBtns() + self:refreshFightBtn() + self:refreshLeftBtn() + self:refreshRightBtn() +end + +function MainComp:refreshFightBtn() + local module = nil + for type, data in pairs(MODULE_DATA) do + if self.curModuleType == type then + module = data + end + end + if not module then + return + end + + self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) + local cost = module["numFunc"]() + if cost then + self.uiMap["main_comp.fight_btn.desc_2"]:setText(GFunc.getRewardNum(cost)) + else + self.uiMap["main_comp.fight_btn.desc_2"]:setText("0") + end + + self.uiMap["main_comp.fight_btn"]:addClickListener(module["clickFunc"]) +end + +function MainComp:refreshLeftBtn() + local module = MODULE_DATA[self:getCurLeftModuleIdx()] + if module == nil then + self.uiMap["main_comp.left_btn"]:setActive(false) + return + end + + self.uiMap["main_comp.left_btn"]:setActive(true) + self.uiMap["main_comp.left_btn.desc"]:setText(module["title"]) + self.uiMap["main_comp.left_btn.icon"]:setSprite(module["atlas"],module["icon"]) + self.uiMap["main_comp.left_btn"]:addClickListener(function() + self.curModuleType = module["type"] + self:refreshBtns() + self:refreshModuleComp() + end) +end + +function MainComp:refreshRightBtn() + local module = MODULE_DATA[self:getCurRightModuleIdx()] + if module == nil then + self.uiMap["main_comp.right_btn"]:setActive(false) + return + end + + self.uiMap["main_comp.right_btn"]:setActive(true) + self.uiMap["main_comp.right_btn.desc"]:setText(module["title"]) + self.uiMap["main_comp.right_btn.icon"]:setSprite(module["atlas"],module["icon"]) + self.uiMap["main_comp.right_btn"]:addClickListener(function() + self.curModuleType = module["type"] + self:refreshBtns() + self:refreshModuleComp() + end) +end + +function MainComp:getCurLeftModuleIdx() + for idx, data in pairs(MODULE_DATA) do + if self.curModuleType == data["type"] then + if idx == 1 then + return nil + else + return idx - 1 + end + end + end +end + +function MainComp:getCurRightModuleIdx() + for idx, data in pairs(MODULE_DATA) do + if self.curModuleType == data["type"] then + if idx == #MODULE_DATA then + return nil + else + return idx + 1 + end + end + end end function MainComp:initStageFormation() @@ -49,135 +165,11 @@ function MainComp:initStageFormation() end function MainComp:refresh() - self:refreshChapter() self:refreshStageFormaion() end -function MainComp:onFightBtnClick() - ModuleManager.ChapterManager:startFight() -end - function MainComp: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 - self.chapterImg:setTexture(string.format(CHAPTER_PATH, chapterInfo.icon)) - 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.chapter.progress_bg.slider"] - if not self.boxObjs then - self.boxObjs = {} - for i = 1, 3 do - self.boxObjs[i] = { - box = self.uiMap["main_comp.chapter.progress_bg.box_" .. i], - desc = self.uiMap["main_comp.chapter.progress_bg.box_desc_" .. i], - spineObj = self.uiMap["main_comp.chapter.progress_bg.spine_node.ui_spine_obj_" .. i], - boxIcon = self.uiMap["main_comp.chapter.progress_bg.box_" .. i .. ".box_icon"] - } - end - end - - local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId) - local mysteryBoxIcon = self.uiMap["main_comp.chapter.img.mystery_box_icon"] - mysteryBoxIcon:setVisible(mysteryBoxCount > 0) - if mysteryBoxCount > 0 then - local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId) - self.uiMap["main_comp.chapter.img.mystery_box_icon.desc"]:setText(gotCount .. "/" .. mysteryBoxCount) - 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", true, false, function() - objs.spineObj:setVisible(false) - 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.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) - local cost = DataManager.ChapterData:getFightCost() - if cost then - self.uiMap["main_comp.fight_btn.desc_2"]:setText(GFunc.getRewardNum(cost)) - else - self.uiMap["main_comp.fight_btn.desc_2"]:setText("0") - end - end + self.chapterComp:refreshChapter(force) end function MainComp:refreshStageFormaion() diff --git a/lua/app/userdata/daily_challenge.meta b/lua/app/userdata/daily_challenge.meta new file mode 100644 index 00000000..df2c77cc --- /dev/null +++ b/lua/app/userdata/daily_challenge.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb475e2297dca58498f1e412443a2899 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/userdata/daily_challenge/daily_challenge_data.lua b/lua/app/userdata/daily_challenge/daily_challenge_data.lua new file mode 100644 index 00000000..c59fb8ae --- /dev/null +++ b/lua/app/userdata/daily_challenge/daily_challenge_data.lua @@ -0,0 +1,67 @@ +local DailyChallengeData = class("DailyChallengeData", BaseData) + +function DailyChallengeData:init(data) + -- 服务器的初始数据 +end + +function DailyChallengeData:clear() +end + +function DailyChallengeData:isOpen() + return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DAILY_CHALLENGE, true) +end + +-- 是否满足挑战条件 +function DailyChallengeData:isMeetChallenge() + return self:isOpen() and self:isEnoughChallengeTime() and self:isEnoughHp() +end + +-- 次数是否足够 +function DailyChallengeData:isEnoughChallengeTime() + return true +end + +-- 体力是否足够 +function DailyChallengeData:isEnoughHp() + return true +end + +-- 获取今日挑战场景配置 +function DailyChallengeData:getTodayConfig() + -- body +end + +-- 获取今日挑战任务和奖励 +function DailyChallengeData:getTodayTaskAndReward() + -- 三个任务需要区分类型,如: + -- 第一个:通关 + -- 第二个:用xxx通关 + -- 第三个:x回合杀怪、x颜色英雄技能释放几次 +end + +-- 获取今日通关次数 +function DailyChallengeData:getTodayPassNum() + -- body +end + +-- 获取今日增益、负面buff +function DailyChallengeData:getTodayBuff() + -- body +end + +-- 获取今日剩余时间 +function DailyChallengeData:getTodaySurplusTime() + -- body +end + +-- 获取boss配置数据 +function DailyChallengeData:getBossData(bossId) + -- body +end + +-- 任务是否完成 +function DailyChallengeData:isTaskFinish(taskId) + -- body +end + +return DailyChallengeData \ No newline at end of file diff --git a/lua/app/userdata/daily_challenge/daily_challenge_data.lua.meta b/lua/app/userdata/daily_challenge/daily_challenge_data.lua.meta new file mode 100644 index 00000000..def1e28d --- /dev/null +++ b/lua/app/userdata/daily_challenge/daily_challenge_data.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8a47285265cc9b64798079b605d13684 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}