diff --git a/lua/app/common/module_manager.lua b/lua/app/common/module_manager.lua index 290a7089..d485e039 100644 --- a/lua/app/common/module_manager.lua +++ b/lua/app/common/module_manager.lua @@ -60,7 +60,8 @@ ModuleManager.MODULE_KEY = { IDLE_DROP = "idle_drop", MALL = "mall", -- 商城 MALL_DAILY = "mall_daily", -- 每日商城 - FUND = "act_level_gift" -- 成长基金 + FUND = "act_level_gift", -- 成长基金 + ACT_GIFT_SHOW_OPEN = "act_gift_show_open", -- 弹窗礼包通用开启条件 } local _moduleMgrs = {} diff --git a/lua/app/module/maincity/maincity_const.lua b/lua/app/module/maincity/maincity_const.lua index 1ec1011a..d887e565 100644 --- a/lua/app/module/maincity/maincity_const.lua +++ b/lua/app/module/maincity/maincity_const.lua @@ -25,6 +25,9 @@ MainCityConst.LEFT_SIDE_BARS = { MainCityConst.RIGHT_SIDE_BARS = { "app/ui/main_city/cell/side_bar_gold_pig_cell", "app/ui/main_city/cell/side_bar_level_fund_cell", + "app/ui/main_city/cell/side_bar_beginner_gift_cell", + "app/ui/main_city/cell/side_bar_grow_up_gift_1_cell", + "app/ui/main_city/cell/side_bar_grow_up_gift_2_cell", } return MainCityConst \ No newline at end of file diff --git a/lua/app/module/shop/shop_manager.lua b/lua/app/module/shop/shop_manager.lua index 7f455710..5a6851e6 100644 --- a/lua/app/module/shop/shop_manager.lua +++ b/lua/app/module/shop/shop_manager.lua @@ -23,8 +23,14 @@ end -- 触发弹窗礼包 function ShopManager:triggerGiftPopUI(actType, actId) - UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId}) - DataManager.ShopData:removePopUpGift(actType, actId) + if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ACT_GIFT_SHOW_OPEN, true) then + UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId}) + DataManager.ShopData:removePopUpGift(actType, actId) + end +end + +function ShopManager:showGiftPopUI(actType, actId) + UIManager:showUI("app/ui/shop/gift_pop_ui", {type = actType, id = actId, onlySelf = true}) end -- 触发金币弹窗礼包 @@ -172,8 +178,10 @@ end -- 推送成长礼包 function ShopManager:onTriggerGrowUpGift(result) DataManager.ShopData:onTriggerGrowUpGift(result.add_grow_up_gift) - -- 立即触发弹窗 - self:triggerGrowUpGiftPopUI(result.add_grow_up_gift.current_grow_up_id) + -- 有2种情况 1.处于英雄升级/解锁界面 立即触发弹窗 2.购买了成长礼包,此时仅标记,在奖励弹窗结束后再弹 + if UIManager:getTopUIObj() == UIManager.UI_PATH.HERO_DETAIL_UI then + self:triggerGrowUpGiftPopUI(result.add_grow_up_gift.current_grow_up_id) + end end return ShopManager \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua b/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua new file mode 100644 index 00000000..c1dd3bd1 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua @@ -0,0 +1,42 @@ +local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" +local SideBarBeginnerGiftCell = class("SideBarBeginnerGiftCell", SideBarBaseCellComp) + +function SideBarBeginnerGiftCell:getIsOpen() + return DataManager.ShopData:getBeginnerGiftShowSideBar() +end + +function SideBarBeginnerGiftCell:getIconRes() + return "main_btn_gift_1" -- TODOJ +end + +function SideBarBeginnerGiftCell:onClick() + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID) +end + +function SideBarBeginnerGiftCell:getIsShowRedPoint() + return false +end + +function SideBarBeginnerGiftCell:onRefresh() + self.timeBg:setVisible(true) + self:_refreshTime() +end + +function SideBarBeginnerGiftCell:updateTime() + if self:getIsOpen() then + self:_refreshTime() + else + self:closeBtn() + end +end + +function SideBarBeginnerGiftCell:_refreshTime() + local remainTime = DataManager.ShopData:getBeginnerGiftSideBarRemainTime() + if remainTime >= 0 then + self.timeTx:setText(GFunc.getTimeStr(remainTime)) + else + self.timeTx:setText("00:00:00") + end +end + +return SideBarBeginnerGiftCell \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua.meta b/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua.meta new file mode 100644 index 00000000..9b4bba88 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_beginner_gift_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b43a4c18aa3ff764691d1792e98936e2 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua new file mode 100644 index 00000000..4e33bd44 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua @@ -0,0 +1,57 @@ +local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" +local SideBarGrowUpGift1Cell = class("SideBarGrowUpGift1Cell", SideBarBaseCellComp) + +function SideBarGrowUpGift1Cell:getIsOpen() + return #DataManager.ShopData:getValidGrowUpGifts() >= 1 +end + +function SideBarGrowUpGift1Cell:getIconRes() + return "main_btn_gift_2" -- TODOJ +end + +function SideBarGrowUpGift1Cell:onClick() + local gift = DataManager.ShopData:getValidGrowUpGifts()[1] + if gift then + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id) + end +end + +function SideBarGrowUpGift1Cell:getIsShowRedPoint() + return false +end + +function SideBarGrowUpGift1Cell:onRefresh() + self.timeBg:setVisible(true) + self:_refreshTime() +end + +function SideBarGrowUpGift1Cell:updateTime() + if self:getIsOpen() then + self:_refreshTime() + else + self:closeBtn() + end +end + +function SideBarGrowUpGift1Cell:_refreshTime() + local gift = DataManager.ShopData:getValidGrowUpGifts()[1] + if gift then + local cfgInfo = DataManager.ShopData:getActGrowUpGiftConfig()[gift.current_grow_up_id] + if cfgInfo then + local durationTime = (cfgInfo.limit_time or 0) * 3600 + local triggerTime = gift.trigger_at // 1000 + local remainTime = triggerTime + durationTime - Time:getServerTime() + if remainTime >= 0 then + self.timeTx:setText(GFunc.getTimeStr(remainTime)) + else + self.timeTx:setText("00:00:00") + end + else + self.timeTx:setText("00:00:00") + end + else + self.timeTx:setText("00:00:00") + end +end + +return SideBarGrowUpGift1Cell \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua.meta b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua.meta new file mode 100644 index 00000000..9a0420f0 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_1_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 297d71f3bc4702a40a96511df082c7ad +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua new file mode 100644 index 00000000..5e4dcd1a --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua @@ -0,0 +1,57 @@ +local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" +local SideBarGrowUpGift2Cell = class("SideBarGrowUpGift2Cell", SideBarBaseCellComp) + +function SideBarGrowUpGift2Cell:getIsOpen() + return #DataManager.ShopData:getValidGrowUpGifts() >= 2 +end + +function SideBarGrowUpGift2Cell:getIconRes() + return "main_btn_gift_2" -- TODOJ +end + +function SideBarGrowUpGift2Cell:onClick() + local gift = DataManager.ShopData:getValidGrowUpGifts()[2] + if gift then + ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id) + end +end + +function SideBarGrowUpGift2Cell:getIsShowRedPoint() + return false +end + +function SideBarGrowUpGift2Cell:onRefresh() + self.timeBg:setVisible(true) + self:_refreshTime() +end + +function SideBarGrowUpGift2Cell:updateTime() + if self:getIsOpen() then + self:_refreshTime() + else + self:closeBtn() + end +end + +function SideBarGrowUpGift2Cell:_refreshTime() + local gift = DataManager.ShopData:getValidGrowUpGifts()[2] + if gift then + local cfgInfo = DataManager.ShopData:getActGrowUpGiftConfig()[gift.current_grow_up_id] + if cfgInfo then + local durationTime = (cfgInfo.limit_time or 0) * 3600 + local triggerTime = gift.trigger_at // 1000 + local remainTime = triggerTime + durationTime - Time:getServerTime() + if remainTime >= 0 then + self.timeTx:setText(GFunc.getTimeStr(remainTime)) + else + self.timeTx:setText("00:00:00") + end + else + self.timeTx:setText("00:00:00") + end + else + self.timeTx:setText("00:00:00") + end +end + +return SideBarGrowUpGift2Cell \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua.meta b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua.meta new file mode 100644 index 00000000..e302a8a4 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_grow_up_gift_2_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2dded7533782f8247b5d11e2eedfdd21 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/shop/gift_pop_ui.lua b/lua/app/ui/shop/gift_pop_ui.lua index a3f02793..3026ef52 100644 --- a/lua/app/ui/shop/gift_pop_ui.lua +++ b/lua/app/ui/shop/gift_pop_ui.lua @@ -26,6 +26,7 @@ function GiftPopUI:ctor(params) self.actType = params.type self.actId = params.id + self.onlySelf = params.onlySelf -- 有此标记时 关闭直接关闭界面 self.buyCount = DataManager.ShopData:getGiftBoughtNum(self.actType, self.actId) -- 触发时该礼包的购买数量 end @@ -44,7 +45,11 @@ function GiftPopUI:onLoadRootComplete() self.uiMap = self.root:genAllChildren() self.uiMap["gift_pop_ui.close_btn"]:addClickListener(function() - self:checkNextPopGiftOrClose() + if self.onlySelf then + self:closeUI() + else + self:checkNextPopGiftOrClose() + end end) self.titleTx = self.uiMap["gift_pop_ui.bg.title"] @@ -147,8 +152,38 @@ function GiftPopUI:refresh(needCheck) end function GiftPopUI:updateTime() - -- TODOJ - self.timeNode:setVisible(false) + local hasTime = false + -- 部分礼包有倒计时 + if self.actType == PayManager.PURCHARSE_TYPE.ACT_GIFT then + local cfgInfo = DataManager.ShopData:getActGiftConfig()[self.actId] + if cfgInfo then + if cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.FIRST_RECHARGE then -- 首充礼包 + hasTime = true + self.timeText:setText("TODOJ") -- TODOJ + elseif cfgInfo and cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT then -- 金币礼包 + hasTime = true + local remainTime = 0 + local triggerTime = DataManager.ShopData:getCoinGiftTriggerTime() + remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime() + if remainTime <= 0 then + remainTime = 0 + end + self.timeText:setText(GFunc.getTimeStr(remainTime)) + end + end + elseif self.actType == PayManager.PURCHARSE_TYPE.GROW_UP_GIFT then -- 成长礼包 + hasTime = true + local remainTime = 0 + local cfgInfo = DataManager.ShopData:getActGrowUpGiftConfig()[self.actId] + local gift = DataManager.ShopData:getGrowUpGiftByActId(self.actId) + local triggerTime = (gift and gift.trigger_at or 0) // 1000 + remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime() + if remainTime <= 0 then + remainTime = 0 + end + self.timeText:setText(GFunc.getTimeStr(remainTime)) + end + self.timeNode:setVisible(hasTime) end function GiftPopUI:onClickGift() diff --git a/lua/app/ui/shop/shop_comp.lua b/lua/app/ui/shop/shop_comp.lua index c96e151f..14eabb26 100644 --- a/lua/app/ui/shop/shop_comp.lua +++ b/lua/app/ui/shop/shop_comp.lua @@ -110,9 +110,6 @@ function ShopComp:initDiscountPage() self.coinSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.coin_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_COIN_SELL_CELL) end -function ShopComp:updateMainList() -end - function ShopComp:refresh() if self.page == PAGE_DISCOUNT then self.mainNode:setAnchoredPositionX(GConst.NOT_VISIBLE_POS) diff --git a/lua/app/ui/ui_manager.lua b/lua/app/ui/ui_manager.lua index 34aa7839..221fef8d 100644 --- a/lua/app/ui/ui_manager.lua +++ b/lua/app/ui/ui_manager.lua @@ -22,6 +22,7 @@ UIManager.UI_PATH = { BATTLE_UI = "app/ui/battle/battle_ui", ROGUE_SKILL_UI = "app/ui/battle/battle_skill_select_ui", REWARD_BOX = "app/ui/tips/reward_box", + HERO_DETAIL_UI = "app/ui/hero/hero_detail_ui", } -- 动画类型 diff --git a/lua/app/userdata/player/player_data.lua b/lua/app/userdata/player/player_data.lua index cc7896f9..3f9f665c 100644 --- a/lua/app/userdata/player/player_data.lua +++ b/lua/app/userdata/player/player_data.lua @@ -24,6 +24,7 @@ function PlayerData:init(data) self:resetOnCrossDay() self:markDirty() end) + self.createTime = basicInfo.create_at or 0 -- 创角时间 end function PlayerData:resetOnCrossDay() @@ -135,4 +136,9 @@ function PlayerData:addPayment(rechargeId) self.data.payAmount = self.data.payAmount + cfg.price end +-- 获取创角时间 +function PlayerData:getCreateTime() + return self.createTime +end + return PlayerData \ No newline at end of file diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index 4083955c..36090e3c 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -393,7 +393,7 @@ end function ShopData:getActChapterStoreCanBuyActIds() local list = {} local curChapterId = DataManager.ChapterData:getMaxChapterId() - for id = curChapterId, 1, -1 do + for id = 1, curChapterId do if not self:getActChapterStoreHasBuy(id) then table.insert(list, self.actChapterStoreChapterId2IdMap[id]) end @@ -421,6 +421,22 @@ function ShopData:getBeginnerGiftHasBuy() end end +function ShopData:getBeginnerGiftSideBarDurationTime() + return 3 * 24 * 3600 -- 暂无配置表 TODOJ +end + +-- 未购买且在开服的3天内 +function ShopData:getBeginnerGiftShowSideBar() + return not self:getBeginnerGiftHasBuy() and self:getBeginnerGiftSideBarRemainTime() > 0 +end + +-- 展示在侧边栏的剩余时间 +function ShopData:getBeginnerGiftSideBarRemainTime() + local createTime = DataManager.PlayerData:getCreateTime() // 1000 + local durationTime = self:getBeginnerGiftSideBarDurationTime() + return createTime + durationTime - Time:getServerTime() +end + -- 新手礼包结束 ---------------------------------------------------------------------------------------------- -- 助力与金币礼包(act_gift) ********************************************************************************************** @@ -623,36 +639,69 @@ function ShopData:getGrowUpGifts() return self.growUpGifts end +-- 目前允许显示的最多2个礼包 +function ShopData:getMaxGrowUpGiftCount() + return 2 +end + +function ShopData:getGrowUpGiftByActId(actId) + local list = self:getGrowUpGifts() + for _, gift in ipairs(list) do + if gift.current_grow_up_id == actId then + return gift + end + end +end + -- 获取目前时间有效的成长礼包 function ShopData:getValidGrowUpGifts() local list = {} for index, gift in ipairs(self:getGrowUpGifts()) do local cfgInfo = self:getActGrowUpGiftConfig()[gift.current_grow_up_id] if cfgInfo then - local cd = (cfgInfo.cd or 0) * 3600 + local isValid = false local durationTime = (cfgInfo.limit_time or 0) * 3600 local triggerTime = gift.trigger_at // 1000 local maxDurationTime = triggerTime + durationTime - local maxEndTime = triggerTime + cd + local buyLimit = cfgInfo.limit or 0 + -- 是否在有效范围内 local isInDurationTime = Time:getServerTime() < maxDurationTime if isInDurationTime then - -- 从通用act里找到这个礼包的最后购买时间 如果有且在这个范围内 则这个礼包已经被购买了 - local hasBuy = false + -- 从通用act里找到这个礼包 如果有该礼包且购买次数未达到上限,则有效;如果没有该礼包也有效 local actGiftDetailData = self:getActGiftDetailData(PayManager.PURCHARSE_TYPE.GROW_UP_GIFT, gift.current_grow_up_id) + if actGiftDetailData then + local buyCount = actGiftDetailData.buy_count local latestBuyTime = actGiftDetailData.latest_buy_at // 1000 - if latestBuyTime > 0 and triggerTime < latestBuyTime and latestBuyTime < maxEndTime then - hasBuy = true - end - end - if not hasBuy then - table.insert(list, gift) + if buyLimit > 0 then + if buyCount < buyLimit then + isValid = true + end + else + isValid = true + end + else + isValid = true end end + if isValid then + table.insert(list, gift) + end end end - return list + -- 按照时间排序 + table.sort(list, function(a, b) + return a.trigger_at < b.trigger_at + end) + -- 上限2位 + local limitList = {} + for i = 1, self:getMaxGrowUpGiftCount() do + if list[i] then + table.insert(limitList, list[i]) + end + end + return limitList end -- 触发了成长礼包