Merge branch 'fang/礼包' into 'dev_20230725'

装备礼包

See merge request b6-client/b6-lua!8
This commit is contained in:
陈希 2023-07-21 01:48:55 +00:00
commit 6eddc93a88
14 changed files with 242 additions and 6 deletions

View File

@ -19,6 +19,9 @@ PayManager.PURCHARSE_ACT_TYPE = {
BOUNTY = 7, BOUNTY = 7,
ARENA_BOUNTY = 8, ARENA_BOUNTY = 8,
ARENA_GIFT = 9, ARENA_GIFT = 9,
ARMOR_FUND = 10,
WEAPON_GIFT = 11,
ARMOR_GIFT = 12,
} }
PayManager.PURCHARSE_TYPE_CONFIG = { PayManager.PURCHARSE_TYPE_CONFIG = {

View File

@ -41,6 +41,8 @@ MainCityConst.RIGHT_SIDE_BARS = {
"app/ui/main_city/cell/side_bar_introduct_gift_cell", "app/ui/main_city/cell/side_bar_introduct_gift_cell",
"app/ui/main_city/cell/side_bar_beginner_gift_cell", "app/ui/main_city/cell/side_bar_beginner_gift_cell",
"app/ui/main_city/cell/side_bar_discount_cell", "app/ui/main_city/cell/side_bar_discount_cell",
"app/ui/main_city/cell/side_bar_weapon_gift_cell",
"app/ui/main_city/cell/side_bar_armor_gift_cell",
"app/ui/main_city/cell/side_bar_grow_up_gift_cell", "app/ui/main_city/cell/side_bar_grow_up_gift_cell",
} }

View File

@ -45,6 +45,10 @@ function DungeonArmorMainUI:onLoadRootComplete()
self:_display() self:_display()
self:_addListeners() self:_addListeners()
self:_bind() self:_bind()
local gift = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT)
if gift and #gift > 0 then
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift[1])
end
end end
function DungeonArmorMainUI:_display() function DungeonArmorMainUI:_display()

View File

@ -37,6 +37,10 @@ function DungeonWeaponMainUI:onLoadRootComplete()
self:_display() self:_display()
self:_addListeners() self:_addListeners()
self:_bind() self:_bind()
local gift = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT)
if gift and #gift > 0 then
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift[1])
end
end end
function DungeonWeaponMainUI:_display() function DungeonWeaponMainUI:_display()

View File

@ -41,6 +41,11 @@ function ArmorInfoComp:init()
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3)) self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
local gift = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT)
if gift and #gift > 0 then
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift[1])
end
self.btnUp:addClickListener(function() self.btnUp:addClickListener(function()
ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), self.selectPart) ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), self.selectPart)
end) end)

View File

@ -23,6 +23,11 @@ function WeaponInfoComp:init()
self.txDesc2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_5)) self.txDesc2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_5))
self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3)) self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
local gift = DataManager.ShopData:getPopUpGiftByType(PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT)
if gift and #gift > 0 then
ModuleManager.ShopManager:triggerGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift[1])
end
self.btnUp:addClickListener(function() self.btnUp:addClickListener(function()
ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON) ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)
end) end)

View File

@ -0,0 +1,56 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarArmorGiftCell = class("SideBarArmorGiftCell", SideBarBaseCellComp)
local GIFT_TYPE = PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT
function SideBarArmorGiftCell:getIsOpen()
return DataManager.ShopData:hasGift(GIFT_TYPE)
end
function SideBarArmorGiftCell:getSpineName()
return "ui_main_btn_hang"
end
function SideBarArmorGiftCell:onClick()
local gift = DataManager.ShopData:getGift(GIFT_TYPE)
if gift then
ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift.id, true)
end
end
function SideBarArmorGiftCell:getIsShowRedPoint()
return false
end
function SideBarArmorGiftCell:onRefresh()
self.timeBg:setVisible(true)
self:_refreshTime()
end
function SideBarArmorGiftCell:updateTime()
if self:getIsOpen() then
self:_refreshTime()
else
self:closeBtn()
end
end
function SideBarArmorGiftCell:_refreshTime()
local gift = DataManager.ShopData:getGift(GIFT_TYPE)
if gift then
local cfgInfo = DataManager.ShopData:getActGiftConfig()[gift.id]
if cfgInfo then
local remainTime = DataManager.ShopData:getGiftRemainTime(GIFT_TYPE)
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 SideBarArmorGiftCell

View File

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

View File

