This commit is contained in:
Fang 2023-07-04 18:28:56 +08:00
parent 045b774449
commit 6099fe08fb
6 changed files with 117 additions and 36 deletions

View File

@ -112,6 +112,7 @@ BIReport.ITEM_GET_TYPE = {
DUNGEON_SHARDS_SWEEP = "DungeonShardsSweep", -- 碎片副本扫荡
ARENA_REMATCH_CD = "ArenaRematchCd",
ARENA_REWARD = "ArenaReward",
ARENA_AD_BOX_REWARD = "ArenaAdBoxReward",
ARENA_SETTLEMENT = "ArenaSettlement",
CHANGE_NAME = "ChangeName", -- 重命名
CHANGE_AVATAR = "ChangeAvatar", -- 修改头像
@ -130,6 +131,7 @@ BIReport.ADS_CLICK_TYPE = {
IDLE_QUICK_DROP = "IdleQuickDrop",
ARENA_TICKET = "ArenaTicket",
ARENA_REMATCH = "ArenaRematch",
ARENA_AD_BOX = "ArenaAdBox",
MALL_DAILY = "MallDaily",
MALL_DAILY_RESET = "MallDailyReset",

View File

@ -209,6 +209,17 @@ function ArenaManager:rspOverCD(result)
end
end
-- 领取广告宝箱
function ArenaManager:reqAdBoxReward(isWin)
self:sendMessage(ProtoMsgType.FromMsgEnum.PVPSettlementADRewardReq, {win = isWin}, {}, self.rspAdBoxReward, BIReport.ITEM_GET_TYPE.ARENA_AD_BOX_REWARD)
end
function ArenaManager:rspAdBoxReward(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
ModuleManager.ShopManager:showBoxOpenUI({type = GConst.ShopConst.BOX_REWARD_TYPE.SUMMON, params = summonType, rewards = result.rewards})
end
end
function ArenaManager:showGiftPopUI()
UIManager:showUI("app/ui/arena/arena_pop_gift_ui")
end

View File

@ -1,9 +1,18 @@
local ShopManager = class("ShopManager", BaseModule)
-- 展示商城宝箱
function ShopManager:showBoxHeroUI(type)
UIManager:showUI("app/ui/shop/box_hero_ui", {type = type})
end
-- 展示竞技场ad宝箱
function ShopManager:showArenaAdBoxUI(isWin)
local params = {
isWin = isWin
}
UIManager:showUI("app/ui/shop/box_hero_ui", {arena = params})
end
function ShopManager:showBoxLevelUI()
UIManager:showUI("app/ui/shop/box_level_ui")
end

View File

@ -66,6 +66,10 @@ function BattleResultUI:onClose()
self.arenaSequence:Kill()
self.arenaSequence = nil
end
if self.arenaSpine then
self.arenaSpine:destroy()
self.arenaSpine = nil
end
end
function BattleResultUI:onLoadRootComplete()
@ -133,7 +137,7 @@ function BattleResultUI:onLoadRootComplete()
self:onClickMask()
end)
self.arenaBoxBtnGet:addClickListener(function()
-- 打开宝箱界面
ModuleManager.ShopManager:showArenaAdBoxUI(self.isWin)
end)
end
@ -155,8 +159,8 @@ function BattleResultUI:onRefresh()
self:refreshDefeatNode()
AudioManager:playEffect(AudioManager.EFFECT_ID.BATTLE_DEFEAT)
end
self:refreshRewards()
self:refreshUnitInfo()
self:refreshRewards()
self:refreshArenaNode()
self:refreshArenaBoxNode()
end
@ -268,6 +272,8 @@ function BattleResultUI:refreshArenaNode()
end
function BattleResultUI:refreshArenaBoxNode()
self.rewardScrollRect:setSizeDeltaY(260)
self.rewardScrollRect:setAnchoredPositionY(-268)
if self.battleType ~= GConst.BattleConst.BATTLE_TYPE.ARENA then
self.arenaBoxNode:setVisible(false)
return
@ -280,6 +286,8 @@ function BattleResultUI:refreshArenaBoxNode()
end
self.arenaBoxNode:setVisible(true)
self.arenaBoxTxGet:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM))
self.rewardScrollRect:setSizeDeltaY(120)
self.rewardScrollRect:setAnchoredPositionY(-255)
if self.isWin then
-- 胜利宝箱

