From 61b302305e8e3eb3224f30b0286dd2532c5da3cd Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 20 Jul 2023 19:39:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/pay_manager.lua | 3 + lua/app/module/maincity/maincity_const.lua | 2 + .../dungeon_armor/dungeon_armor_main_ui.lua | 4 ++ .../dungeon_weapon/dungeon_weapon_main_ui.lua | 4 ++ lua/app/ui/hero/armor_info_comp.lua | 5 ++ lua/app/ui/hero/weapon_info_comp.lua | 5 ++ .../cell/side_bar_armor_gift_cell.lua | 56 ++++++++++++++++++ .../cell/side_bar_armor_gift_cell.lua.meta | 10 ++++ .../cell/side_bar_weapon_gift_cell.lua | 56 ++++++++++++++++++ .../cell/side_bar_weapon_gift_cell.lua.meta | 10 ++++ lua/app/ui/shop/gift_pop_ui.lua | 12 ++++ .../userdata/dungeon/dungeon_armor_entity.lua | 11 +++- .../dungeon/dungeon_weapon_entity.lua | 11 +++- lua/app/userdata/shop/shop_data.lua | 59 +++++++++++++++++++ 14 files changed, 242 insertions(+), 6 deletions(-) create mode 100644 lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua create mode 100644 lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua.meta create mode 100644 lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua create mode 100644 lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua.meta diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index a35e5cf7..b14a4083 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -19,6 +19,9 @@ PayManager.PURCHARSE_ACT_TYPE = { BOUNTY = 7, ARENA_BOUNTY = 8, ARENA_GIFT = 9, + ARMOR_FUND = 10, + WEAPON_GIFT = 11, + ARMOR_GIFT = 12, } PayManager.PURCHARSE_TYPE_CONFIG = { diff --git a/lua/app/module/maincity/maincity_const.lua b/lua/app/module/maincity/maincity_const.lua index 17519814..3799130d 100644 --- a/lua/app/module/maincity/maincity_const.lua +++ b/lua/app/module/maincity/maincity_const.lua @@ -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_beginner_gift_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", } diff --git a/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua b/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua index aa6ca83c..e6aa4bac 100644 --- a/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua +++ b/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua @@ -45,6 +45,10 @@ function DungeonArmorMainUI:onLoadRootComplete() self:_display() self:_addListeners() 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 function DungeonArmorMainUI:_display() diff --git a/lua/app/ui/dungeon_weapon/dungeon_weapon_main_ui.lua b/lua/app/ui/dungeon_weapon/dungeon_weapon_main_ui.lua index bd8f3b84..1b6faaf3 100644 --- a/lua/app/ui/dungeon_weapon/dungeon_weapon_main_ui.lua +++ b/lua/app/ui/dungeon_weapon/dungeon_weapon_main_ui.lua @@ -37,6 +37,10 @@ function DungeonWeaponMainUI:onLoadRootComplete() self:_display() self:_addListeners() 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 function DungeonWeaponMainUI:_display() diff --git a/lua/app/ui/hero/armor_info_comp.lua b/lua/app/ui/hero/armor_info_comp.lua index 95a381b2..05998084 100644 --- a/lua/app/ui/hero/armor_info_comp.lua +++ b/lua/app/ui/hero/armor_info_comp.lua @@ -41,6 +41,11 @@ function ArmorInfoComp:init() self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16)) 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() ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), self.selectPart) end) diff --git a/lua/app/ui/hero/weapon_info_comp.lua b/lua/app/ui/hero/weapon_info_comp.lua index 8409db88..a8cb3af5 100644 --- a/lua/app/ui/hero/weapon_info_comp.lua +++ b/lua/app/ui/hero/weapon_info_comp.lua @@ -23,6 +23,11 @@ function WeaponInfoComp:init() self.txDesc2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_5)) 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() ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON) end) diff --git a/lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua b/lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua new file mode 100644 index 00000000..ae82f226 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua @@ -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 \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua.meta b/lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua.meta new file mode 100644 index 00000000..47d3fc48 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_armor_gift_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8da62da4b2631db44bc8d29cb2292794 +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_weapon_gift_cell.lua b/lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua new file mode 100644 index 00000000..e682dce8 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua @@ -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 \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua.meta b/lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua.meta new file mode 100644 index 00000000..72b27dd6 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_weapon_gift_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9a84c4b0533866243a700f9106a12593 +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 5f164ffe..b0b2bce7 100644 --- a/lua/app/ui/shop/gift_pop_ui.lua +++ b/lua/app/ui/shop/gift_pop_ui.lua @@ -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.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.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.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.LEVEL_UP_GIFT] = I18N.GlobalConst.SHOP_DESC_12, [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.GROW_UP_GIFT_NEW] = I18N.GlobalConst.SHOP_DESC_13, @@ -178,6 +182,14 @@ function GiftPopUI:updateTime() self:checkNextPopGiftOrClose() end 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 elseif self.actType == PayManager.PURCHARSE_TYPE.GROW_UP_GIFT_NEW then -- 成长礼包 diff --git a/lua/app/userdata/dungeon/dungeon_armor_entity.lua b/lua/app/userdata/dungeon/dungeon_armor_entity.lua index 901e5736..c1ed4e45 100644 --- a/lua/app/userdata/dungeon/dungeon_armor_entity.lua +++ b/lua/app/userdata/dungeon/dungeon_armor_entity.lua @@ -15,9 +15,9 @@ function DungeonArmorEntity:init(data) self.heroes = data.heroes or {} self.starRewards = data.star_rewards or {} self.fundRewards = data.fund_rewards - self.giftInfo = data.gift_info self.totalChallengeCount = data.total_challenge_count + self:updateGift(data.gift_info) DataManager.FormationData:initDungeonArmor(self.heroes) DataManager:registerCrossDayFunc("DungeonArmorEntity", function() @@ -29,17 +29,22 @@ end function DungeonArmorEntity:refreshInfoOnSettlement(chapterId, result) self.totalChallengeCount[chapterId] = (self.totalChallengeCount[chapterId] or 0) + 1 self.maxPassedId = result.max_id - self.giftInfo = result.gift_info self.armorInfo[chapterId] = result.armor_info + self:updateGift(result.gift_info) self:setDirty() end function DungeonArmorEntity:refreshInfoOnFarm(chapterId, result) self.farmCount[chapterId] = (self.farmCount[chapterId] or 0) + 1 - self.giftInfo = result.gift_info + self:updateGift(result.gift_info) self:setDirty() end +-- 更新礼包状态 +function DungeonArmorEntity:updateGift(giftInfo) + DataManager.ShopData:initGift(PayManager.PURCHARSE_ACT_TYPE.ARMOR_GIFT, giftInfo) +end + function DungeonArmorEntity:setStarReward(starId) self.starRewards[starId] = true self:setDirty() diff --git a/lua/app/userdata/dungeon/dungeon_weapon_entity.lua b/lua/app/userdata/dungeon/dungeon_weapon_entity.lua index b69a0ae8..26214269 100644 --- a/lua/app/userdata/dungeon/dungeon_weapon_entity.lua +++ b/lua/app/userdata/dungeon/dungeon_weapon_entity.lua @@ -12,10 +12,10 @@ function DungeonWeaponEntity:init(data) self.maxPassedId = data.max_challenge_id or 0 self.farmCount = data.farm_count or 0 self.heroes = data.heroes or {} - self.giftInfo = data.gift_info or {} self.totalChallengeCount = data.total_challenge_count or {} self.data.isDirty = not self.data.isDirty + self:updateGift(data.gift_info) DataManager.FormationData:initDungeonWeapon(self.heroes) DataManager:registerCrossDayFunc("DungeonWeaponEntity", function() @@ -27,16 +27,21 @@ end function DungeonWeaponEntity:refreshInfoOnSettlement(chapterId, result) self.totalChallengeCount[chapterId] = (self.totalChallengeCount[chapterId] or 0) + 1 self.maxPassedId = result.max_id - self.giftInfo = result.gift_info + self:updateGift(result.gift_info) self:setDirty() end function DungeonWeaponEntity:refreshInfoOnFarm(result) self.farmCount = self.farmCount + 1 - self.giftInfo = result.gift_info + self:updateGift(result.gift_info) self:setDirty() end +-- 更新礼包状态 +function DungeonWeaponEntity:updateGift(giftInfo) + DataManager.ShopData:initGift(PayManager.PURCHARSE_ACT_TYPE.WEAPON_GIFT, giftInfo) +end + function DungeonWeaponEntity:setDirty() self.data.isDirty = not self.data.isDirty end diff --git a/lua/app/userdata/shop/shop_data.lua b/lua/app/userdata/shop/shop_data.lua index 3417c063..fcaf23ec 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -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() if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, true) then