@ -0,0 +1,56 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarWeaponGiftCell = class("SideBarWeaponGiftCell", SideBarBaseCellComp)
local GIFT_TYPE = PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT
function SideBarWeaponGiftCell:getIsOpen()
return DataManager.ShopData:hasGift(GIFT_TYPE)
end
function SideBarWeaponGiftCell:getSpineName()
return "ui_main_btn_hang"
end
function SideBarWeaponGiftCell:onClick()
local gift = DataManager.ShopData:getGift(GIFT_TYPE)
if gift then
ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, gift.id, true)
end
end
function SideBarWeaponGiftCell:getIsShowRedPoint()
return false
end
function SideBarWeaponGiftCell:onRefresh()
self.timeBg:setVisible(true)
self:_refreshTime()
end
function SideBarWeaponGiftCell:updateTime()
if self:getIsOpen() then
self:_refreshTime()
else
self:closeBtn()
end
end
function SideBarWeaponGiftCell:_refreshTime()
local gift = DataManager.ShopData:getGift(GIFT_TYPE)
if gift then
local cfgInfo = DataManager.ShopData:getActGiftConfig()[gift.id]
if cfgInfo then
local remainTime = DataManager.ShopData:getGiftRemainTime(GIFT_TYPE)
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 SideBarWeaponGiftCell

View File

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

View File

