340 lines
16 KiB
Lua
340 lines
16 KiB
Lua
---
|
||
--- 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] = {}
|
||
this.myBaby[i].go = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/Demons/heroPro (" .. i .. ")")
|
||
this.myBaby[i].frame = Util.GetGameObject(this.myBaby[i].go, "frame"):GetComponent("Image")
|
||
this.myBaby[i].hero = Util.GetGameObject(this.myBaby[i].go, "hero")
|
||
this.myBaby[i].levelText = Util.GetGameObject(this.myBaby[i].hero, "lvbg/levelText"):GetComponent("Text")
|
||
this.myBaby[i].icon = Util.GetGameObject(this.myBaby[i].hero, "icon"):GetComponent("Image")
|
||
this.myBaby[i].proIcon = Util.GetGameObject(this.myBaby[i].hero, "proIcon"):GetComponent("Image")
|
||
this.myBaby[i].starGrid = Util.GetGameObject(this.myBaby[i].hero, "starGrid")
|
||
end
|
||
this.damnEvil = {}
|
||
for a = 1, 6 do
|
||
this.damnEvil[a] = {}
|
||
this.damnEvil[a].go = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/Demons/heroPro (" .. a .. ")")
|
||
this.damnEvil[a].frame = Util.GetGameObject(this.damnEvil[a].go, "frame"):GetComponent("Image")
|
||
this.damnEvil[a].hero = Util.GetGameObject(this.damnEvil[a].go, "hero")
|
||
this.damnEvil[a].levelText = Util.GetGameObject(this.damnEvil[a].hero, "lvbg/levelText"):GetComponent("Text")
|
||
this.damnEvil[a].icon = Util.GetGameObject(this.damnEvil[a].hero, "icon"):GetComponent("Image")
|
||
this.damnEvil[a].proIcon = Util.GetGameObject(this.damnEvil[a].hero, "proIcon"):GetComponent("Image")
|
||
this.damnEvil[a].starGrid = Util.GetGameObject(this.damnEvil[a].hero, "starGrid")
|
||
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 "<color=green>+"..deltaIntegral.."</color>" or "<color=red>0</color>"
|
||
this.herScore.text = textType == 1 and "<color=red>0</color>" or "<color=green>+"..deltaIntegral.."</color>"
|
||
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
|
||
demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1))
|
||
demon.hero:SetActive(false)
|
||
end
|
||
for i, hero in ipairs(formation.team) do
|
||
local heroData = hero
|
||
teamRoot[heroData.position].hero:SetActive(true)
|
||
teamRoot[heroData.position].levelText.text = heroData.level
|
||
local star,starType = GetStarOrGodSoulLv(1,heroData)
|
||
SetHeroStars(this.spLoader,teamRoot[heroData.position].starGrid, star,starType)
|
||
local demonId = heroData.heroTid
|
||
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId)
|
||
teamRoot[heroData.position].frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality,heroData.star))
|
||
-- if not heroData.skinId or heroData.skinId == 0 then
|
||
-- Util.GetGameObject(teamRoot[heroData.position].hero, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon))
|
||
-- else
|
||
-- local heroSkinconfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId)
|
||
-- Util.GetGameObject(teamRoot[heroData.position].hero, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroSkinconfig.Icon))
|
||
-- end
|
||
SetHeroIcon(this.spLoader, heroData,teamRoot[heroData.position].icon,heroConfig)
|
||
teamRoot[heroData.position].proIcon.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
|
||
demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1))
|
||
demon.hero:SetActive(false)
|
||
end
|
||
for i, hero in ipairs(formation.teamHeroInfos) do
|
||
local heroData = HeroManager.GetSingleHeroData(formation.teamHeroInfos[i].heroId)
|
||
teamRoot[hero.position].hero:SetActive(true)
|
||
teamRoot[hero.position].levelText.text = heroData.lv
|
||
local star,starType = heroData.GetStar(1)
|
||
SetHeroStars(this.spLoader, teamRoot[hero.position].starGrid, star,starType)
|
||
local heroConfig = heroData.heroConfig
|
||
teamRoot[hero.position].frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality,heroData.star))
|
||
teamRoot[hero.position].icon.sprite = this.spLoader:LoadSprite(heroData.icon)
|
||
teamRoot[hero.position].proIcon.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
|
||
|
||
function this:OnSortingOrderChange(sort)
|
||
for i, demon in ipairs(this.myBaby) do
|
||
Util.SetParticleSortLayer(demon.starGrid,sort + 1)
|
||
end
|
||
for i, demon in ipairs(this.damnEvil) do
|
||
Util.SetParticleSortLayer(demon.starGrid,sort + 1)
|
||
end
|
||
end
|
||
|
||
function this.OnDestroy()
|
||
this.myBaby = {}
|
||
this.damnEvil = {}
|
||
end
|
||
|
||
return this |