miduo_client/Assets/ManagedResources/~Lua/Modules/ArenaTopMatch/View/ATM_CommonInfo.lua

344 lines
16 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
---
2020-05-09 13:31:21 +08:00
--- 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 = {
2021-01-26 17:08:39 +08:00
[-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)},
2020-05-09 13:31:21 +08:00
}
local resultRes = {
2021-01-26 17:08:39 +08:00
[0] = {name = "UI_effect_JJC_JieSuan_ShiBai_png_zh"},
[1] = {name = "UI_effect_JJC_JieSuan_ShengLi_png_zh"},
2020-05-09 13:31:21 +08:00
}
local sortLayer=0
2020-05-09 13:31:21 +08:00
--------- 走 UI界面流程部分 ------------------------------
function this.InitComponent(root)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
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")
2020-07-03 16:09:15 +08:00
this.LeftWinNum = {}
this.RightWinNum = {}
2020-07-08 20:48:43 +08:00
this.LeftWinNumGo = Util.GetGameObject(this.infoPanel, "Left/winNum")
this.RightWinNumGo = Util.GetGameObject(this.infoPanel, "Right/winNum")
2020-08-24 21:46:19 +08:00
for i = 1, 2 do
2020-07-03 16:09:15 +08:00
this.LeftWinNum[i] = Util.GetGameObject(this.infoPanel, "Left/winNum/winNum (".. i ..")")
this.RightWinNum[i] = Util.GetGameObject(this.infoPanel, "Right/winNum/winNum (".. i ..")")
end
2020-05-09 13:31:21 +08:00
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 = {}
2020-07-03 16:09:15 +08:00
for i = 1, 6 do
2021-11-04 11:35:15 +08:00
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")
2021-11-05 13:35:14 +08:00
this.myBaby[i].starGrid = Util.GetGameObject(this.myBaby[i].hero, "starGrid")
2020-05-09 13:31:21 +08:00
end
this.damnEvil = {}
2020-07-03 16:09:15 +08:00
for a = 1, 6 do
2021-11-04 11:35:15 +08:00
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")
2021-11-05 13:35:14 +08:00
this.damnEvil[a].starGrid = Util.GetGameObject(this.damnEvil[a].hero, "starGrid")
2020-05-09 13:31:21 +08:00
end
-- 点击编队
this.btnBlueFormat = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/orggroup")
this.btnRedFormat = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/orggroup")
--等待其他战斗结束
2020-07-16 15:52:19 +08:00
this.awaitText = Util.GetGameObject(root.gameObject, "content/ATM_CommonPart/awaitText")
2020-05-09 13:31:21 +08:00
end
function this.BindEvent()
-- 两个按钮相同的功能
local function formatBtnClick()
local isCanFormat = this.panelType == 1 and ArenaTopMatchManager.CanChangeTeam()
if not isCanFormat then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10143])
2020-05-09 13:31:21 +08:00
else
2020-07-03 16:09:15 +08:00
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.ARENA_TOP_MATCH, function()
2020-05-09 13:31:21 +08:00
-- 重新获取战斗数据
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 -- 是否显示积分
2020-07-23 11:08:11 +08:00
--- @ battleEndResultSortState -- 是否需要翻转战斗数据
2020-07-15 18:23:40 +08:00
function this.SetInfoData(panelType, blueData, redData, textType, showScore,battleEndResultSortState)
2020-05-09 13:31:21 +08:00
this.panelType = panelType
this.blueData = blueData
this.redData = redData
this.rootPanel.transform.localPosition = panelPos[panelType]
this.rootPanel:SetActive(true)
2020-07-15 18:23:40 +08:00
this.battleEndResultSortState = battleEndResultSortState
2020-05-09 13:31:21 +08:00
this.RefreshData(showScore, textType)
this.SetBlueInfo(blueData, textType)
this.SetRedInfo(redData, textType)
this.FreshTeam(redData.team, false)
2020-07-23 11:08:11 +08:00
if panelType == 1 then--当时我的界面 并且准备阶段时 显示我自己的编队数据
local baseData = ArenaTopMatchManager.GetBaseData()
if baseData.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
2020-07-23 14:36:28 +08:00
this.FreshTeam2(FormationManager.GetFormationByID(FormationTypeDef.ARENA_TOM_MATCH), true)
2020-07-23 11:08:11 +08:00
else
this.FreshTeam(blueData.team, true)
end
elseif panelType == 2 then
this.FreshTeam(blueData.team, true)
end
2020-07-08 20:48:43 +08:00
this.RefreshTwoOutOfThreeData()
2020-07-16 14:13:27 +08:00
this.awaitText:SetActive(ArenaTopMatchManager.GetIsBattleEndState(this.panelType))
2020-07-24 10:01:48 +08:00
LogPink("ArenaTopMatchManager.GetIsBattleEndState(this.panelType) "..tostring(ArenaTopMatchManager.GetIsBattleEndState(this.panelType)))
2020-07-23 21:18:46 +08:00
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)
2020-05-09 13:31:21 +08:00
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
2021-04-21 13:12:04 +08:00
this.myFrame.sprite = GetPlayerHeadFrameSprite(this.spLoader, blueData.headFrame)
this.myIcon.sprite = GetPlayerHeadSprite(this.spLoader, blueData.head)
2020-05-09 13:31:21 +08:00
this.myName.text = blueData.name
if textType >= 0 then
this.myResult.gameObject:SetActive(true)
local myResult = textType
2021-04-21 13:12:04 +08:00
this.myResult.sprite = this.spLoader:LoadSprite(resultRes[myResult].name)
2020-05-09 13:31:21 +08:00
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
2021-04-21 13:12:04 +08:00
this.herFrame.sprite = GetPlayerHeadFrameSprite(this.spLoader, redData.headFrame)
this.herIcon.sprite = GetPlayerHeadSprite(this.spLoader, redData.head)
2020-05-09 13:31:21 +08:00
this.herName.text = redData.name
if textType >= 0 then
this.herResult.gameObject:SetActive(true)
local herResult = (textType + 1) % 2
2021-04-21 13:12:04 +08:00
this.herResult.sprite = this.spLoader:LoadSprite(resultRes[herResult].name)
2020-05-09 13:31:21 +08:00
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
2021-04-21 13:12:04 +08:00
-- this.textImg.sprite = this.spLoader:LoadSprite(imgRes[textType].resPath)
local imageTextType = textType
if ArenaTopMatchManager.GetIsBattleEndState(this.panelType) then
imageTextType = 1
end
2021-04-21 13:12:04 +08:00
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
2020-05-09 13:31:21 +08:00
-- 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
2020-07-08 20:48:43 +08:00
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)
2020-07-15 18:23:40 +08:00
2020-08-24 21:46:19 +08:00
for i = 1, 2 do
2020-07-15 18:23:40 +08:00
if this.battleEndResultSortState then
if upWinNum >= i then
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(true)
2020-07-15 18:23:40 +08:00
else
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(false)
2020-07-15 18:23:40 +08:00
end
if downWinNum >= i then
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(true)
2020-07-15 18:23:40 +08:00
else
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(false)
2020-07-15 18:23:40 +08:00
end
2020-07-08 20:48:43 +08:00
else
2020-07-15 18:23:40 +08:00
if upWinNum >= i then
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(true)
2020-07-15 18:23:40 +08:00
else
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.RightWinNum[i], "Image"):SetActive(false)
2020-07-15 18:23:40 +08:00
end
if downWinNum >= i then
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(true)
2020-07-15 18:23:40 +08:00
else
2020-08-24 21:46:19 +08:00
Util.GetGameObject(this.LeftWinNum[i], "Image"):SetActive(false)
2020-07-15 18:23:40 +08:00
end
2020-07-08 20:48:43 +08:00
end
end
end
2020-05-09 13:31:21 +08:00
end
2020-07-23 11:08:11 +08:00
--根据后端数据显示编队
2020-05-09 13:31:21 +08:00
function this.FreshTeam(formation, isBlue)
local teamRoot = isBlue and this.myBaby or this.damnEvil
for i, demon in ipairs(teamRoot) do
2021-11-04 11:35:15 +08:00
demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1))
demon.hero:SetActive(false)
2020-07-03 16:09:15 +08:00
end
for i, hero in ipairs(formation.team) do
local heroData = hero
2021-11-04 11:35:15 +08:00
teamRoot[heroData.position].hero:SetActive(true)
teamRoot[heroData.position].levelText.text = heroData.level
2021-10-26 16:00:31 +08:00
local star,starType = GetStarOrGodSoulLv(1,heroData)
2021-11-04 11:35:15 +08:00
SetHeroStars(this.spLoader,teamRoot[heroData.position].starGrid, star,starType)
2020-07-23 11:08:11 +08:00
local demonId = heroData.heroTid
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId)
2021-11-04 11:35:15 +08:00
teamRoot[heroData.position].frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality,heroData.star))
2020-11-06 09:37:27 +08:00
-- if not heroData.skinId or heroData.skinId == 0 then
2021-11-04 11:35:15 +08:00
-- Util.GetGameObject(teamRoot[heroData.position].hero, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon))
2020-11-06 09:37:27 +08:00
-- else
-- local heroSkinconfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId)
2021-11-04 11:35:15 +08:00
-- Util.GetGameObject(teamRoot[heroData.position].hero, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroSkinconfig.Icon))
2020-11-06 09:37:27 +08:00
-- end
2021-11-04 11:35:15 +08:00
SetHeroIcon(this.spLoader, heroData,teamRoot[heroData.position].icon,heroConfig)
SetHeroFlyEffect(teamRoot[heroData.position].hero,this.spLoader,heroData.star,sortLayer,1)
teamRoot[heroData.position].proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.propertyId))
2020-07-23 11:08:11 +08:00
end
end
--根据前端数据显示编队
function this.FreshTeam2(formation, isBlue)
local teamRoot = isBlue and this.myBaby or this.damnEvil
for i, demon in ipairs(teamRoot) do
2021-11-04 11:35:15 +08:00
demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1))
demon.hero:SetActive(false)
2020-07-23 11:08:11 +08:00
end
for i, hero in ipairs(formation.teamHeroInfos) do
local heroData = HeroManager.GetSingleHeroData(formation.teamHeroInfos[i].heroId)
2021-11-05 14:08:35 +08:00
teamRoot[hero.position].hero:SetActive(true)
teamRoot[hero.position].levelText.text = heroData.lv
2021-10-26 16:00:31 +08:00
local star,starType = heroData.GetStar(1)
2021-11-05 14:08:35 +08:00
SetHeroStars(this.spLoader, teamRoot[hero.position].starGrid, star,starType)
SetHeroFlyEffect(teamRoot[hero.position].hero,this.spLoader,heroData.star,sortLayer,1)
2020-07-23 11:08:11 +08:00
local heroConfig = heroData.heroConfig
2021-11-05 14:08:35 +08:00
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(heroData.changeProId))
2020-05-09 13:31:21 +08:00
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
2021-11-05 13:35:14 +08:00
function this:OnSortingOrderChange(sort)
2021-11-04 11:35:15 +08:00
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
sortLayer=sort+1
2021-11-04 11:35:15 +08:00
end
function this.OnDestroy()
this.myBaby = {}
this.damnEvil = {}
end
2020-06-23 18:36:24 +08:00
return this