@ -6,6 +6,8 @@ local GIFT_BG_NAME = {
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_3_1.png", [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_3_1.png",
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_4_1.png", [PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_4_1.png",
[PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_6_1.png", [PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_6_1.png",
[PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_6_1.png",
[PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_6_1.png",
}, },
[PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_2_1.png", [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = "assets/arts/textures/background/shop/shop_gift_banner_2_1.png",
[PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW] = "assets/arts/textures/background/shop/shop_gift_banner_5_1.png", [PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW] = "assets/arts/textures/background/shop/shop_gift_banner_5_1.png",
@ -16,6 +18,8 @@ local GIFT_TITLE_TEXT = {
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = I18N.GlobalConst.SHOP_DESC_11, [PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = I18N.GlobalConst.SHOP_DESC_11,
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = I18N.GlobalConst.SHOP_DESC_12, [PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = I18N.GlobalConst.SHOP_DESC_12,
[PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = I18N.GlobalConst.SHOP_DESC_14, [PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = I18N.GlobalConst.SHOP_DESC_14,
[PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT] = I18N.GlobalConst.EQUIP_DESC_24,
[PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT] = I18N.GlobalConst.EQUIP_DESC_25,
}, },
[PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = I18N.GlobalConst.SHOP_DESC_10, [PayManager.PURCHARSE_TYPE.CHAPTER_GIFT] = I18N.GlobalConst.SHOP_DESC_10,
[PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW] = I18N.GlobalConst.SHOP_DESC_13, [PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW] = I18N.GlobalConst.SHOP_DESC_13,
@ -178,6 +182,14 @@ function GiftPopUI:updateTime()
self:checkNextPopGiftOrClose() self:checkNextPopGiftOrClose()
end end
self.timeText:setText(Time:formatNumTime(remainTime)) self.timeText:setText(Time:formatNumTime(remainTime))
elseif cfgInfo and (cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT or cfgInfo.type == PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT) then-- 装备礼包
hasTime = true
local remainTime = DataManager.ShopData:getGiftRemainTime(cfgInfo.type)
if remainTime <= 0 then
remainTime = 0
self:checkNextPopGiftOrClose()
end
self.timeText:setText(Time:formatNumTime(remainTime))
end end
end end
elseif self.actType == PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW then -- 成长礼包 elseif self.actType == PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW then -- 成长礼包

View File

@ -15,9 +15,9 @@ function DungeonArmorEntity:init(data)
self.heroes = data.heroes or {} self.heroes = data.heroes or {}
self.starRewards = data.star_rewards or {} self.starRewards = data.star_rewards or {}
self.fundRewards = data.fund_rewards self.fundRewards = data.fund_rewards
self.giftInfo = data.gift_info
self.totalChallengeCount = data.total_challenge_count self.totalChallengeCount = data.total_challenge_count
self:updateGift(data.gift_info)
DataManager.FormationData:initDungeonArmor(self.heroes) DataManager.FormationData:initDungeonArmor(self.heroes)
DataManager:registerCrossDayFunc("DungeonArmorEntity", function() DataManager:registerCrossDayFunc("DungeonArmorEntity", function()
@ -29,17 +29,22 @@ end
function DungeonArmorEntity:refreshInfoOnSettlement(chapterId, result) function DungeonArmorEntity:refreshInfoOnSettlement(chapterId, result)
self.totalChallengeCount[chapterId] = (self.totalChallengeCount[chapterId] or 0) + 1 self.totalChallengeCount[chapterId] = (self.totalChallengeCount[chapterId] or 0) + 1
self.maxPassedId = result.max_id self.maxPassedId = result.max_id
self.giftInfo = result.gift_info
self.armorInfo[chapterId] = result.armor_info self.armorInfo[chapterId] = result.armor_info
self:updateGift(result.gift_info)
self:setDirty() self:setDirty()
end end
function DungeonArmorEntity:refreshInfoOnFarm(chapterId, result) function DungeonArmorEntity:refreshInfoOnFarm(chapterId, result)
self.farmCount[chapterId] = (self.farmCount[chapterId] or 0) + 1 self.farmCount[chapterId] = (self.farmCount[chapterId] or 0) + 1
self.giftInfo = result.gift_info self:updateGift(result.gift_info)
self:setDirty() self:setDirty()
end end
-- 更新礼包状态
function DungeonArmorEntity:updateGift(giftInfo)
DataManager.ShopData:initGift(PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT, giftInfo)
end
function DungeonArmorEntity:setStarReward(starId) function DungeonArmorEntity:setStarReward(starId)
self.starRewards[starId] = true self.starRewards[starId] = true
self:setDirty() self:setDirty()

View File

@ -12,10 +12,10 @@ function DungeonWeaponEntity:init(data)
self.maxPassedId = data.max_challenge_id or 0 self.maxPassedId = data.max_challenge_id or 0
self.farmCount = data.farm_count or 0 self.farmCount = data.farm_count or 0
self.heroes = data.heroes or {} self.heroes = data.heroes or {}
self.giftInfo = data.gift_info or {}
self.totalChallengeCount = data.total_challenge_count or {} self.totalChallengeCount = data.total_challenge_count or {}
self.data.isDirty = not self.data.isDirty self.data.isDirty = not self.data.isDirty
self:updateGift(data.gift_info)
DataManager.FormationData:initDungeonWeapon(self.heroes) DataManager.FormationData:initDungeonWeapon(self.heroes)
DataManager:registerCrossDayFunc("DungeonWeaponEntity", function() DataManager:registerCrossDayFunc("DungeonWeaponEntity", function()
@ -27,16 +27,21 @@ end
function DungeonWeaponEntity:refreshInfoOnSettlement(chapterId, result) function DungeonWeaponEntity:refreshInfoOnSettlement(chapterId, result)
self.totalChallengeCount[chapterId] = (self.totalChallengeCount[chapterId] or 0) + 1 self.totalChallengeCount[chapterId] = (self.totalChallengeCount[chapterId] or 0) + 1
self.maxPassedId = result.max_id self.maxPassedId = result.max_id
self.giftInfo = result.gift_info self:updateGift(result.gift_info)
self:setDirty() self:setDirty()
end end
function DungeonWeaponEntity:refreshInfoOnFarm(result) function DungeonWeaponEntity:refreshInfoOnFarm(result)
self.farmCount = self.farmCount + 1 self.farmCount = self.farmCount + 1
self.giftInfo = result.gift_info self:updateGift(result.gift_info)
self:setDirty() self:setDirty()
end end
-- 更新礼包状态
function DungeonWeaponEntity:updateGift(giftInfo)
DataManager.ShopData:initGift(PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT, giftInfo)
end
function DungeonWeaponEntity:setDirty() function DungeonWeaponEntity:setDirty()
self.data.isDirty = not self.data.isDirty self.data.isDirty = not self.data.isDirty
end end

View File

@ -818,6 +818,65 @@ end
-- 入门礼包结束 -------------------------------------------------------------------------------------------- -- 入门礼包结束 --------------------------------------------------------------------------------------------
-- 武器礼包 --------------------------------------------------------------------------------------------
-- 初始化礼包
function ShopData:initGift(giftType, gift)
if giftType == nil or gift == nil then
return
end
if EDITOR_MODE then
Logger.logHighlight("初始化礼包[%s] -- now_ts:%s", giftType, Time:getServerTime())
Logger.printTable(gift)
end
if not self.gifts then
self.gifts = {}
end
local giftStruct = {}
if giftType == PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT or giftType == PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT then
giftStruct.id = gift.gift_id
giftStruct.triggerTime = gift.trigger_at
giftStruct.expireTime = gift.expire_at
giftStruct.cdEndTime = gift.cd_end_at
end
self.gifts[giftType] = giftStruct
if self:hasGift(giftType) then
self:markPopUpGift(giftType, self.gifts[giftType].id)
end
self:setDirty()
end
-- 当前是否有礼包
function ShopData:hasGift(giftType)
return self.gifts ~= nil and self:getGiftRemainTime(giftType) > 0
end
-- 获取当前礼包
function ShopData:getGift(giftType)
if not self:hasGift(giftType) then
return nil
end
return self.gifts[giftType]
end
-- 获取礼包倒计时
function ShopData:getGiftRemainTime(giftType)
if not self.gifts or not self.gifts[giftType] then
return -1
end
return (self.gifts[giftType].expireTime // 1000) - Time:getServerTime()
end
-- 礼包购买成功
function ShopData:onGiftBuySuccess(giftType)
self.gifts[giftType].expireTime = -1
self:setDirty()
end
-- 武器礼包结束 -----------------------------------------------------------------------------------------
-- 底部栏是否有红点 -- 底部栏是否有红点
function ShopData:getRp() function ShopData:getRp()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, true) then if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, true) then