miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/PlayerInfoPopup_extra.lua

113 lines
4.2 KiB
Lua

local PlayerInfoPopup_extra = {}
local this = PlayerInfoPopup_extra
local _PlayerHead = nil
local titleLiveStr = nil
local titleLive = nil
function this.Init( _parent,_data,_ViewConfig)
this.infoPopup = _parent
this.data = _data
this.viewConfig = _ViewConfig
this.RefreshPlayerInfo(this.data)
this.FormationAdapter(this.data.teamInfo)
this.RefreshBtnShow()
end
function this.RefreshPlayerInfo(data)
this.infoPopup.memName.text = data.name
this.infoPopup.memProfess.text = ""
-- 头像
if not _PlayerHead then
_PlayerHead = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.infoPopup.memHead.transform)
end
_PlayerHead:Reset()
_PlayerHead:SetScale(Vector3.one * 0.85)
_PlayerHead:SetHead(data.head)
_PlayerHead:SetFrame(data.headFrame)
_PlayerHead:SetLevel(data.level)
_PlayerHead:SetLayer(this.infoPopup.sortingOrder)
_PlayerHead:SetEffectScale(0.9)
this.infoPopup.titlePar:SetActive(false)
end
-- 编队数据匹配
function this.FormationAdapter(teamInfo)
this.infoPopup.formationTip.text = this.viewConfig.tip
-- 战斗力
this.infoPopup.memPower.text = teamInfo.totalForce
for i, demon in ipairs(this.infoPopup.Demons) do
demon.frame.sprite = this.infoPopup.spLoader:LoadSprite(GetQuantityImageByquality(1))
demon.hero:SetActive(false)
end
--队伍阵容
for i, hero in ipairs(teamInfo.team) do
local demonId = teamInfo.team[i].heroTid
if demonId then
this.infoPopup.Demons[hero.position].hero:SetActive(true)
local star,starType = GetStarOrGodSoulLv(1,hero)
local starSize = Vector2.New(35,35)
local starScale = -8
if starType == 3 then
starSize = Vector2.New(1,-15.65)
starScale = -13
elseif starType == 2 then
starSize = Vector2.New(60,57)
end
SetHeroStars(this.infoPopup.spLoader, this.infoPopup.Demons[hero.position].starGrid, star,starType,starSize,starScale)
Util.SetParticleSortLayer(this.infoPopup.Demons[hero.position].starGrid,this.infoPopup.sortingOrder + 1)
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId)
this.infoPopup.Demons[hero.position].proIcon.sprite = this.infoPopup.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
this.infoPopup.Demons[hero.position].levelText.text = hero.level
this.infoPopup.Demons[hero.position].frame.sprite = this.infoPopup.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality, hero.star))
SetHeroIcon(this.infoPopup.spLoader, hero,this.infoPopup.Demons[hero.position].icon,heroConfig)
end
end
end
-- 刷新按钮显示
function this.RefreshBtnShow()
this.infoPopup.btnBox:SetActive(true)
this.infoPopup.addFriendBtn:SetActive(false)
this.infoPopup.starBox:SetActive(false)
-- 按钮功能
local btnType = this.infoPopup._Config.btnType
for index, btn in ipairs(this.infoPopup.btnList) do
btn:SetActive(btnType[index] ~= nil)
if btnType[index] then
Util.GetGameObject(btn, "Text"):GetComponent("Text").text = btnType[index].name
Util.AddOnceClick(btn, function()
local funcType = btnType[index].func
if not this.infoPopup.btnFunc[funcType] then
Log("方法不存在")
return
end
this.infoPopup.btnFunc[funcType](btnType[index].param)
end)
end
end
if this.infoPopup._ViewType == PLAYER_INFO_VIEW_TYPE.LINGMAIMIJING then
this.infoPopup.btnBox:SetActive(true)
this.infoPopup.btnList[1]:SetActive(false)
this.infoPopup.btnList[2]:SetActive(true)
this.infoPopup.btnList[3]:SetActive(false)
if LingMaiMiJingManager.myPlaceId < this.data.Id then
this.infoPopup.btnBox:SetActive(false)
this.infoPopup.btnList[2]:SetActive(false)
end
end
end
function this.OnDestroy()
-- 头像
if _PlayerHead then
_PlayerHead:Recycle()
_PlayerHead = nil
end
titleLive = nil
titleLiveStr = nil
end
return this