This commit is contained in:
xiekaidong 2023-09-16 17:52:18 +08:00
parent ea8b6f6214
commit 8173e46209
6 changed files with 231 additions and 57 deletions

View File

@ -9,7 +9,11 @@ function ActPvpManager:showMainUI()
if DataManager.ActPvpData:getNeedUpdateData() then if DataManager.ActPvpData:getNeedUpdateData() then
self:reqActData() self:reqActData()
end end
UIManager:showUI("app/ui/activity/act_pvp/act_pvp_main_ui") if DataManager.ActPvpData:isPlaying() then
UIManager:showUI("app/ui/activity/act_pvp/act_pvp_playing_ui")
else
UIManager:showUI("app/ui/activity/act_pvp/act_pvp_main_ui")
end
end end
function ActPvpManager:showMatchUI(forceShowMatchUI) function ActPvpManager:showMatchUI(forceShowMatchUI)
@ -340,15 +344,14 @@ end
function ActPvpManager:rspBountyReward(result) function ActPvpManager:rspBountyReward(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
Logger.printTable(result)
DataManager.ActPvpData:setBountyCollected(result.success_id_grade) DataManager.ActPvpData:setBountyCollected(result.success_id_grade)
GFunc.showRewardBox(result.rewards) GFunc.showRewardBox(result.rewards)
end end
end end
function ActPvpManager:reqBuyBountyLevel() function ActPvpManager:reqBuyBountyLevel()
local level = DataManager.ActPvpData:getFundLevel() local level = DataManager.ActPvpData:getBountyLevel()
if level + 1 > DataManager.ActPvpData:getMaxFundLevel() then if level + 1 > DataManager.ActPvpData:getMaxBountyLevel() then
return return
end end
@ -360,7 +363,7 @@ end
function ActPvpManager:rspBuyBountyLevel(result) function ActPvpManager:rspBuyBountyLevel(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:setFundLevel(result.reqData.id) DataManager.ActPvpData:setBountyLevel(result.reqData.id)
end end
end end

View File

@ -36,7 +36,7 @@ end
function ActPvpBountyUI:_display() function ActPvpBountyUI:_display()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["act_pvp_bounty_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_4)) uiMap["act_pvp_bounty_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_4))
uiMap["act_pvp_bounty_ui.bg.scrollrect.viewport.content.mask_img.line.btn_buy_level.tx_num"]:setText(GFunc.getRewardNum(DataManager.ActBossRushData:getBuyBountyLevelCost())) uiMap["act_pvp_bounty_ui.bg.scrollrect.viewport.content.mask_img.line.btn_buy_level.tx_num"]:setText(GFunc.getRewardNum(DataManager.ActPvpData:getBuyBountyLevelCost()))
self.downDesc = uiMap["act_pvp_bounty_ui.bg.bg.desc"] self.downDesc = uiMap["act_pvp_bounty_ui.bg.bg.desc"]
self.downDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_16)) self.downDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_16))
@ -163,6 +163,7 @@ function ActPvpBountyUI:refreshTime()
str = Time:formatNumTimeStr(remainTime) str = Time:formatNumTimeStr(remainTime)
end end
uiMap["act_pvp_bounty_ui.bg.countdown.tx_countdown"]:setText(str) uiMap["act_pvp_bounty_ui.bg.countdown.tx_countdown"]:setText(str)
uiMap["act_pvp_bounty_ui.bg.scrollrect.viewport.content.mask_img.line.btn_buy_level"]:setActive(remainTime < 86400)
end end
function ActPvpBountyUI:refreshLevelInfo() function ActPvpBountyUI:refreshLevelInfo()

View File