View File

@ -15,7 +15,8 @@ local MAX_ITEM_NUM = 4
function BoxHeroUI:ctor(params)
params = params or {}
self.summonType = params.type or GConst.SummonConst.SUMMON_TYPE.LV_1
self.summonType = params.type
self.arenaBoxInfo = params.arena
end
function BoxHeroUI:isFullScreen()
@ -39,9 +40,14 @@ function BoxHeroUI:onLoadRootComplete()
self.titleTx = self.uiMap["box_hero_ui.bg.title"]
self.boxImg = self.uiMap["box_hero_ui.bg.box"]
-- 购买按钮
self.buyBtn = self.uiMap["box_hero_ui.bg.buy_btn"]
self.buyBtnTx = self.uiMap["box_hero_ui.bg.buy_btn.text"]
self.buyBtnIcon = self.uiMap["box_hero_ui.bg.buy_btn.icon"]
-- 视频按钮
self.adBtn = self.uiMap["box_hero_ui.bg.ad_btn"]
self.adBtnTx = self.uiMap["box_hero_ui.bg.ad_btn.tx_ad"]
self.adBtnIcon = self.uiMap["box_hero_ui.bg.ad_btn.img_ad"]
self.itemNodeLayout = self.uiMap["box_hero_ui.bg.item_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT)
self.itemNodeList = {}
@ -55,11 +61,8 @@ function BoxHeroUI:onLoadRootComplete()
table.insert(self.itemHelpList, self.uiMap["box_hero_ui.bg.item_" .. i .. ".help"])
end
self.buyBtn:addClickListener(function()
self:onClickSummon()
end)
self:refresh()
self.adBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.STR_FREE))
GFunc.centerImgAndTx(self.adBtnIcon, self.adBtnTx, 5)
-- 奖励界面打开时 关闭此界面
self:addEventListener(EventManager.CUSTOM_EVENT.CLOSE_BOX_HERO_UI, function()
@ -67,11 +70,60 @@ function BoxHeroUI:onLoadRootComplete()
end)
end
function BoxHeroUI:refresh()
function BoxHeroUI:onRefresh()
self.buyBtn:setActive(false)
self.adBtn:setActive(false)
if self.summonType then
self:refreshCummonBox()
elseif self.arenaBoxInfo then
self:refreshArenaAdBox()
end
end
-- 刷新商城宝箱
function BoxHeroUI:refreshCummonBox()
self.buyBtn:setActive(true)
self.buyBtn:addClickListener(function()
self:onClickSummon()
end)
self.titleTx:setText(TITLE_TEXT[self.summonType])
self.boxImg:setSprite(GConst.ATLAS_PATH.SHOP, ICON_NAME[self.summonType])
local rewards = DataManager.SummonData:getSummonTotalRewardByLv(self.summonType) -- 本次实际奖励
self:showRewards(DataManager.SummonData:getSummonTotalRewardByLv(self.summonType))-- 本次实际奖励
local costItem, cost = DataManager.SummonData:getSummonCost(self.summonType)
if GFunc.checkCost(costItem.id, costItem.num, false) then
self.buyBtnIcon:setSprite(GFunc.getIconRes(costItem.id))
self.buyBtnTx:setText(costItem.num)
else
self.buyBtnIcon:setSprite(GFunc.getIconRes(cost.id))
self.buyBtnTx:setText(cost.num)
end
GFunc.centerImgAndTx(self.buyBtnIcon, self.buyBtnTx, 5)
end
-- 刷新竞技场ad宝箱
function BoxHeroUI:refreshArenaAdBox()
self.adBtn:setActive(true)
self.adBtn:addClickListener(function()
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.ARENA_AD_BOX, function ()
ModuleManager.ArenaManager:reqAdBoxReward(self.arenaBoxInfo.isWin)
end)
end)
if self.arenaBoxInfo.isWin then
self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_32))
self.boxImg:setSprite(GConst.ATLAS_PATH.SHOP, "shop_chest_5")
else
self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_33))
self.boxImg:setSprite(GConst.ATLAS_PATH.SHOP, "shop_chest_4")
end
self:showRewards(DataManager.ArenaData:getAdBoxRewards(self.arenaBoxInfo.isWin))
end
function BoxHeroUI:showRewards(rewards)
for i = 1, MAX_ITEM_NUM do
if i <= #rewards then
self.itemNodeList[i]:setVisible(true)
@ -95,16 +147,6 @@ function BoxHeroUI:refresh()
end
end
self.itemNodeLayout:RefreshLayout()
local costItem, cost = DataManager.SummonData:getSummonCost(self.summonType)
if GFunc.checkCost(costItem.id, costItem.num, false) then
self.buyBtnIcon:setSprite(GFunc.getIconRes(costItem.id))
self.buyBtnTx:setText(costItem.num)
else
self.buyBtnIcon:setSprite(GFunc.getIconRes(cost.id))
self.buyBtnTx:setText(cost.num)
end
GFunc.centerImgAndTx(self.buyBtnIcon, self.buyBtnTx, 5)
end
function BoxHeroUI:onClickSummon()

