英雄解锁

This commit is contained in:
chenxi 2023-05-30 10:17:31 +08:00
parent 5565fb2f8c
commit 837f54acda
7 changed files with 134 additions and 3 deletions

View File

@ -104,12 +104,14 @@ function ChapterManager:endFightFinish(result)
data.max_chapter = newMaxChapter data.max_chapter = newMaxChapter
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
-- 标记可弹出新手礼包 -- 标记可弹出新手礼包
if newMaxChapter == 2 then if maxChapter == 1 then
DataManager.ShopData:markPopUpGiftForBeginnerGift() DataManager.ShopData:markPopUpGiftForBeginnerGift()
end end
-- 章节通关 标记可弹出章节礼包 -- 章节通关 标记可弹出章节礼包
DataManager.ShopData:markPopUpGiftForActChapterStore(newMaxChapter - 1) DataManager.ShopData:markPopUpGiftForActChapterStore(maxChapter)
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_PASS_CHAPTER) ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_PASS_CHAPTER)
-- 章节通关 检查是否要弹出英雄解锁界面
DataManager.HeroData:checkIfCanShowHeroUnlock(maxChapter)
end end
ModuleManager.TaskManager:addFightTaskProgress(reqData) ModuleManager.TaskManager:addFightTaskProgress(reqData)

View File

@ -4,6 +4,10 @@ function HeroManager:showHeroDetailUI(heroId)
UIManager:showUI("app/ui/hero/hero_detail_ui", {heroId = heroId}) UIManager:showUI("app/ui/hero/hero_detail_ui", {heroId = heroId})
end end
function HeroManager:showHeroUnlockUI(heroIdList)
UIManager:showUI("app/ui/hero/hero_unlock_ui", {heroIdList = heroIdList})
end
function HeroManager:upgradeHero(heroId, heroEntity) function HeroManager:upgradeHero(heroId, heroEntity)
local heroEntity = heroEntity or DataManager.HeroData:getHeroById(heroId) local heroEntity = heroEntity or DataManager.HeroData:getHeroById(heroId)
if not heroEntity then if not heroEntity then
@ -12,7 +16,6 @@ function HeroManager:upgradeHero(heroId, heroEntity)
local canLvUp, state = heroEntity:canLvUp(true) local canLvUp, state = heroEntity:canLvUp(true)
if not canLvUp then if not canLvUp then
-- 如果是金币不足 尝试触发金币礼包 -- 如果是金币不足 尝试触发金币礼包
if state == GConst.HeroConst.CHECK_LV_UP_STATE.COIN_NOT_ENOUGH then if state == GConst.HeroConst.CHECK_LV_UP_STATE.COIN_NOT_ENOUGH then
ModuleManager.ShopManager:tryTriggerCoinGift() ModuleManager.ShopManager:tryTriggerCoinGift()
@ -37,6 +40,10 @@ function HeroManager:getHeroName(id)
return I18N:getConfig("hero")[id].name return I18N:getConfig("hero")[id].name
end end
function HeroManager:getHeroDesc(id)
return I18N:getConfig("hero")[id].desc
end
function HeroManager:getHeroIcon(heroId) function HeroManager:getHeroIcon(heroId)
local cfg = ConfigManager:getConfig("hero")[heroId] local cfg = ConfigManager:getConfig("hero")[heroId]
return cfg and tostring(cfg.icon) return cfg and tostring(cfg.icon)

View File

@ -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

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 51bd98d3fbf493b44b3cbf37ead6a3ad
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -776,12 +776,22 @@ function MainCityUI:checkSideBarOpenStatus()
end end
end end
-- 弹窗优先级: 升级>功能弹窗>英雄解锁弹窗>礼包弹窗>引导
function MainCityUI:checkMainPop() function MainCityUI:checkMainPop()
-- 检查是否升级 -- 检查是否升级
if DataManager.PlayerData:getIfCanLevelUp() then if DataManager.PlayerData:getIfCanLevelUp() then
ModuleManager.PlayerManager:levelUp() ModuleManager.PlayerManager:levelUp()
return return
end 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 if self:checkTutorial() then

View File

@ -7,6 +7,8 @@ function HeroData:ctor()
self.data.isDirty = false self.data.isDirty = false
self.matchActiveHeroMap = {} self.matchActiveHeroMap = {}
self.maxHeroLvOnInit = 0 self.maxHeroLvOnInit = 0
self.showHeroUnlockChapter = 0
self.heroChapterUnlockMap = {}
end end
function HeroData:clear() function HeroData:clear()
@ -15,6 +17,9 @@ end
function HeroData:init(data) function HeroData:init(data)
self.heroes = {} self.heroes = {}
for k, v in pairs(self.heroChapterUnlockMap) do
self.heroChapterUnlockMap[k] = false
end
if data then if data then
for id, heroInfo in pairs(data) do for id, heroInfo in pairs(data) do
self:addHero(heroInfo.id, heroInfo.level) self:addHero(heroInfo.id, heroInfo.level)
@ -34,7 +39,11 @@ function HeroData:init(data)
end end
self.matchActiveHeroMap[matchType][entity:getCfgId()] = true self.matchActiveHeroMap[matchType][entity:getCfgId()] = true
end end
if info.unlock_chapter and info.is_show == 1 then
self.heroChapterUnlockMap[info.unlock_chapter] = true
end
end end
self.showHeroUnlockChapter = 0
end end
function HeroData:addHero(cfgId, lv) function HeroData:addHero(cfgId, lv)
@ -132,4 +141,29 @@ function HeroData:getMaxHeroLvOnInit()
return self.maxHeroLvOnInit return self.maxHeroLvOnInit
end 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 return HeroData

View File

@ -225,6 +225,11 @@ function HeroEntity:getName()
return ModuleManager.HeroManager:getHeroName(self:getCfgId()) return ModuleManager.HeroManager:getHeroName(self:getCfgId())
end end
function HeroEntity:getDesc()
return ModuleManager.HeroManager:getHeroDesc(self:getCfgId())
end
function HeroEntity:getActiveRogueCount() function HeroEntity:getActiveRogueCount()
local lvInfo = ConfigManager:getConfig("hero_level")[self.data.lv] local lvInfo = ConfigManager:getConfig("hero_level")[self.data.lv]
if not lvInfo then if not lvInfo then