@ -38,7 +38,6 @@ end
function ActPvpMainUI:_display() function ActPvpMainUI:_display()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["act_pvp_main_ui.down.enter_node.enter_btn.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_2)) uiMap["act_pvp_main_ui.down.enter_node.enter_btn.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_2))
uiMap["act_pvp_main_ui.down.playing_node.macth_btn.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_2))
uiMap["act_pvp_main_ui.down.btn_rank.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_BOSS_RUSH_DESC_10)) uiMap["act_pvp_main_ui.down.btn_rank.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_BOSS_RUSH_DESC_10))
uiMap["act_pvp_main_ui.down.btn_bounty.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_4)) uiMap["act_pvp_main_ui.down.btn_bounty.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_4))
uiMap["act_pvp_main_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_5)) uiMap["act_pvp_main_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_5))
@ -47,12 +46,7 @@ function ActPvpMainUI:_display()
title:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_6)) title:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_6))
GFunc.centerImgAndTx(titleBg, title, 5) GFunc.centerImgAndTx(titleBg, title, 5)
if DataManager.ActPvpData:isPlaying() then self:refreshEnterNode()
self:refreshPlayingNode()
else
self:refreshEnterNode()
end
self:refreshDialyRewardNode() self:refreshDialyRewardNode()
self:refreshBtns() self:refreshBtns()
end end
@ -63,10 +57,6 @@ function ActPvpMainUI:_addListeners()
ModuleManager.ActPvpManager:reqEnter() ModuleManager.ActPvpManager:reqEnter()
end) end)
uiMap["act_pvp_main_ui.down.playing_node.macth_btn"]:addClickListener(function()
ModuleManager.ActPvpManager:showMatchUI()
end)
uiMap["act_pvp_main_ui.bg.time_bg.btn_help"]:addClickListener(function() uiMap["act_pvp_main_ui.bg.time_bg.btn_help"]:addClickListener(function()
ModuleManager.ActPvpManager:showHelpUI() ModuleManager.ActPvpManager:showHelpUI()
end) end)
@ -115,15 +105,12 @@ function ActPvpMainUI:refreshTime()
self.canFight = canFight self.canFight = canFight
if not self.canFight then if not self.canFight then
uiMap["act_pvp_main_ui.down.enter_node"]:setVisible(false) uiMap["act_pvp_main_ui.down.enter_node"]:setVisible(false)
uiMap["act_pvp_main_ui.down.playing_node"]:setVisible(false)
end end
end end
end end
function ActPvpMainUI:refreshEnterNode() function ActPvpMainUI:refreshEnterNode()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["act_pvp_main_ui.down.enter_node"]:setVisible(true)
uiMap["act_pvp_main_ui.down.playing_node"]:setVisible(false)
local freeCount = DataManager.ActPvpData:getFreeEnterCount() local freeCount = DataManager.ActPvpData:getFreeEnterCount()
local txFree = uiMap["act_pvp_main_ui.down.enter_node.tx_count"] local txFree = uiMap["act_pvp_main_ui.down.enter_node.tx_count"]
local costNode = uiMap["act_pvp_main_ui.down.enter_node.cost"] local costNode = uiMap["act_pvp_main_ui.down.enter_node.cost"]
@ -146,43 +133,6 @@ function ActPvpMainUI:refreshEnterNode()
end end
end end
function ActPvpMainUI:refreshPlayingNode()
local curPairIds = DataManager.ActPvpData:getCurSelectPairId()
if curPairIds and curPairIds[1] then
ModuleManager.ActPvpManager:showSelectUI() -- 还有可选择的英雄
end
local uiMap = self.root:genAllChildren()
uiMap["act_pvp_main_ui.down.enter_node"]:setVisible(false)
uiMap["act_pvp_main_ui.down.playing_node"]:setVisible(true)
if not self.simpleHeroCells then
self.simpleHeroCells = {}
for i = 1, 5 do
self.simpleHeroCells[i] = CellManager:addCellComp(uiMap["act_pvp_main_ui.down.playing_node.hero_formation_comp.simple_hero_cell_" .. i], SIMPLE_HERO_CELL)
end
end
local str = GConst.EMPTY_STRING
local actData = DataManager.ActPvpData
str = I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_3, actData:getWinCount(), actData:getWinLimit(), actData:getLoseCount(), actData:getLoseLimit())
local txObj = uiMap["act_pvp_main_ui.down.playing_node.tx_fight"]
txObj:setText(str)
local btnHelp = uiMap["act_pvp_main_ui.bg.time_bg.btn_help"]
btnHelp:setAnchoredPositionX(txObj:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth / 2 + 30)
local heroes = DataManager.ActPvpData:getHeros()
for matchType, cell in ipairs(self.simpleHeroCells) do
local entity = heroes[matchType]
if entity then
cell:getBaseObject():setVisible(true)
cell:refresh(entity)
else
cell:getBaseObject():setVisible(false)
end
end
end
function ActPvpMainUI:refreshBtns() function ActPvpMainUI:refreshBtns()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
local btnRank = uiMap["act_pvp_main_ui.down.btn_rank"] local btnRank = uiMap["act_pvp_main_ui.down.btn_rank"]

