礼包
This commit is contained in:
parent
b784b7aeda
commit
4fa2d67de2
@ -399,15 +399,6 @@ if NOT_PUBLISH then
|
||||
Logger.printTable(map)
|
||||
end
|
||||
end
|
||||
|
||||
if Input.GetKeyDown(KeyCode.Q) then
|
||||
-- 标记可弹出新手礼包
|
||||
DataManager.ShopData:markPopUpGiftForBeginnerGift()
|
||||
end
|
||||
if Input.GetKeyDown(KeyCode.W) then
|
||||
-- 章节通关 标记可弹出章节礼包
|
||||
DataManager.ShopData:markPopUpGiftForActChapterStore(4)
|
||||
end
|
||||
end
|
||||
|
||||
Game._releaseOnApplicationFocus = Game.onApplicationFocus
|
||||
|
||||
@ -98,9 +98,8 @@ function ChapterManager:endFightFinish(result)
|
||||
local data = {}
|
||||
data.max_chapter = newMaxChapter
|
||||
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
|
||||
|
||||
-- 标记可弹出新手礼包
|
||||
if newMaxChapter == 1 then
|
||||
if newMaxChapter == 2 then
|
||||
DataManager.ShopData:markPopUpGiftForBeginnerGift()
|
||||
end
|
||||
-- 章节通关 标记可弹出章节礼包
|
||||
|
||||
@ -21,11 +21,16 @@ function ShopManager:showBoxLevelUpUI(params)
|
||||
UIManager:showUI("app/ui/shop/box_level_up_ui", params)
|
||||
end
|
||||
|
||||
-- 弹窗礼包
|
||||
function ShopManager:showGiftPopUI(params)
|
||||
UIManager:showUI("app/ui/shop/gift_pop_ui", params)
|
||||
-- 触发弹窗礼包
|
||||
function ShopManager:triggerGiftPopUI(actType, actId)
|
||||
UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId})
|
||||
DataManager.ShopData:removePopUpGift(actType, actId)
|
||||
end
|
||||
|
||||
-- 触发金币弹窗礼包
|
||||
function ShopManager:triggerCoinGiftPopUI(actId)
|
||||
self:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, actId)
|
||||
end
|
||||
|
||||
-- 购买每日特惠商品
|
||||
function ShopManager:buyMallDailyGift(id, isAd)
|
||||
@ -154,6 +159,8 @@ end
|
||||
function ShopManager:tryTriggerCoinGiftFinish(result)
|
||||
if result.status == 0 then
|
||||
DataManager.ShopData:onTriggerCoinGift(result.reqData.gold_gift_id)
|
||||
-- 立即触发金币弹窗
|
||||
self:triggerCoinGiftPopUI(result.reqData.gold_gift_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -117,6 +117,10 @@ function MainCityUI:_addListeners()
|
||||
ModuleManager.MailManager:getTriggeredTimeMail()
|
||||
end, time)
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.TUTORIAL_TASK_STOP, function()
|
||||
-- 引导完成时 检测主界面的弹窗是否要触发
|
||||
self:checkGift()
|
||||
end)
|
||||
DataManager.MailData:checkNewMail()
|
||||
end
|
||||
|
||||
@ -775,16 +779,46 @@ end
|
||||
|
||||
-- 检查礼包
|
||||
function MainCityUI:checkGift()
|
||||
-- 引导其间不处理
|
||||
if DataManager.TutorialData:getIsHaveTutorial() then
|
||||
return
|
||||
end
|
||||
|
||||
local actType, actId = DataManager.ShopData:getNextPopGiftData()
|
||||
if actType and actId then
|
||||
-- 触发弹窗
|
||||
ModuleManager.ShopManager:showGiftPopUI({type = actType, id = actId})
|
||||
-- 移除
|
||||
DataManager.ShopData:removePopUpGift(actType, actId)
|
||||
-- 章节礼包
|
||||
local popUpGift = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT)
|
||||
if popUpGift and #popUpGift > 0 then
|
||||
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, popUpGift[1])
|
||||
return true
|
||||
end
|
||||
-- 通用礼包
|
||||
local popUpGift = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
||||
if popUpGift and #popUpGift > 0 then
|
||||
-- 先遍历找出符合弹出的类型
|
||||
local beginnerGiftIds = {}
|
||||
local levelUpGiftIds = {}
|
||||
for _, actId in ipairs(popUpGift) do
|
||||
local cfgInfo = DataManager.ShopData:getActGiftConfig()[actId]
|
||||
if cfgInfo then
|
||||
-- 新手礼包
|
||||
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT then
|
||||
table.insert(beginnerGiftIds, actId)
|
||||
end
|
||||
-- 助力礼包
|
||||
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT then
|
||||
table.insert(levelUpGiftIds, actId)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 新手礼包
|
||||
if #beginnerGiftIds > 0 then
|
||||
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, beginnerGiftIds[1])
|
||||
return true
|
||||
end
|
||||
-- 助力礼包
|
||||
if #levelUpGiftIds then
|
||||
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.CHAPTER_GIFT, levelUpGiftIds[1])
|
||||
return true
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
@ -16,10 +16,14 @@ local GIFT_TITLE_TEXT = {
|
||||
local MAX_ITEM_NUM = 4
|
||||
|
||||
function GiftPopUI:ctor(params)
|
||||
|
||||
Logger.logHighlight("GiftPopUI -- ctor type:%s id:%s", params.type, params.id)
|
||||
|
||||
params = params or {}
|
||||
|
||||
self.actType = params.type
|
||||
self.actId = params.id
|
||||
self.buyCount = DataManager.ShopData:getGiftBoughtNum(self.actType, self.actId) -- 触发时该礼包的购买数量
|
||||
end
|
||||
|
||||
function GiftPopUI:isFullScreen()
|
||||
@ -86,12 +90,14 @@ function GiftPopUI:refresh(needCheck)
|
||||
if needCheck then
|
||||
-- 如果已经购买过了 则切为下一个或关闭UI 目前都是唯一礼包
|
||||
local bought = DataManager.ShopData:getGiftBoughtNum(self.actType, self.actId)
|
||||
if bought > 0 then
|
||||
if bought ~= self.buyCount then
|
||||
self:checkNextPopGiftOrClose()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Logger.logHighlight("refresh -- type:%s id:%s", self.actType, self.actId)
|
||||
|
||||
if self.actType == PayManager.PURCHARSE_TYPE.ACT_GIFT then
|
||||
local type = PayManager:getGiftConfigInfo(self.actType, self.actId).type
|
||||
self.titleTx:setText(GIFT_TITLE_TEXT[self.actType][type])
|
||||
@ -150,15 +156,14 @@ function GiftPopUI:onClickGift()
|
||||
end
|
||||
|
||||
function GiftPopUI:checkNextPopGiftOrClose()
|
||||
local actType, actId = DataManager.ShopData:getNextPopGiftData()
|
||||
if actType and actId then
|
||||
local actId = DataManager.ShopData:getNextPopGiftData(self.actType)
|
||||
if actId then
|
||||
-- 更新数据
|
||||
self.actType = actType
|
||||
self.actId = actId
|
||||
|
||||
self:refresh()
|
||||
-- 移除弹窗列表
|
||||
DataManager.ShopData:removePopUpGift(actType, actId)
|
||||
DataManager.ShopData:removePopUpGift(self.actType, actId)
|
||||
else
|
||||
self:closeUI()
|
||||
end
|
||||
|
||||
@ -101,15 +101,16 @@ end
|
||||
|
||||
-- 标记一个礼包需要弹出 在条件允许时会弹出
|
||||
function ShopData:markPopUpGift(actType, actId)
|
||||
-- 与预期的逻辑不一致 暂时屏蔽弹窗礼包
|
||||
-- TODOJ
|
||||
-- if not self.needPopUpGift then
|
||||
-- self.needPopUpGift = {}
|
||||
-- end
|
||||
-- if not self.needPopUpGift[actType] then
|
||||
-- self.needPopUpGift[actType] = {}
|
||||
-- end
|
||||
-- table.insert(self.needPopUpGift[actType], actId)
|
||||
if not self.needPopUpGift then
|
||||
self.needPopUpGift = {}
|
||||
end
|
||||
if not self.needPopUpGift[actType] then
|
||||
self.needPopUpGift[actType] = {}
|
||||
end
|
||||
|
||||
Logger.logHighlight("markPopUpGift -- actType:%s actId:%s",actType, actId)
|
||||
|
||||
table.insert(self.needPopUpGift[actType], actId)
|
||||
end
|
||||
|
||||
function ShopData:removePopUpGift(actType, actId)
|
||||
@ -117,6 +118,9 @@ function ShopData:removePopUpGift(actType, actId)
|
||||
if self.needPopUpGift[actType] then
|
||||
for index, id in ipairs(self.needPopUpGift[actType]) do
|
||||
if id == actId then
|
||||
|
||||
Logger.logHighlight("removePopUpGift -- actType:%s actId:%s",actType, actId)
|
||||
|
||||
table.remove(self.needPopUpGift[actType], index)
|
||||
break
|
||||
end
|
||||
@ -130,15 +134,16 @@ function ShopData:getPopUpGift()
|
||||
return self.needPopUpGift
|
||||
end
|
||||
|
||||
-- 获取下一个需要弹出的礼包数据
|
||||
function ShopData:getNextPopGiftData()
|
||||
local popUpGift = self:getPopUpGift()
|
||||
if popUpGift then
|
||||
for actType, actIdList in pairs(popUpGift) do
|
||||
-- 弹窗顺序待处理 TODOJ
|
||||
for _, actId in ipairs(actIdList) do
|
||||
return actType, actId
|
||||
end
|
||||
function ShopData:getPopUpGiftByType(actType)
|
||||
return self.needPopUpGift and self.needPopUpGift[actType]
|
||||
end
|
||||
|
||||
-- 获取下一个需要弹出的同类型礼包数据
|
||||
function ShopData:getNextPopGiftData(actType)
|
||||
local popUpGift = self:getPopUpGiftByType(actType)
|
||||
if popUpGift and #popUpGift > 0 then
|
||||
for _, actId in ipairs(popUpGift) do
|
||||
return actId
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -480,9 +485,6 @@ function ShopData:_getCoinGiftPayConditionList()
|
||||
if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT then
|
||||
local tmpCfgInfo = clone(cfgInfo)
|
||||
tmpCfgInfo.id = id
|
||||
|
||||
Logger.logHighlight("set id:%s", id)
|
||||
|
||||
table.insert(self.coinGiftPayConditionList, tmpCfgInfo)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user