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

262 lines
11 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
--- 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")
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, 5 do
this.myBaby[i] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/demons/head_" .. i)
end
-- 3个我的宠物
this.myCat = {}
for j = 1, 3 do
this.myCat[j] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/diffdemons/icon_" .. j)
end
-- 5个她的它
this.damnEvil = {}
for a = 1, 5 do
this.damnEvil[a] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/demons/head_" .. a)
end
-- 她的该死的宠物
this.herDamnCat = {}
for b = 1, 3 do
this.herDamnCat[b] = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/diffdemons/icon_" .. b)
end
-- 点击编队
this.btnBlueFormat = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/myFormat/orggroup")
this.btnRedFormat = Util.GetGameObject(root.gameObject, "ATM_CommonPart/formatRoot/otherFormat/orggroup")
end
function this.BindEvent()
-- 两个按钮相同的功能
local function formatBtnClick()
local isCanFormat = this.panelType == 1 and ArenaTopMatchManager.CanChangeTeam()
if not isCanFormat then
PopupTipPanel.ShowTip(Language[10149])
else
UIManager.OpenPanel(UIName.FormationPanel, 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 -- 是否显示积分
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)
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
end
function this.FreshTeam(formation, isBlue)
local teamRoot = isBlue and this.myBaby or this.damnEvil
local diffDemonRoot = isBlue and this.myCat or this.herDamnCat
-- Log("isMe = "..tostring(isBlue)..",上阵人数 = "..#formation.team)
for i, demon in ipairs(teamRoot) do
if formation.team[i] then
demon:SetActive(true)
local heroData = formation.team[i]
Util.GetGameObject(demon, "lv/Text"):GetComponent("Text").text = heroData.level
SetHeroStars(Util.GetGameObject(demon, "star"), heroData.star)
local demonId = heroData.heroTid
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId)
Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(heroConfig.Quality))
Util.GetGameObject(demon, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(heroConfig.Icon))
local professionIcon
if GetJobSpriteStrByJobNum(heroConfig.Profession) then
professionIcon = GetJobSpriteStrByJobNum(heroConfig.Profession)
else
professionIcon = GetJobSpriteStrByJobNum(1)
end
Util.GetGameObject(demon, "posIcon"):GetComponent("Image").sprite = Util.LoadSprite(professionIcon)
Util.GetGameObject(demon, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
--Util.GetGameObject(demon, "heroStage"):GetComponent("Image").sprite = Util.LoadSprite(HeroStageSprite[heroConfig.HeroStage])
Util.GetGameObject(demon, "heroStage"):SetActive(false)
else
demon:SetActive(false)
end
end
-- 异妖
for i, diffDemon in ipairs(diffDemonRoot) do
if formation.PokemonInfos[i] then
diffDemon:SetActive(true)
local demonId = formation.PokemonInfos[i]
---TODO: 异妖条状头像资源未配置配置后增加根据ID获取资源名称
local resId = ConfigManager.GetConfigData(ConfigName.DifferDemonsConfig, demonId).LiveIcon
diffDemon:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(resId))
else
diffDemon:SetActive(false)
end
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