View File

@ -176,25 +176,26 @@ end
-- 获取积分所对应的段位id
function ArenaData:getGradingIdFromScore(score, isLastSeason)
local seasonId,grading = nil
local gradingId,gradingInfo = nil
local cfg = self.cfgRank
if isLastSeason then
cfg = self:getRankCfg(self.season - 1)
end
for id, data in pairs(cfg) do
if score >= data.score and (grading == nil or grading.score < data.score) then
seasonId, grading = id, data
local ids = table.keys(cfg)
table.sort(ids)
for index, id in ipairs(ids) do
if score >= cfg[id].score and (gradingInfo == nil or gradingInfo.score < cfg[id].score) then
gradingId, gradingInfo = id, cfg[id]
end
end
return seasonId
return gradingId
end
-- 获取所在段位的积分 cur - min
function ArenaData:getGradingScore(score)
return score - self:getGradingMinScore(self.score)
return score - self:getGradingMinScore(score)
end
-- 获取所在段位的最低积分
@ -209,20 +210,18 @@ end
-- 获取所在段位的最高积分 full
function ArenaData:getGradingMaxScore(score)
local gradingId = self:getGradingIdFromScore(score)
local isNext = false
for id, data in pairs(self.cfgRank) do
if isNext then
return data.score
end
if id == gradingId then
isNext = true
end
local ids = self:getGradingIdList()
local curIdx = table.indexof(ids, gradingId)
if curIdx and curIdx + 1 <= #ids then
return self.cfgRank[ids[curIdx + 1]].score
end
end
-- 获取所在段位的总积分
function ArenaData:getGradingScoreTotal(score)
return self:getGradingMaxScore(score) - self:getGradingMinScore(score)
local max = self:getGradingMaxScore(score)
local min = self:getGradingMinScore(score)
return max - min
end
-- 获取段位图标名(大段位区分)
@ -412,6 +411,15 @@ function ArenaData:hasEntranceRedDot()
return DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_ARENA_TICKET) > 0 or self:hasSeasonReward()
end
-- 获取当前段位ad宝箱奖励
function ArenaData:getAdBoxRewards(isWin)
if isWin then
return self.cfgRank[self.curGradingId].win_adbox
else
return self.cfgRank[self.curGradingId].lose_adbox
end
end
-- 事件处理 ----------------------------------------------------------------------
-- 获取到排行榜数据
@ -448,6 +456,7 @@ end
-- 结算战斗数据
function ArenaData:onBattleResultReceived(settlement)
self.matchInfo = nil
-- 战斗记录改变
if self.recentBattle == nil then
self.recentBattle = {}