View File

@ -0,0 +1,208 @@
local ActPvpPlayingUI = class("ActPvpPlayingUI", BaseUI)
local SIMPLE_HERO_CELL = "app/ui/activity/act_pvp/cell/simple_hero_cell"
function ActPvpPlayingUI:ctor()
end
function ActPvpPlayingUI:getPrefabPath()
return "assets/prefabs/ui/activity/act_pvp/act_pvp_playing_ui.prefab"
end
function ActPvpPlayingUI:onLoadRootComplete()
self:_display()
self:_addListeners()
self:_bind()
self:refreshTime()
if self.actCountdownSid then
self:unscheduleGlobal(self.actCountdownSid)
end
self.actCountdownSid = self:scheduleGlobal(function()
self:refreshTime()
end, 1)
end
function ActPvpPlayingUI:onPressBackspace()
self:closeUI()
end
function ActPvpPlayingUI:onClose()
if self.countdownSid then
self:unscheduleGlobal(self.countdownSid)
self.countdownSid = nil
end
end
function ActPvpPlayingUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["act_pvp_main_ui.down.playing_node.macth_btn.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_2))
uiMap["act_pvp_main_ui.down.btn_rank.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_BOSS_RUSH_DESC_10))
uiMap["act_pvp_main_ui.down.btn_bounty.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_4))
local title = uiMap["act_pvp_main_ui.bg.title_tx"]
title:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_6))
title:setSizeDeltaX(title:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth)
self:refreshPlayingNode()
self:refreshDialyRewardNode()
self:refreshBtns()
end
function ActPvpPlayingUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["act_pvp_main_ui.down.playing_node.macth_btn"]:addClickListener(function()
ModuleManager.ActPvpManager:showMatchUI()
end)
uiMap["act_pvp_main_ui.bg.time_bg.btn_help"]:addClickListener(function()
ModuleManager.ActPvpManager:showHelpUI()
end)
uiMap["act_pvp_main_ui.down.close_btn"]:addClickListener(function()
self:closeUI()
end)
uiMap["act_pvp_main_ui.down.btn_rank"]:addClickListener(function()
ModuleManager.ActPvpManager:showRankUI()
end)
uiMap["act_pvp_main_ui.down.btn_bounty"]:addClickListener(function()
ModuleManager.ActPvpManager:showBountyUI()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_PVP_EVENT, function(params)
if params and params.closeMainUI then
self:closeUI()
end
end)
end
function ActPvpPlayingUI:_bind()
self:bind(DataManager.ActPvpData, "isDirty", function()
self:_display()
end)
end
function ActPvpPlayingUI:refreshTime()
local uiMap = self.root:genAllChildren()
local remainTime = DataManager.ActPvpData:getRemainTime()
local str
if remainTime <= 0 then
str = I18N:getGlobalText(I18N.GlobalConst.ACTIVITY_OVER_EDSC)
else
str = Time:formatNumTimeStr(remainTime)
end
local icon = uiMap["act_pvp_main_ui.bg.time_bg.time_icon"]
local tx = uiMap["act_pvp_main_ui.bg.time_bg.time"]
tx:setText(str)
GFunc.centerImgAndTx(icon, tx, 5)
local canFight = remainTime > 86400
if self.canFight ~= canFight then
self.canFight = canFight
if not self.canFight then
uiMap["act_pvp_main_ui.down.playing_node"]:setVisible(false)
end
end
end
function ActPvpPlayingUI:refreshPlayingNode()
local curPairIds = DataManager.ActPvpData:getCurSelectPairId()
if curPairIds and curPairIds[1] then
ModuleManager.ActPvpManager:showSelectUI() -- 还有可选择的英雄
end
local uiMap = self.root:genAllChildren()
if not self.simpleHeroCells then
self.simpleHeroCells = {}
for i = 1, 5 do
self.simpleHeroCells[i] = CellManager:addCellComp(uiMap["act_pvp_main_ui.down.playing_node.hero_formation_comp.simple_hero_cell_" .. i], SIMPLE_HERO_CELL)
end
end
local actData = DataManager.ActPvpData
local txObj = uiMap["act_pvp_main_ui.down.playing_node.tx_fight"]
local txLose = uiMap["act_pvp_playing_ui.bg.playing_node.tx_fight_lose"]
txObj:setText(actData:getWinCount() .. "/" .. actData:getWinLimit())
txLose:setText(actData:getLoseCount() .. "/" .. actData:getLoseLimit())
local heroes = DataManager.ActPvpData:getHeros()
for matchType, cell in ipairs(self.simpleHeroCells) do
local entity = heroes[matchType]
if entity then
cell:getBaseObject():setVisible(true)
cell:refresh(entity)
else
cell:getBaseObject():setVisible(false)
end
end
end
function ActPvpPlayingUI:refreshBtns()
local uiMap = self.root:genAllChildren()
local btnRank = uiMap["act_pvp_main_ui.down.btn_rank"]
if DataManager.ActPvpData:canGetRankReward() then
btnRank:addRedPoint(30, 36, 0.6)
else
btnRank:removeRedPoint()
end
local btnBounty = uiMap["act_pvp_main_ui.down.btn_bounty"]
if DataManager.ActPvpData:getBountyRp() then
btnBounty:addRedPoint(30, 36, 0.6)
else
btnBounty:removeRedPoint()
end
end
function ActPvpPlayingUI:refreshDialyRewardNode()
local uiMap = self.root:genAllChildren()
local boxIndex = 0
for i = 1, 10 do
local obj = uiMap["act_pvp_main_ui.bg.win_point_" .. i]
local color = "#ffffff"
local countEnough = false
if DataManager.ActPvpData:winCountEnough(i) then
color = "#FFF667"
countEnough = true
end
if DataManager.ActPvpData:getWinCountMap()[i] then
boxIndex = boxIndex + 1
local boxIcon = "act_pvp_chest_" .. boxIndex
local tx = uiMap["act_pvp_main_ui.bg.win_desc_" .. i]
if tx then
local str = I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_7, i)
str = string.format("<color=%s>%s</color>", color, str)
tx:setText(str)
end
if DataManager.ActPvpData:canGetDailyReward(i) then
GFunc.getShakeSeq(obj, false, 1)
obj:addClickListener(function()
ModuleManager.ActPvpManager:reqDailyReward(DataManager.ActPvpData:getWinCountMap()[i])
end)
else
GFunc.getShakeSeq(obj, true, 1)
obj:addClickListener(function()
ModuleManager.TipsManager:showRewardsTips(DataManager.ActPvpData:getDailyRewards(i), nil, obj)
end)
end
if DataManager.ActPvpData:gotDailyReward(i) then
boxIcon = "act_pvp_chest_" .. boxIndex .. "_1"
end
obj:setSprite(GConst.ATLAS_PATH.UI_ACT_PVP, boxIcon)
else
local icon = "act_pvp_point_2"
if countEnough then
icon = "act_pvp_point_1"
end
obj:setSprite(GConst.ATLAS_PATH.UI_ACT_PVP, icon)
end
end
end
return ActPvpPlayingUI

View File

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

View File

@ -565,6 +565,8 @@ function ActPvpData:setBountyCollected(idGrades)
self.collected[id][ActPvpData.BOUNTY_TYPE.SUPERIOR_MAX] = true self.collected[id][ActPvpData.BOUNTY_TYPE.SUPERIOR_MAX] = true
end end
end end
self:setDirty()
end end
function ActPvpData:getBountyCanGet(level, bountyType) function ActPvpData:getBountyCanGet(level, bountyType)