--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by Steven Hawking. --- DateTime: 9/11/21 17:04 --- 公用数据显示部分 local this = {} -- 页签下标作为参数 local panelPos = { [1] = Vector3.New(0, 0, 0), -- 我的 [2] = Vector3.New(0, 270, 0), -- 竞猜 } local imgRes = { [-1] = {pos = Vector3.New(36, 62, 0), resPath = "r_gonghui_zhan_zh", size = Vector2.New(632, 533)}, [0] = {pos = Vector3.New(13, 62, 0), resPath = "r_playerrumble_wan_zh", size = Vector2.New(420, 420)}, [1] = {pos = Vector3.New(13, 62, 0), resPath = "r_playerrumble_wan_zh", size = Vector2.New(420, 420)}, } local resultRes = { [0] = {name = "UI_effect_JJC_JieSuan_ShiBai_png_zh"}, [1] = {name = "UI_effect_JJC_JieSuan_ShengLi_png_zh"}, } --------- 走 UI界面流程部分 ------------------------------ function this.InitComponent(root) this.spLoader = SpriteLoader.New() this.infoPanel = Util.GetGameObject(root.gameObject, "content/ATM_CommonPart/battlePopup") this.rootPanel = Util.GetGameObject(root.gameObject, "content/ATM_CommonPart") this.rootPanel:SetActive(false) this.myPowerNum = Util.GetGameObject(this.infoPanel, "Left/powerBtn/value"):GetComponent("Text") this.myLevel = Util.GetGameObject(this.infoPanel, "Left/Grade/level/Text"):GetComponent("Text") this.myFrame = Util.GetGameObject(this.infoPanel, "Left/Grade/headBg"):GetComponent("Image") this.myIcon = Util.GetGameObject(this.infoPanel, "Left/Grade/headIcon"):GetComponent("Image") this.myName = Util.GetGameObject(this.infoPanel, "Left/Grade/name"):GetComponent("Text") this.myScore = Util.GetGameObject(this.infoPanel, "Left/Grade/score"):GetComponent("Text") this.myResult = Util.GetGameObject(this.infoPanel, "Left/result"):GetComponent("Image") this.LeftWinNum = {} this.RightWinNum = {} this.LeftWinNumGo = Util.GetGameObject(this.infoPanel, "Left/winNum") this.RightWinNumGo = Util.GetGameObject(this.infoPanel, "Right/winNum") for i = 1, 2 do this.LeftWinNum[i] = Util.GetGameObject(this.infoPanel, "Left/winNum/winNum (".. i ..")") this.RightWinNum[i] = Util.GetGameObject(this.infoPanel, "Right/winNum/winNum (".. i ..")") end this.herPowerNum = Util.GetGameObject(this.infoPanel, "Right/Grade/powerBtn/value"):GetComponent("Text") this.herLevel = Util.GetGameObject(this.infoPanel, "Right/Grade/level/Text"):GetComponent("Text") this.herFrame = Util.GetGameObject(this.infoPanel, "Right/Grade/headBg"):GetComponent("Image") this.herIcon = Util.GetGameObject(this.infoPanel, "Right/Grade/headIcon"):GetComponent("Image") this.herName = Util.GetGameObject(this.infoPanel, "Right/Grade/name"):GetComponent("Text") this.herScore = Util.GetGameObject(this.infoPanel, "Right/Grade/score"):GetComponent("Text") this.herResult = Util.GetGameObject(this.infoPanel, "Right/result"):GetComponent("Image") this.textImg = Util.GetGameObject(this.infoPanel, "ShiBai_WenZi"):GetComponent("Image") this.myTeam = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat") this.herTeam = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat") -- 5个我的它 this.myBaby = {} for i = 1, 6 do this.myBaby[i] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/Demons/heroPro (" .. i .. ")") end this.damnEvil = {} for a = 1, 6 do this.damnEvil[a] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/Demons/heroPro (" .. a .. ")") end -- 点击编队 this.btnBlueFormat = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/orggroup") this.btnRedFormat = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/orggroup") --等待其他战斗结束 this.awaitText = Util.GetGameObject(root.gameObject, "content/ATM_CommonPart/awaitText") end function this.BindEvent() -- 两个按钮相同的功能 local function formatBtnClick() local isCanFormat = this.panelType == 1 and ArenaTopMatchManager.CanChangeTeam() if not isCanFormat then PopupTipPanel.ShowTip(Language[10143]) else UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.ARENA_TOP_MATCH, function() -- 重新获取战斗数据 ArenaTopMatchManager.RequestTopMatchBaseInfo() end) end end Util.AddClick(this.btnBlueFormat, formatBtnClick) Util.AddClick(this.btnRedFormat, formatBtnClick) end -------------------------------------------------------------------------------- function this.HidePopup() this.infoPanel:SetActive(false) end --- @设置模块数据, 相当于OnShow方法 --- @ panelType -- 1 --> 我的 ; 2 -- > 竞猜 --- @ textType -- 需要显示的文字类型 -1 --> 战 ; 1 -- > 胜; 0 --> 败 --- @ showScore -- 是否显示积分 --- @ battleEndResultSortState -- 是否需要翻转战斗数据 function this.SetInfoData(panelType, blueData, redData, textType, showScore,battleEndResultSortState) this.panelType = panelType this.blueData = blueData this.redData = redData this.rootPanel.transform.localPosition = panelPos[panelType] this.rootPanel:SetActive(true) this.battleEndResultSortState = battleEndResultSortState this.RefreshData(showScore, textType) this.SetBlueInfo(blueData, textType) this.SetRedInfo(redData, textType) this.FreshTeam(redData.team, false) if panelType == 1 then--当时我的界面 并且准备阶段时 显示我自己的编队数据 local baseData = ArenaTopMatchManager.GetBaseData() if baseData.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then this.FreshTeam2(FormationManager.GetFormationByID(FormationTypeDef.ARENA_TOM_MATCH), true) else this.FreshTeam(blueData.team, true) end elseif panelType == 2 then this.FreshTeam(blueData.team, true) end this.RefreshTwoOutOfThreeData() this.awaitText:SetActive(ArenaTopMatchManager.GetIsBattleEndState(this.panelType)) LogPink("ArenaTopMatchManager.GetIsBattleEndState(this.panelType) "..tostring(ArenaTopMatchManager.GetIsBattleEndState(this.panelType))) if this.panelType == 1 then this.awaitText.transform.localPosition = Vector3.New(0,785,0) elseif this.panelType == 2 then this.awaitText.transform.localPosition = Vector3.New(0,515,0) end Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.CommonInfoRefreshTitle) end -- 设置显隐 function this.SetActive(isActive) -- body this.rootPanel:SetActive(isActive) end function this.SetBlueInfo(blueData, textType) -- Log("我的战力 = "..blueData.team.totalForce) this.myPowerNum.text = blueData.team.totalForce this.myLevel.text = blueData.level this.myFrame.sprite = GetPlayerHeadFrameSprite(this.spLoader, blueData.headFrame) this.myIcon.sprite = GetPlayerHeadSprite(this.spLoader, blueData.head) this.myName.text = blueData.name if textType >= 0 then this.myResult.gameObject:SetActive(true) local myResult = textType this.myResult.sprite = this.spLoader:LoadSprite(resultRes[myResult].name) this.myResult:SetNativeSize() else this.myResult.gameObject:SetActive(false) end end function this.SetRedInfo(redData, textType) -- Log("我的战力 = "..redData.team.totalForce) this.herPowerNum.text = redData.team.totalForce this.herLevel.text = redData.level this.herFrame.sprite = GetPlayerHeadFrameSprite(this.spLoader, redData.headFrame) this.herIcon.sprite = GetPlayerHeadSprite(this.spLoader, redData.head) this.herName.text = redData.name if textType >= 0 then this.herResult.gameObject:SetActive(true) local herResult = (textType + 1) % 2 this.herResult.sprite = this.spLoader:LoadSprite(resultRes[herResult].name) this.herResult:SetNativeSize() else this.herResult.gameObject:SetActive(false) end end function this.SetEffectPopupShow(state) this.rootPanel:SetActive(state) end -- 在此界面时刷新数据 --- 设置积分与文字图标 function this.RefreshData(showScore, textType) if showScore and textType >= 0 then this.herScore.gameObject:SetActive(true) this.myScore.gameObject:SetActive(true) local deltaIntegral = ArenaTopMatchManager.GetMatchDeltaIntegral() this.myScore.text = textType == 1 and "+"..deltaIntegral.."" or "0" this.herScore.text = textType == 1 and "0" or "+"..deltaIntegral.."" else this.herScore.gameObject:SetActive(false) this.myScore.gameObject:SetActive(false) end -- this.textImg.sprite = this.spLoader:LoadSprite(imgRes[textType].resPath) local imageTextType = textType if ArenaTopMatchManager.GetIsBattleEndState(this.panelType) then imageTextType = 1 end this.textImg.sprite = this.spLoader:LoadSprite(imgRes[imageTextType].resPath) this.textImg.gameObject.transform.localPosition = imgRes[imageTextType].pos this.textImg.gameObject.transform.sizeDelta = imgRes[imageTextType].size -- this.textImg:SetNativeSize() -- 设置编队按钮状态 if this.panelType == 1 then this.btnBlueFormat:SetActive(this.blueData.uid == PlayerManager.uid) this.btnRedFormat:SetActive(this.redData.uid == PlayerManager.uid) local isCanFormat = ArenaTopMatchManager.CanChangeTeam() Util.SetGray(this.btnBlueFormat, not isCanFormat) Util.SetGray(this.btnRedFormat, not isCanFormat) elseif this.panelType == 2 then this.btnBlueFormat:SetActive(false) this.btnRedFormat:SetActive(false) end end function this.RefreshTwoOutOfThreeData() this.LeftWinNumGo:SetActive(ArenaTopMatchManager.GetBaseData().battleStage == TOP_MATCH_STAGE.ELIMINATION) this.RightWinNumGo:SetActive(ArenaTopMatchManager.GetBaseData().battleStage == TOP_MATCH_STAGE.ELIMINATION) if ArenaTopMatchManager.GetBaseData().battleStage == TOP_MATCH_STAGE.ELIMINATION then local upWinNum,downWinNum = ArenaTopMatchManager.GetTwoOutOfThreeInfo(this.panelType) for i = 1, 2 do if this.battleEndResultSortState then if upWinNum >= i then Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(true) else Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(false) end if downWinNum >= i then Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(true) else Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(false) end else if upWinNum >= i then Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(true) else Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(false) end if downWinNum >= i then Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(true) else Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(false) end end end end end --根据后端数据显示编队 function this.FreshTeam(formation, isBlue) local teamRoot = isBlue and this.myBaby or this.damnEvil for i, demon in ipairs(teamRoot) do Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1)) Util.GetGameObject(demon, "hero"):SetActive(false) end for i, hero in ipairs(formation.team) do local heroData = hero local heroGo = Util.GetGameObject(teamRoot[heroData.position], "hero") heroGo:SetActive(true) Util.GetGameObject(heroGo, "lvbg/levelText"):GetComponent("Text").text = heroData.level SetHeroStars(this.spLoader, Util.GetGameObject(heroGo, "starGrid"), heroData.star,1) local demonId = heroData.heroTid local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId) Util.GetGameObject(teamRoot[heroData.position], "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality,heroData.star)) -- if not heroData.skinId or heroData.skinId == 0 then -- Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon)) -- else -- local heroSkinconfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId) -- Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroSkinconfig.Icon)) -- end SetHeroIcon(this.spLoader, heroData,Util.GetGameObject(heroGo, "icon"):GetComponent("Image"),heroConfig) Util.GetGameObject(heroGo, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName)) end end --根据前端数据显示编队 function this.FreshTeam2(formation, isBlue) local teamRoot = isBlue and this.myBaby or this.damnEvil for i, demon in ipairs(teamRoot) do Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1)) Util.GetGameObject(demon, "hero"):SetActive(false) end for i, hero in ipairs(formation.teamHeroInfos) do local heroData = HeroManager.GetSingleHeroData(formation.teamHeroInfos[i].heroId) local heroGo = Util.GetGameObject(teamRoot[formation.teamHeroInfos[i].position], "hero") heroGo:SetActive(true) Util.GetGameObject(heroGo, "lvbg/levelText"):GetComponent("Text").text = heroData.lv SetHeroStars(this.spLoader, Util.GetGameObject(heroGo, "starGrid"), heroData.star,1) local heroConfig = heroData.heroConfig Util.GetGameObject(teamRoot[formation.teamHeroInfos[i].position], "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality,heroData.star)) Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon) Util.GetGameObject(heroGo, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName)) end end -- 控制显示编队信息 --- @showType 0 = both hide; 1 = show me and hide bitch; 2 = show bitch and hide me function this.SetFormationShow(showType, showFormat) this.rootPanel:SetActive(true) this.herTeam:SetActive(showType == 2) this.herTeam:SetActive(showType == 1) this.infoPanel:SetActive(showFormat) end return this