From 837f54acda55dd24c83af31b143185bb159b10b5 Mon Sep 17 00:00:00 2001 From: chenxi Date: Tue, 30 May 2023 10:17:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E8=A7=A3=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/chapter/chapter_manager.lua | 6 ++- lua/app/module/hero/hero_manager.lua | 9 +++- lua/app/ui/hero/hero_unlock_ui.lua | 63 ++++++++++++++++++++++ lua/app/ui/hero/hero_unlock_ui.lua.meta | 10 ++++ lua/app/ui/main_city/main_city_ui.lua | 10 ++++ lua/app/userdata/hero/hero_data.lua | 34 ++++++++++++ lua/app/userdata/hero/hero_entity.lua | 5 ++ 7 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 lua/app/ui/hero/hero_unlock_ui.lua create mode 100644 lua/app/ui/hero/hero_unlock_ui.lua.meta diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index 9c527eac..13695918 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -104,12 +104,14 @@ function ChapterManager:endFightFinish(result) data.max_chapter = newMaxChapter CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) -- 标记可弹出新手礼包 - if newMaxChapter == 2 then + if maxChapter == 1 then DataManager.ShopData:markPopUpGiftForBeginnerGift() end -- 章节通关 标记可弹出章节礼包 - DataManager.ShopData:markPopUpGiftForActChapterStore(newMaxChapter - 1) + DataManager.ShopData:markPopUpGiftForActChapterStore(maxChapter) ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_PASS_CHAPTER) + -- 章节通关 检查是否要弹出英雄解锁界面 + DataManager.HeroData:checkIfCanShowHeroUnlock(maxChapter) end ModuleManager.TaskManager:addFightTaskProgress(reqData) diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index 2be9b40a..da47b2e1 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -4,6 +4,10 @@ function HeroManager:showHeroDetailUI(heroId) UIManager:showUI("app/ui/hero/hero_detail_ui", {heroId = heroId}) end +function HeroManager:showHeroUnlockUI(heroIdList) + UIManager:showUI("app/ui/hero/hero_unlock_ui", {heroIdList = heroIdList}) +end + function HeroManager:upgradeHero(heroId, heroEntity) local heroEntity = heroEntity or DataManager.HeroData:getHeroById(heroId) if not heroEntity then @@ -12,7 +16,6 @@ function HeroManager:upgradeHero(heroId, heroEntity) local canLvUp, state = heroEntity:canLvUp(true) if not canLvUp then - -- 如果是金币不足 尝试触发金币礼包 if state == GConst.HeroConst.CHECK_LV_UP_STATE.COIN_NOT_ENOUGH then ModuleManager.ShopManager:tryTriggerCoinGift() @@ -37,6 +40,10 @@ function HeroManager:getHeroName(id) return I18N:getConfig("hero")[id].name end +function HeroManager:getHeroDesc(id) + return I18N:getConfig("hero")[id].desc +end + function HeroManager:getHeroIcon(heroId) local cfg = ConfigManager:getConfig("hero")[heroId] return cfg and tostring(cfg.icon) diff --git a/lua/app/ui/hero/hero_unlock_ui.lua b/lua/app/ui/hero/hero_unlock_ui.lua new file mode 100644 index 00000000..52c00908 --- /dev/null +++ b/lua/app/ui/hero/hero_unlock_ui.lua @@ -0,0 +1,63 @@ +local HeroUnlockUI = class("HeroUnlockUI", BaseUI) + +function HeroUnlockUI:getPrefabPath() + return "assets/prefabs/ui/hero/hero_unlock_ui.prefab" +end + +function HeroUnlockUI:ctor(params) + self.heroIdList = params and params.heroIdList +end + +function HeroUnlockUI:onLoadRootComplete() + self.uiMap = self.root:genAllChildren() + self.uiMap["hero_unlock_ui.bg"]:addClickListener(function() + self:closeUI() + end) + self:initTitleAndDesc() + self:initHeroes() +end + +function HeroUnlockUI:initTitleAndDesc() + self.uiMap["player_level_up_ui.title_tx"]:setText("临时文本:英雄解锁") + self.uiMap["player_level_up_ui.reward_title"]:setText("临时文本:现在可从宝箱中获得") + self.uiMap["player_level_up_ui.continue"]:setText("临时文本:点击继续") +end + +function HeroUnlockUI:initHeroes() + if self.heroIdList then + local count = #self.heroIdList + if count > 3 then + count = 3 + end + if count > 0 then + for i = 1, count do + local heroEntity = DataManager.HeroData:getHeroById(self.heroIdList[i]) + self.uiMap["hero_unlock_ui.bg_" .. i]:setVisible(true) + local rewardCell = self.uiMap["hero_unlock_ui.bg_" .. i .. ".reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL) + rewardCell:refreshItemById(heroEntity:getFragmentId(), 0) + self.uiMap["hero_unlock_ui.bg_" .. i .. ".name_tx"]:setText(heroEntity:getName()) + self.uiMap["hero_unlock_ui.bg_" .. i .. ".desc_tx"]:setText(heroEntity:getDesc()) + end + for i = count + 1, 3 do + self.uiMap["hero_unlock_ui.bg_" .. i]:setVisible(false) + end + if count == 1 then + self.uiMap["hero_unlock_ui.bg_1"]:setAnchoredPositionY(100) + else + self.uiMap["hero_unlock_ui.bg_1"]:setAnchoredPositionY(180) + end + else + self:hideAllHeroes() + end + else + self:hideAllHeroes() + end +end + +function HeroUnlockUI:hideAllHeroes() + self.uiMap["hero_unlock_ui.bg_1"]:setVisible(false) + self.uiMap["hero_unlock_ui.bg_2"]:setVisible(false) + self.uiMap["hero_unlock_ui.bg_3"]:setVisible(false) +end + +return HeroUnlockUI \ No newline at end of file diff --git a/lua/app/ui/hero/hero_unlock_ui.lua.meta b/lua/app/ui/hero/hero_unlock_ui.lua.meta new file mode 100644 index 00000000..00a172bb --- /dev/null +++ b/lua/app/ui/hero/hero_unlock_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 51bd98d3fbf493b44b3cbf37ead6a3ad +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index a5e20f6c..30ca9c22 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -776,12 +776,22 @@ function MainCityUI:checkSideBarOpenStatus() end end +-- 弹窗优先级: 升级>功能弹窗>英雄解锁弹窗>礼包弹窗>引导 function MainCityUI:checkMainPop() -- 检查是否升级 if DataManager.PlayerData:getIfCanLevelUp() then ModuleManager.PlayerManager:levelUp() 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 diff --git a/lua/app/userdata/hero/hero_data.lua b/lua/app/userdata/hero/hero_data.lua index f397a7c5..c0e3f17a 100644 --- a/lua/app/userdata/hero/hero_data.lua +++ b/lua/app/userdata/hero/hero_data.lua @@ -7,6 +7,8 @@ function HeroData:ctor() self.data.isDirty = false self.matchActiveHeroMap = {} self.maxHeroLvOnInit = 0 + self.showHeroUnlockChapter = 0 + self.heroChapterUnlockMap = {} end function HeroData:clear() @@ -15,6 +17,9 @@ end function HeroData:init(data) self.heroes = {} + for k, v in pairs(self.heroChapterUnlockMap) do + self.heroChapterUnlockMap[k] = false + end if data then for id, heroInfo in pairs(data) do self:addHero(heroInfo.id, heroInfo.level) @@ -34,7 +39,11 @@ function HeroData:init(data) end self.matchActiveHeroMap[matchType][entity:getCfgId()] = true end + if info.unlock_chapter and info.is_show == 1 then + self.heroChapterUnlockMap[info.unlock_chapter] = true + end end + self.showHeroUnlockChapter = 0 end function HeroData:addHero(cfgId, lv) @@ -132,4 +141,29 @@ function HeroData:getMaxHeroLvOnInit() return self.maxHeroLvOnInit end +function HeroData:getIfCanShowHeroUnlock() + return self.showHeroUnlockChapter > 0 +end + +function HeroData:markShowHeroUnlock() + self.showHeroUnlockChapter = 0 +end + +function HeroData:checkIfCanShowHeroUnlock(chapterId) + if not self.heroChapterUnlockMap[chapterId] then + return + end + self.showHeroUnlockChapter = chapterId +end + +function HeroData:getHeroChapterUnlockList() + local list = {} + for id, entity in pairs(self.heroes) do + if not entity:isActived() and entity:getUnlcokChapter() == self.showHeroUnlockChapter then + table.insert(list, id) + end + end + return list +end + return HeroData \ No newline at end of file diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index f55e40d6..c381ffb3 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -225,6 +225,11 @@ function HeroEntity:getName() return ModuleManager.HeroManager:getHeroName(self:getCfgId()) end +function HeroEntity:getDesc() + return ModuleManager.HeroManager:getHeroDesc(self:getCfgId()) +end + + function HeroEntity:getActiveRogueCount() local lvInfo = ConfigManager:getConfig("hero_level")[self.data.lv] if not lvInfo then