diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index cdc7f3a3..6d887fbb 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -119,6 +119,7 @@ BIReport.ITEM_GET_TYPE = { INTRODUCTORY_GIFT = "IntroductoryGift", -- 入门礼包 ARENA_CHALLENGE = "ArenaChallenge", ARENA_SETTLEMENT = "ArenaSettlement", + ARENA_GIFT = "ArenaGift", } BIReport.ADS_CLICK_TYPE = { @@ -175,6 +176,7 @@ BIReport.GIFT_TYPE = { GROW_UP_GIFT = "GrowUpGift", ARENA_BOUNTY = "ArenaBounty", INTRODUCTORY_GIFT = "IntroductoryGift", + ARENA_GIFT = "ArenaGift", } BIReport.COIN_TYPE = { diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index bec2a288..36615304 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -136,6 +136,7 @@ function DataManager:initWithServerData(data) self.GoldPigData:init(data.pig, true) self.BountyData:init(data.bounty) self.ArenaBountyData:init(data.arena_bounty) + self.ArenaData:initGiftInfo(data.act_arena_gift, true) -- 任务要在BountyData之后初始化,依赖BountyData的数据 self.DailyTaskData:init(data.task_daily) self.IdleData:init(data.idle) diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index 6fa52cdc..32f4446d 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -18,6 +18,7 @@ PayManager.PURCHARSE_ACT_TYPE = { GROWTH_FUND = 6, BOUNTY = 7, ARENA_BOUNTY = 8, + ARENA_GIFT = 9, } PayManager.PURCHARSE_TYPE_CONFIG = { @@ -38,6 +39,7 @@ PayManager.BI_ITEM_GET_TYPE = { [PayManager.PURCHARSE_ACT_TYPE.GROWTH_FUND] = BIReport.ITEM_GET_TYPE.GROWTH_FUND, [PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.ITEM_GET_TYPE.BOUNTY, [PayManager.PURCHARSE_ACT_TYPE.ARENA_BOUNTY] = BIReport.ITEM_GET_TYPE.ARENA_BOUNTY, + [PayManager.PURCHARSE_ACT_TYPE.ARENA_GIFT] = BIReport.ITEM_GET_TYPE.ARENA_GIFT, }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.ITEM_GET_TYPE.GOLD_PIG, [PayManager.PURCHARSE_TYPE.MALL_TREASURE] = BIReport.ITEM_GET_TYPE.MALL_TREASURE, @@ -54,7 +56,8 @@ PayManager.BI_GIFT_TYPE = { [PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.GIFT_TYPE.LEVEL_UP_GIFT, [PayManager.PURCHARSE_ACT_TYPE.GROWTH_FUND] = BIReport.GIFT_TYPE.GROWTH_FUND, [PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.GIFT_TYPE.BOUNTY, - [PayManager.PURCHARSE_ACT_TYPE.ARENA_BOUNTY] = BIReport.GIFT_TYPE.ARENA_BOUNTY, + [PayManager.PURCHARSE_ACT_TYPE.ARENA_BOUNTY] = BIReport.GIFT_TYPE.ARENA_GIFT, + [PayManager.PURCHARSE_ACT_TYPE.ARENA_GIFT] = BIReport.ITEM_GET_TYPE.ARENA_GIFT, }, [PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.GIFT_TYPE.GOLD_PIG, [PayManager.PURCHARSE_TYPE.MALL_TREASURE] = BIReport.GIFT_TYPE.MALL_TREASURE, diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index 7bb4bf9a..1b28be3d 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -1,5 +1,6 @@ local LocalizationGlobalConst = { + SHOP_DESC_40 = "SHOP_DESC_40", MAIN_BTN_1 = "MAIN_BTN_1", QLT_DESC_1 = "QLT_DESC_1", QLT_DESC_2 = "QLT_DESC_2", diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 0f9c0701..4e03886f 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -307,6 +307,8 @@ local localization_global = ["ARENA_DESC_30"] = "竞技场新赛季开启,请更新游戏再进入!", ["ARENA_DESC_31"] = "竞技场结算开始,暂停挑战!", ["ARENA_DESC_HELP"] = "1.竞技场为赛季周期制,每个赛季结束后将重置竞技场并发放上一赛季段位奖励。\n2.竞技场结算将在结束当日的23点30分(UTC-0)开始结算,结算时长为30分钟,结算期间为防止竞技场记录员受到干扰,竞技场将无法进行挑战,请各位骑士见谅。\n3.结算后,所有骑士团将重置为当前段位的最低段位阶段。如果前一赛季挑战不足10次,则重置为上一段位的最低阶段。", + ["SHOP_DESC_40"] = "竞技场特惠", + ["SHOP_DESC_41"] = "在竞技场战斗中获胜,聚集最大超值", } return localization_global \ No newline at end of file diff --git a/lua/app/module/arena/arena_manager.lua b/lua/app/module/arena/arena_manager.lua index 7f23c36a..77a9769f 100644 --- a/lua/app/module/arena/arena_manager.lua +++ b/lua/app/module/arena/arena_manager.lua @@ -95,6 +95,7 @@ end function ArenaManager:rspSettlement(result) if result.err_code == GConst.ERROR_STR.SUCCESS then DataManager.ArenaData:onBattleResultReceived(result.settlement) + DataManager.ArenaData:initGiftInfo(result.act_arena_gift) local checkCount = 0 if result.settlement.win then checkCount = result.total_win_count @@ -179,4 +180,8 @@ function ArenaManager:rspOverCD(result) end end +function ArenaManager:showGiftPopUI() + UIManager:showUI("app/ui/arena/arena_pop_gift_ui") +end + return ArenaManager \ No newline at end of file diff --git a/lua/app/ui/arena/arena_pop_gift_ui.lua b/lua/app/ui/arena/arena_pop_gift_ui.lua new file mode 100644 index 00000000..e5b32d86 --- /dev/null +++ b/lua/app/ui/arena/arena_pop_gift_ui.lua @@ -0,0 +1,119 @@ +local GiftPopUI = class("GiftPopUI", BaseUI) + +local MAX_ITEM_NUM = 4 +local MAX_GIFT_ID = 90102 + +function GiftPopUI:ctor(params) + params = params or {} + + self.actType = PayManager.PURCHARSE_TYPE.ACT_GIFT + self.actId = DataManager.ArenaData:getGiftId() + + DataManager.ArenaData:cleaShowPopGift() +end + +function GiftPopUI:isFullScreen() + return false +end + +function GiftPopUI:getPrefabPath() + return "assets/prefabs/ui/arena/arena_gift_pop_ui.prefab" +end + +function GiftPopUI:onLoadRootComplete() + if not self.actType or not self.actId then + self:closeUI() + return + end + + self.uiMap = self.root:genAllChildren() + self.uiMap["gift_pop_ui.close_btn"]:addClickListener(function() + self:closeUI() + end) + + self.titleTx = self.uiMap["gift_pop_ui.bg.title"] + self.banner = self.uiMap["gift_pop_ui.bg.banner"] + + self.offNode = self.uiMap["gift_pop_ui.bg.off_img"] + self.offText = self.uiMap["gift_pop_ui.bg.off_img.text"] + + self.rewardCellList = {} + for i = 1, MAX_ITEM_NUM do + table.insert(self.rewardCellList, CellManager:addCellComp(self.uiMap["gift_pop_ui.bg.item_node.pop_reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.POP_REWARD_CELL)) + end + self.itemNodeLayout = self.uiMap["gift_pop_ui.bg.item_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) + + self.timeNode = self.uiMap["gift_pop_ui.bg.time_node"] + self.timeText = self.uiMap["gift_pop_ui.bg.time_node.text"] + self.buyBtn = self.uiMap["gift_pop_ui.bg.buy_btn"] + self.buyBtnTx = self.uiMap["gift_pop_ui.bg.buy_btn.text"] + self.buyBtnIcon = self.uiMap["gift_pop_ui.bg.buy_btn.icon"] + + self.buyBtn:addClickListener(function() + self:onClickGift() + end) + + self:scheduleGlobal(function() + self:updateTime() + end, 1) + self:refresh() +end + +function GiftPopUI:refresh() + self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_40)) + -- self.banner:setTexture(GIFT_BG_NAME[self.actType][type]) + + local cfgInfo = PayManager:getGiftConfigInfo(self.actType, self.actId) + if cfgInfo then + local off = cfgInfo.value or 0 + if off < 100 then -- 统一为百分比格式 + off = off * 100 + end + if off > 0 then + self.offNode:setVisible(true) + self.offText:setText(tostring(off) .. "%") + else + self.offNode:setVisible(false) + end + end + + local rewards = cfgInfo.reward or {} + for i = 1, MAX_ITEM_NUM do + for i = 1, MAX_ITEM_NUM do + if i <= #rewards then + self.rewardCellList[i]:setVisible(true, 0.8) + self.rewardCellList[i]:refresh(rewards[i].id, rewards[i].num, true) + else + self.rewardCellList[i]:setVisible(false) + end + end + end + self.itemNodeLayout:RefreshLayout() + + local rechargeId = cfgInfo.recharge_id + if rechargeId then + self.buyBtnTx:setText(GFunc.getFormatPrice(rechargeId)) + end + + -- 上报 + local giftType = PayManager:getGiftType(self.actType, self.actId) + BIReport:postPayUIShow(giftType, self.actId) + + self:updateTime() +end + +function GiftPopUI:updateTime() + local hasTime = true + local remainTime = DataManager.ArenaData:getGiftRemainTime() + if remainTime <= 0 then + self:closeUI() + end + self.timeText:setText(Time:formatNumTime(remainTime)) + self.timeNode:setVisible(hasTime) +end + +function GiftPopUI:onClickGift() + PayManager:purchasePackage(self.actId, self.actType) +end + +return GiftPopUI \ No newline at end of file diff --git a/lua/app/ui/arena/arena_pop_gift_ui.lua.meta b/lua/app/ui/arena/arena_pop_gift_ui.lua.meta new file mode 100644 index 00000000..2a76c4aa --- /dev/null +++ b/lua/app/ui/arena/arena_pop_gift_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b5966ead92359dc4d8c46834c68ac2be +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/battle/battle_ui_pvp.lua b/lua/app/ui/battle/battle_ui_pvp.lua index 2d055c4a..c7c06cd8 100644 --- a/lua/app/ui/battle/battle_ui_pvp.lua +++ b/lua/app/ui/battle/battle_ui_pvp.lua @@ -204,7 +204,7 @@ function BattleUIPVP:refreshWave(wave, iconAtlas, iconName) -- GFunc.centerImgAndTx(icon, desc, 10) iconAtlas = iconAtlas or GConst.ATLAS_PATH.COMMON - iconName = iconName or "common_dec_3" + iconName = iconName or "common_dec_15" icon:setSprite(iconAtlas, iconName) end diff --git a/lua/app/ui/main_city/cell/side_bar_arena_gift_cell.lua b/lua/app/ui/main_city/cell/side_bar_arena_gift_cell.lua new file mode 100644 index 00000000..b3ded01b --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_arena_gift_cell.lua @@ -0,0 +1,50 @@ +local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" +local SideBarArenaGiftCell = class("SideBarArenaGiftCell", SideBarBaseCellComp) + +function SideBarArenaGiftCell:getModuleKey() + return ModuleManager.MODULE_KEY.ARENA_GIFT +end + +function SideBarArenaGiftCell:getHasPurchase() + return true +end + +function SideBarArenaGiftCell:getIsOpen() + return DataManager.ArenaData:getGiftId() +end + +function SideBarArenaGiftCell:getSpineName() + return "ui_main_btn_sevenday" +end + +function SideBarArenaGiftCell:onClick() + ModuleManager.ArenaManager:showGiftPopUI() +end + +function SideBarArenaGiftCell:getIsShowRedPoint() + return false +end + +function SideBarArenaGiftCell:onRefresh() + self.timeBg:setVisible(true) + self:_refreshTime() +end + +function SideBarArenaGiftCell:updateTime() + if self:getIsOpen() then + self:_refreshTime() + else + self:closeBtn() + end +end + +function SideBarArenaGiftCell:_refreshTime() + local remainTime = DataManager.ArenaData:getGiftRemainTime() + if remainTime >= 0 then + self.timeTx:setText(GFunc.getTimeStr(remainTime)) + else + self.timeTx:setText("00:00:00") + end +end + +return SideBarArenaGiftCell \ No newline at end of file diff --git a/lua/app/ui/main_city/cell/side_bar_arena_gift_cell.lua.meta b/lua/app/ui/main_city/cell/side_bar_arena_gift_cell.lua.meta new file mode 100644 index 00000000..6015e8d5 --- /dev/null +++ b/lua/app/ui/main_city/cell/side_bar_arena_gift_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: aa3c399f1f548114d8da14ef274abaec +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/component/arena_comp.lua b/lua/app/ui/main_city/component/arena_comp.lua index fedf6d78..c7c3acfe 100644 --- a/lua/app/ui/main_city/component/arena_comp.lua +++ b/lua/app/ui/main_city/component/arena_comp.lua @@ -1,6 +1,8 @@ local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell" local ArenaComp = class("ArenaComp", MainCompBaseCell) +local GIFT_CELL = "app/ui/main_city/cell/side_bar_arena_gift_cell" + function ArenaComp:getIsOpen() return DataManager.ArenaData:isOpen(true) end @@ -77,6 +79,7 @@ function ArenaComp:init() end) self:initBounty() self:refreshShow() + self:initRightBtns() end function ArenaComp:initBounty() @@ -176,4 +179,36 @@ function ArenaComp:updateTimer() end, 1) end +function ArenaComp:refreshTime() + self:refreshRightBtns() +end + +function ArenaComp:initRightBtns() + if self.rightBtnCells then + return + end + local uiMap = self:getUIMap() + self.rightArrow = uiMap["arena_comp.right_node.arrow_node"] + self.rightNode = uiMap["arena_comp.right_node"] + self.rightBtnCells = {} + self.rightBtnCells.giftCell = CellManager:addCellComp(uiMap["arena_comp.right_node.side_bar.side_bar_cell"], GIFT_CELL) + self:refreshRightBtns() +end + +function ArenaComp:refreshRightBtns() + local y = 0 + if self.rightBtnCells.giftCell:checkIsOpen() then + y = y - 60 + self.rightBtnCells.giftCell:setActive(true) + self.rightBtnCells.giftCell:setVisible(true) + self.rightBtnCells.giftCell:getBaseObject():setAnchoredPositionY(y) + self.rightBtnCells.giftCell:refresh() + else + self.rightBtnCells.giftCell:setVisible(false) + end + + -- 暂不处理箭头的问题 + self.rightNode:setVisible(y < 0) +end + return ArenaComp \ No newline at end of file diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index f609ee15..fb27737e 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -13,6 +13,15 @@ function MainComp:init() self:refreshModule(ModuleManager.MaincityManager:getCurModule()) end +function MainComp:refreshTime() + if not self.moduleMap then + return + end + if self.moduleMap[self.curModuleType] and self.moduleMap[self.curModuleType].refreshTime then + self.moduleMap[self.curModuleType]:refreshTime() + end +end + function MainComp:refreshModule(selectModule) if not self.moduleMap then self.moduleMap = {} @@ -71,6 +80,12 @@ function MainComp:refreshModule(selectModule) EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_COMP_MODULE, self.curModuleType) end + if self.curModuleType == GConst.MainCityConst.MAIN_MODULE.ARENA then + if DataManager.ArenaData:needShowPopGift() then + ModuleManager.ArenaManager:showGiftPopUI() + end + end + for idx, cell in pairs(self.moduleMap) do cell:getBaseObject():setActive(self.curModuleType == idx) end diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 338ef4c6..06be2afa 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -765,6 +765,7 @@ function MainCityUI:switchMainCompModule(moduleKey) return end + self.mainComp:refreshModule(ModuleManager.MaincityManager:getCurModule()) local module = self.mainComp:getCurModule() if module then self:setTopNodeVisible(module:isShowTopNode()) @@ -775,10 +776,8 @@ function MainCityUI:switchMainCompModule(moduleKey) end function MainCityUI:updateTime() - if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP and self.subComps[self.selectedIndex] then - if self.subComps[self.selectedIndex] then - self.subComps[self.selectedIndex]:refreshTime() - end + if self.subComps[self.selectedIndex] and self.subComps[self.selectedIndex].refreshTime then + self.subComps[self.selectedIndex]:refreshTime() end self.inSideBarUpdate = true if self.leftBarList then diff --git a/lua/app/ui/shop/cell/arena_gift_sell_cell.lua b/lua/app/ui/shop/cell/arena_gift_sell_cell.lua new file mode 100644 index 00000000..afcacfdb --- /dev/null +++ b/lua/app/ui/shop/cell/arena_gift_sell_cell.lua @@ -0,0 +1,95 @@ +local ArenaGiftSellCell = class("ArenaGiftSellCell", BaseCell) +local MAX_REWARD_COUNT = 4 +local BASE_CELL_HEIGHT = 320 + +function ArenaGiftSellCell:init() + local uiMap = self.baseObject:genAllChildren() + self.bg = uiMap["gift_cell.bg"] + self.bg:setTexture("assets/arts/textures/background/shop/shop_gift_banner_3.png") + + self.leftArrow = uiMap["gift_cell.left_arrow"] + self.rightArrow = uiMap["gift_cell.right_arrow"] + + self.offImg = uiMap["gift_cell.bg.off_img"] + self.offText = uiMap["gift_cell.bg.off_img.text"] + + self.limitImg = uiMap["gift_cell.bg.limit_img"] + self.limitText = uiMap["gift_cell.bg.limit_img.text"] + + self.titleText = uiMap["gift_cell.bg.title_text"] + + self.reweardLayout = uiMap["gift_cell.bg.reward_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) -- RefreshLayout() + if not self.rewardCellList then + self.rewardCellList = {} + for i = 1, MAX_REWARD_COUNT do + self.rewardCellList[i] = CellManager:addCellComp(uiMap["gift_cell.bg.reward_node.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.GIFT_REWARD_CELL) + end + end + + -- 不限时时使用1类型 否则使用2类型 + self.priceText = uiMap["gift_cell.bg.price"] + self.timeImg = uiMap["gift_cell.bg.time_img"] + self.timeText = uiMap["gift_cell.bg.time_img.text"] + self.clickArea = uiMap["gift_cell.bg.click_area"] +end + +function ArenaGiftSellCell:refresh() + local actGiftId = DataManager.ArenaData:getGiftId() + local cfgInfo = ConfigManager:getConfig("act_gift")[actGiftId] + -- 超值 + if cfgInfo.value then + self.offImg:setVisible(true) + self.offText:setText(tostring(cfgInfo.value) .. "%") + else + self.offImg:setVisible(false) + end + -- 限购 + self.limitText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_18, 1)) -- 限购1次 + -- 标题 + self.titleText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_40)) -- 竞技场特惠 + -- 奖励 + local rewardList = cfgInfo.reward + local count = rewardList and #rewardList or 0 + for i = 1, MAX_REWARD_COUNT do + if i <= count then + self.rewardCellList[i]:getBaseObject():setActive(true) + self.rewardCellList[i]:refreshByConfig(rewardList[i]) + else + self.rewardCellList[i]:getBaseObject():setActive(false) + end + end + self.reweardLayout:RefreshLayout() + -- 价格 + self.priceText:setText(GFunc.getFormatPrice(cfgInfo.recharge_id)) + -- 限时 + self.timeImg:setVisible(true) + self:refreshTime() + + self.clickArea:addClickListener(function() + self:onClickGift(actGiftId) + end) +end + +function ArenaGiftSellCell:getCellHeight() + return BASE_CELL_HEIGHT -- 竞技场固定1个 +end + +function ArenaGiftSellCell:getIsOpen() + return DataManager.ArenaData:getGiftId() ~= nil +end + +function ArenaGiftSellCell:refreshTime() + local remainTime = DataManager.ArenaData:getGiftRemainTime() + self.timeText:setText(Time:formatNumTime(remainTime)) +end + +function ArenaGiftSellCell:setVisible(visible) + self.baseObject:setVisible(visible) +end + +function ArenaGiftSellCell:onClickGift(id) + -- PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT) + ModuleManager.ArenaManager:showGiftPopUI() +end + +return ArenaGiftSellCell \ No newline at end of file diff --git a/lua/app/ui/shop/cell/arena_gift_sell_cell.lua.meta b/lua/app/ui/shop/cell/arena_gift_sell_cell.lua.meta new file mode 100644 index 00000000..0c402dd5 --- /dev/null +++ b/lua/app/ui/shop/cell/arena_gift_sell_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2259d1a0184c8284d9c5a78fd212baf3 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/shop/shop_comp.lua b/lua/app/ui/shop/shop_comp.lua index 0f8307b5..e9687faf 100644 --- a/lua/app/ui/shop/shop_comp.lua +++ b/lua/app/ui/shop/shop_comp.lua @@ -16,6 +16,7 @@ local PAGE_DISCOUNT_BEGINNER_SELL_CELL = "app/ui/shop/cell/beginner_sell_cell" - local PAGE_DISCOUNT_LEVEL_SELL_CELL = "app/ui/shop/cell/level_sell_cell" -- 助力 local PAGE_DISCOUNT_GROW_SELL_CELL = "app/ui/shop/cell/grow_sell_cell" -- 成长 local PAGE_DISCOUNT_COIN_SELL_CELL = "app/ui/shop/cell/coin_sell_cell" -- 金币 +local PAGE_DISCOUNT_ARENA_SELL_CELL = "app/ui/shop/cell/arena_gift_sell_cell" -- 竞技场 function ShopComp:init() self.uiMap = self.baseObject:genAllChildren() @@ -156,6 +157,7 @@ function ShopComp:initDiscountPage() self.levelSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.level_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_LEVEL_SELL_CELL) self.growSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.grow_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_GROW_SELL_CELL) self.coinSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.coin_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_COIN_SELL_CELL) + self.arenaSellCell = self.uiMap["shop_comp.discount.scrollrect.viewport.content.arena_gift_sell_cell"]:addLuaComponent(PAGE_DISCOUNT_ARENA_SELL_CELL) end function ShopComp:refresh() @@ -265,6 +267,15 @@ function ShopComp:refreshTime() self.growCellCount = growCellCount DataManager.ShopData:setDirty() end + local arenaGiftOpen = false + if self.arenaSellCell and self.arenaSellCell:getIsOpen() then + arenaGiftOpen = true + self.arenaSellCell:refreshTime() + end + if self.arenaGiftOpen ~= arenaGiftOpen then + self.arenaGiftOpen = arenaGiftOpen + DataManager.ShopData:setDirty() + end end function ShopComp:refreshDiscountPage() @@ -290,6 +301,16 @@ function ShopComp:refreshDiscountPage() else self.beginnerSellCell:setVisible(false) end + -- 竞技场 + if self.arenaSellCell:getIsOpen() then + self.arenaSellCell:setVisible(true) + self.arenaSellCell:refresh() + self.arenaSellCell:getBaseObject():setAnchoredPositionY(-y) + cellHeight = self.arenaSellCell:getCellHeight() + y = y + cellHeight + else + self.arenaSellCell:setVisible(false) + end -- 助力 if self.levelSellCell:getIsOpen() then self.levelSellCell:setVisible(true) diff --git a/lua/app/userdata/arena/arena_data.lua b/lua/app/userdata/arena/arena_data.lua index d1310c35..58a3ec47 100644 --- a/lua/app/userdata/arena/arena_data.lua +++ b/lua/app/userdata/arena/arena_data.lua @@ -7,6 +7,9 @@ function ArenaData:ctor() end function ArenaData:clear() + self.lastArenaGiftId = nil + self.curArenaGiftId = nil + self.giftExpireAt = nil end function ArenaData:init(data) @@ -38,6 +41,53 @@ function ArenaData:init(data) self:setDirty() end +function ArenaData:initGiftInfo(actArenaGift, isInit) + if not actArenaGift then + return + end + if self.lastArenaGiftId ~= actArenaGift.current_gift_id and not isInit then + self.lastArenaGiftId = nil + else + self.lastArenaGiftId = actArenaGift.current_gift_id + end + self.curArenaGiftId = actArenaGift.current_gift_id + self.giftExpireAt = GFunc.formatTimeStep(actArenaGift.gift_expire_at) +end + +function ArenaData:needShowPopGift() + return self.lastArenaGiftId ~= self.curArenaGiftId +end + +function ArenaData:cleaShowPopGift() + self.lastArenaGiftId = self.curArenaGiftId +end + +function ArenaData:getGiftId() + if not self.curArenaGiftId or self.curArenaGiftId <= 0 then + return + end + if self:getGiftRemainTime() <= 0 then + return + end + return self.curArenaGiftId +end + +function ArenaData:getGiftRemainTime() + if not self.giftExpireAt then + return 0 + end + return self.giftExpireAt - Time:getServerTime() +end + +function ArenaData:onBoughtGift(giftId) + if giftId ~= self.curArenaGiftId then + return + end + self.lastArenaGiftId = nil + self.curArenaGiftId = nil + self.giftExpireAt = nil +end + function ArenaData: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 248bcce5..41648a62 100644 --- a/lua/app/userdata/shop/shop_data.lua +++ b/lua/app/userdata/shop/shop_data.lua @@ -99,8 +99,12 @@ function ShopData:updateGiftInfo(gift) local cfgName = PayManager.PURCHARSE_TYPE_CONFIG[giftType] if cfgName then local cfg = ConfigManager:getConfig(cfgName) - if cfg and cfg[giftId] and cfg[giftId].type == PayManager.PURCHARSE_ACT_TYPE.GROWTH_FUND then - DataManager.GrowthFundData:onBoughtFund(giftId) + if cfg and cfg[giftId] then + if cfg[giftId].type == PayManager.PURCHARSE_ACT_TYPE.GROWTH_FUND then + DataManager.GrowthFundData:onBoughtFund(giftId) + elseif cfg[giftId].type == PayManager.PURCHARSE_ACT_TYPE.ARENA_GIFT then + DataManager.ArenaData:onBoughtGift(giftId) + end end end end