From 68575924bec54aabbb224c48d6da7c3d6f6f84cb Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Sat, 16 Sep 2023 19:39:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=95=8C=E9=9D=A2=E8=A1=A8?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/act_pvp/act_pvp_manager.lua | 5 ++ .../ui/activity/act_pvp/act_pvp_select_ui.lua | 67 +++++++++++++++++-- .../activity/act_pvp/act_pvp_data.lua | 5 +- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/lua/app/module/activity/act_pvp/act_pvp_manager.lua b/lua/app/module/activity/act_pvp/act_pvp_manager.lua index 7abc1c7e..791cbd91 100644 --- a/lua/app/module/activity/act_pvp/act_pvp_manager.lua +++ b/lua/app/module/activity/act_pvp/act_pvp_manager.lua @@ -133,6 +133,10 @@ end function ActPvpManager:rspDecideHero(result) if result.err_code == GConst.ERROR_STR.SUCCESS then 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 @@ -158,6 +162,7 @@ function ActPvpManager:reqRefreshHero() end, } GFunc.showMessageBox(params) + return end self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPFlushHeroesReq, {}, {}, self.rspRefreshHero, BIReport.ITEM_GET_TYPE.ACT_PVP_REFRESH_HERO) end diff --git a/lua/app/ui/activity/act_pvp/act_pvp_select_ui.lua b/lua/app/ui/activity/act_pvp/act_pvp_select_ui.lua index 63045098..362402df 100644 --- a/lua/app/ui/activity/act_pvp/act_pvp_select_ui.lua +++ b/lua/app/ui/activity/act_pvp/act_pvp_select_ui.lua @@ -21,10 +21,16 @@ function ActPvpSelectUI:getPrefabPath() return "assets/prefabs/ui/activity/act_pvp/act_pvp_select_ui.prefab" end +function ActPvpSelectUI:onClose() + if self.aniSeq then + self.aniSeq:Kill() + self.aniSeq = nil + end +end + function ActPvpSelectUI:onLoadRootComplete() self:_display() self:_addListeners() - self:_bind() end function ActPvpSelectUI:_display() @@ -106,11 +112,57 @@ function ActPvpSelectUI:_addListeners() uiMap["act_pvp_select_ui.bg.hero_cell_2.select_btn"]:addClickListener(function() ModuleManager.ActPvpManager:reqDecideHero(1) end) -end -function ActPvpSelectUI:_bind() - self:bind(DataManager.ActPvpData, "isDirty", function() - self:_display() + 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 + + local target = self.simpleHeroCells[heroEntity:getMatchType()] + if not target then + 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 @@ -124,6 +176,7 @@ function ActPvpSelectUI:refreshSelectInfo() local list = {} table.insert(list, {curPairIds[1], nextPairIds[1], nextPairIds[2]}) table.insert(list, {curPairIds[2], nextPairIds[3], nextPairIds[4]}) + self.heroEntities = {} for inedx, ids in pairs(list) do local curId = ids[1] local nextId1 = ids[2] @@ -133,8 +186,10 @@ function ActPvpSelectUI:refreshSelectInfo() local heroId = DataManager.ActPvpData:getSelectHeroId(curId) if heroId then local heroEntity = DataManager.HeroData:getEntity({id = heroId, level = DataManager.ActPvpData:getHeroLv()}) + self.heroEntities[inedx] = heroEntity unit.node:setVisible(true) unit.simpleHeroCell:refresh(heroEntity) + unit.simpleHeroCell:getBaseObject():setActive(false) unit.info:setSprite(GConst.ATLAS_PATH.COMMON, INFO_BG[heroEntity:getQlt()]) local heroInfo = heroEntity:getConfig() 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) imgCost:setVisible(true) txCost:setText(DataManager.ActPvpData:getFlushCost().num) - GFunc.centerImgAndTx(imgCost, txCost, 5) + GFunc.centerImgAndTx(imgCost, txCost, 0) ad:setVisible(false) end end diff --git a/lua/app/userdata/activity/act_pvp/act_pvp_data.lua b/lua/app/userdata/activity/act_pvp/act_pvp_data.lua index d0b5736e..421091b7 100644 --- a/lua/app/userdata/activity/act_pvp/act_pvp_data.lua +++ b/lua/app/userdata/activity/act_pvp/act_pvp_data.lua @@ -398,12 +398,11 @@ function ActPvpData:setLastTurnWin(win) end function ActPvpData:getHeroLevelUp() - -- return self.heroLevelUp - return true + return self.heroLevelUp end function ActPvpData:setHeroLevelUp(up) - -- self.heroLevelUp = up + self.heroLevelUp = up end ---- 排行榜