选择界面表现

This commit is contained in:
xiekaidong 2023-09-16 19:39:43 +08:00
parent d2d1dd612e
commit 68575924be
3 changed files with 68 additions and 9 deletions

View File

@ -133,6 +133,10 @@ end
function ActPvpManager:rspDecideHero(result) function ActPvpManager:rspDecideHero(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:updateHerosInfo(result.heroes, result.pair_id, result.next_select_four_id) DataManager.ActPvpData:updateHerosInfo(result.heroes, result.pair_id, result.next_select_four_id)
if not result.reqData then
result.reqData = {index = 0}
end
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.ACT_PVP_EVENT, {selectIndex = result.reqData.index})
end end
end end
@ -158,6 +162,7 @@ function ActPvpManager:reqRefreshHero()
end, end,
} }
GFunc.showMessageBox(params) GFunc.showMessageBox(params)
return
end end
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPFlushHeroesReq, {}, {}, self.rspRefreshHero, BIReport.ITEM_GET_TYPE.ACT_PVP_REFRESH_HERO) self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPFlushHeroesReq, {}, {}, self.rspRefreshHero, BIReport.ITEM_GET_TYPE.ACT_PVP_REFRESH_HERO)
end end

View File

@ -21,10 +21,16 @@ function ActPvpSelectUI:getPrefabPath()
return "assets/prefabs/ui/activity/act_pvp/act_pvp_select_ui.prefab" return "assets/prefabs/ui/activity/act_pvp/act_pvp_select_ui.prefab"
end end
function ActPvpSelectUI:onClose()
if self.aniSeq then
self.aniSeq:Kill()
self.aniSeq = nil
end
end
function ActPvpSelectUI:onLoadRootComplete() function ActPvpSelectUI:onLoadRootComplete()
self:_display() self:_display()
self:_addListeners() self:_addListeners()
self:_bind()
end end
function ActPvpSelectUI:_display() function ActPvpSelectUI:_display()
@ -106,11 +112,57 @@ function ActPvpSelectUI:_addListeners()
uiMap["act_pvp_select_ui.bg.hero_cell_2.select_btn"]:addClickListener(function() uiMap["act_pvp_select_ui.bg.hero_cell_2.select_btn"]:addClickListener(function()
ModuleManager.ActPvpManager:reqDecideHero(1) ModuleManager.ActPvpManager:reqDecideHero(1)
end) end)
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_PVP_EVENT, function(params)
if params and params.selectIndex then
if not self.heroEntities or not self.bigHeroInfos or not self.simpleHeroCells then
self:_display()
return
end
local heroEntity
local cell
local node
if params.selectIndex == 0 then -- 左边的
heroEntity = self.heroEntities[1]
cell = self.bigHeroInfos[1] and self.bigHeroInfos[1].simpleHeroCell
node = self.bigHeroInfos[1] and self.bigHeroInfos[1].node
if cell then
cell:getBaseObject():setAnchoredPosition(-170, 190)
end
else
heroEntity = self.heroEntities[2]
cell = self.bigHeroInfos[2] and self.bigHeroInfos[2].simpleHeroCell
node = self.bigHeroInfos[2] and self.bigHeroInfos[2].node
if cell then
cell:getBaseObject():setAnchoredPosition(170, 190)
end
end
if not heroEntity or not cell then
self:_display()
return
end end
function ActPvpSelectUI:_bind() local target = self.simpleHeroCells[heroEntity:getMatchType()]
self:bind(DataManager.ActPvpData, "isDirty", function() if not target then
self:_display() self:_display()
return
end
local targetPos = target:getBaseObject():getTransform().position
local sPoint = UIManager:getUICameraComponent():WorldToScreenPoint(targetPos)
targetPos = CS.BF.Utils.RectTransformScreenPointToLocalPointInRectangle(node:getTransform(), sPoint.x, sPoint.y, UIManager:getUICameraComponent())
if self.aniSeq then
self.aniSeq:Kill()
self.aniSeq = nil
end
self.aniSeq = self.root:createBindTweenSequence()
self.aniSeq:AppendCallback(function()
cell:getBaseObject():setActive(true)
end)
self.aniSeq:Append(cell:getBaseObject():getTransform():DOAnchorPos(targetPos, 0.3))
self.aniSeq:AppendCallback(function()
self:_display()
end)
end
end) end)
end end
@ -124,6 +176,7 @@ function ActPvpSelectUI:refreshSelectInfo()
local list = {} local list = {}
table.insert(list, {curPairIds[1], nextPairIds[1], nextPairIds[2]}) table.insert(list, {curPairIds[1], nextPairIds[1], nextPairIds[2]})
table.insert(list, {curPairIds[2], nextPairIds[3], nextPairIds[4]}) table.insert(list, {curPairIds[2], nextPairIds[3], nextPairIds[4]})
self.heroEntities = {}
for inedx, ids in pairs(list) do for inedx, ids in pairs(list) do
local curId = ids[1] local curId = ids[1]
local nextId1 = ids[2] local nextId1 = ids[2]
@ -133,8 +186,10 @@ function ActPvpSelectUI:refreshSelectInfo()
local heroId = DataManager.ActPvpData:getSelectHeroId(curId) local heroId = DataManager.ActPvpData:getSelectHeroId(curId)
if heroId then if heroId then
local heroEntity = DataManager.HeroData:getEntity({id = heroId, level = DataManager.ActPvpData:getHeroLv()}) local heroEntity = DataManager.HeroData:getEntity({id = heroId, level = DataManager.ActPvpData:getHeroLv()})
self.heroEntities[inedx] = heroEntity
unit.node:setVisible(true) unit.node:setVisible(true)
unit.simpleHeroCell:refresh(heroEntity) unit.simpleHeroCell:refresh(heroEntity)
unit.simpleHeroCell:getBaseObject():setActive(false)
unit.info:setSprite(GConst.ATLAS_PATH.COMMON, INFO_BG[heroEntity:getQlt()]) unit.info:setSprite(GConst.ATLAS_PATH.COMMON, INFO_BG[heroEntity:getQlt()])
local heroInfo = heroEntity:getConfig() local heroInfo = heroEntity:getConfig()
unit.matchIcon:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position]) unit.matchIcon:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position])
@ -210,7 +265,7 @@ function ActPvpSelectUI:rfreshRefreshBtns()
txCost:setVisible(true) txCost:setVisible(true)
imgCost:setVisible(true) imgCost:setVisible(true)
txCost:setText(DataManager.ActPvpData:getFlushCost().num) txCost:setText(DataManager.ActPvpData:getFlushCost().num)
GFunc.centerImgAndTx(imgCost, txCost, 5) GFunc.centerImgAndTx(imgCost, txCost, 0)
ad:setVisible(false) ad:setVisible(false)
end end
end end

View File

@ -398,12 +398,11 @@ function ActPvpData:setLastTurnWin(win)
end end
function ActPvpData:getHeroLevelUp() function ActPvpData:getHeroLevelUp()
-- return self.heroLevelUp return self.heroLevelUp
return true
end end
function ActPvpData:setHeroLevelUp(up) function ActPvpData:setHeroLevelUp(up)
-- self.heroLevelUp = up self.heroLevelUp = up
end end
---- 排行榜 ---- 排行榜