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

252 lines
11 KiB
Lua
Raw Normal View History

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 = {
[-1] = {pos = Vector3.New(36, 62, 0), resPath = "r_gonghui_zhan", size = Vector2.New(632, 533)},
[0] = {pos = Vector3.New(13, 62, 0), resPath = "r_playerrumble_wan", size = Vector2.New(420, 420)},
[1] = {pos = Vector3.New(13, 62, 0), resPath = "r_playerrumble_wan", size = Vector2.New(420, 420)},
}
local resultRes = {
[0] = {name = "UI_effect_JJC_JieSuan_ShiBai_png"},
[1] = {name = "UI_effect_JJC_JieSuan_ShengLi_png"},
}
--------- 走 UI界面流程部分 ------------------------------
function this.InitComponent(root)
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-07-03 16:09:15 +08:00
for i = 1, 3 do
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
this.myBaby[i] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/Demons/heroPro (" .. i .. ")")
2020-05-09 13:31:21 +08:00
end
this.damnEvil = {}
2020-07-03 16:09:15 +08:00
for a = 1, 6 do
this.damnEvil[a] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/Demons/heroPro (" .. a .. ")")
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")
--等待其他战斗结束
this.awaitText = Util.GetGameObject(this.infoPanel, "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
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[10149])
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 -- 是否显示积分
function this.SetInfoData(panelType, blueData, redData, textType, showScore)
this.panelType = panelType
this.blueData = blueData
this.redData = redData
this.rootPanel.transform.localPosition = panelPos[panelType]
this.rootPanel:SetActive(true)
this.RefreshData(showScore, textType)
this.SetBlueInfo(blueData, textType)
this.SetRedInfo(redData, textType)
this.FreshTeam(blueData.team, true)
this.FreshTeam(redData.team, false)
2020-07-08 20:48:43 +08:00
this.RefreshTwoOutOfThreeData()
LogGreen("ArenaTopMatchManager.GetIsBattleEndState() "..tostring( ArenaTopMatchManager.GetIsBattleEndState()))
this.awaitText:SetActive(ArenaTopMatchManager.GetIsBattleEndState())
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
this.myFrame.sprite = GetPlayerHeadFrameSprite(blueData.headFrame)
this.myIcon.sprite = GetPlayerHeadSprite(blueData.head)
this.myName.text = blueData.name
if textType >= 0 then
this.myResult.gameObject:SetActive(true)
local myResult = textType
this.myResult.sprite = Util.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(redData.headFrame)
this.herIcon.sprite = GetPlayerHeadSprite(redData.head)
this.herName.text = redData.name
if textType >= 0 then
this.herResult.gameObject:SetActive(true)
local herResult = (textType + 1) % 2
this.herResult.sprite = Util.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 = Util.LoadSprite(imgRes[textType].resPath)
this.textImg.sprite = Util.LoadSprite(imgRes[textType].resPath)
this.textImg.gameObject.transform.localPosition = imgRes[textType].pos
this.textImg.gameObject.transform.sizeDelta = imgRes[textType].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
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)
for i = 1, 3 do
if upWinNum >= i then
this.LeftWinNum[i]:SetActive(true)
else
this.LeftWinNum[i]:SetActive(false)
end
if downWinNum >= i then
this.RightWinNum[i]:SetActive(true)
else
this.RightWinNum[i]:SetActive(false)
end
end
end
2020-05-09 13:31:21 +08:00
end
function this.FreshTeam(formation, isBlue)
local teamRoot = isBlue and this.myBaby or this.damnEvil
for i, demon in ipairs(teamRoot) do
2020-07-03 16:09:15 +08:00
Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = Util.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(Util.GetGameObject(heroGo, "starGrid"), heroData.star)
2020-05-09 13:31:21 +08:00
local demonId = heroData.heroTid
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId)
2020-07-03 16:09:15 +08:00
Util.GetGameObject(teamRoot[heroData.position], "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(heroConfig.Quality))
Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(heroConfig.Icon))
Util.GetGameObject(heroGo, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
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
2020-06-23 18:36:24 +08:00
return this