412 lines
17 KiB
Lua
412 lines
17 KiB
Lua
----- 公会十绝阵详情面板 -----
|
|
require("Base/BasePanel")
|
|
local DeathPosInfoPanel = Inherit(BasePanel)
|
|
local this = DeathPosInfoPanel
|
|
|
|
local guildWarConfig = ConfigManager.GetConfig(ConfigName.GuildWarConfig)
|
|
local monsterGroup = ConfigManager.GetConfig(ConfigName.MonsterGroup)
|
|
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
local monsterViewConfig = ConfigManager.GetConfig(ConfigName.MonsterViewConfig)
|
|
local roleConfig = ConfigManager.GetConfig(ConfigName.RoleConfig)
|
|
|
|
local curIndex = 0 --当前打开绝阵索引
|
|
local rewardList = {} --挑战奖励预设容器
|
|
local liveNodes = {} --立绘容器
|
|
local liveNames = {} --立绘名容器
|
|
local guildName --公会名称
|
|
local guildServer --公会服
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabImgData = { select = "r_tongyong_xiaanniu_01", default = "r_tongyong_xiaanniu_02", }
|
|
local _TabFontColor = {
|
|
default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
|
select = Color.New(154 / 255, 78 / 255, 36 / 255, 1)
|
|
}
|
|
local _TabData = {
|
|
[1] = { txt = Language[11434] },
|
|
[2] = { txt = Language[11435] },
|
|
}
|
|
function DeathPosInfoPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.panel = Util.GetGameObject(this.gameObject, "Panel")
|
|
this.backBtn = Util.GetGameObject(this.panel, "BackBtn")
|
|
this.helpBtn = Util.GetGameObject(this.panel, "HelpBtn")
|
|
this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition
|
|
this.tabbox = Util.GetGameObject(this.panel, "TabBox")
|
|
|
|
--绝阵标题
|
|
this.title = Util.GetGameObject(this.panel, "Title"):GetComponent("Text")
|
|
--当前占据公会名称
|
|
this.curGuildName = Util.GetGameObject(this.panel, "CurGuild/Name"):GetComponent("Text")
|
|
this.curGuildserverName = Util.GetGameObject(this.panel, "CurGuild/serverName"):GetComponent("Text")
|
|
--剩余挑战次数
|
|
this.battleTime = Util.GetGameObject(this.panel, "BattleTime"):GetComponent("Text")
|
|
|
|
--敌人阵容组根节点
|
|
this.enemyGrid = Util.GetGameObject(this.panel, "EnemyGrid")
|
|
--英雄预设容器
|
|
this.heroPreList = {}
|
|
for i = 1, 6 do
|
|
this.heroPreList[i] = Util.GetGameObject(this.enemyGrid, "Bg" .. i .. "/Hero" .. i)
|
|
end
|
|
|
|
--奖励组根节点
|
|
this.rewardGrid = Util.GetGameObject(this.panel, "Reward/Grid")
|
|
--挑战按钮
|
|
this.goBtn = Util.GetGameObject(this.panel, "GoBtn")
|
|
|
|
--排名
|
|
this.rankTitle = Util.GetGameObject(this.panel, "Rank/Title/Name"):GetComponent("Text")
|
|
this.rankScroll = Util.GetGameObject(this.panel, "Rank/Scroll")
|
|
this.rankPre = Util.GetGameObject(this.panel, "Rank/Scroll/Pre")
|
|
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.rankScroll.transform, this.rankPre, nil,
|
|
Vector2.New(this.rankScroll.transform.rect.width, this.rankScroll.transform.rect.height), 1, 1,
|
|
Vector2.New(0, 10))
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
this.scrollView.moveTween.MomentumAmount = 1
|
|
this.scrollView.moveTween.Strength = 2
|
|
|
|
--我的排名
|
|
this.mRRank = Util.GetGameObject(this.panel, "Rank")
|
|
this.mRSortNum = Util.GetGameObject(this.panel, "Rank/MyRank/SortNum")
|
|
this.mRName = Util.GetGameObject(this.panel, "Rank/MyRank/Name"):GetComponent("Text")
|
|
this.mRHurt = Util.GetGameObject(this.panel, "Rank/MyRank/Hurt"):GetComponent("Text")
|
|
|
|
this.empty = Util.GetGameObject(this.panel, "Rank/Empty")
|
|
end
|
|
|
|
function DeathPosInfoPanel:BindEvent()
|
|
Util.AddOnceClick(this.backBtn, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddOnceClick(this.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.GuildTenPosInfo, this.helpPosition.x, this.helpPosition.y)
|
|
end)
|
|
--点击挑战
|
|
Util.AddOnceClick(this.goBtn, function()
|
|
if DeathPosManager.status ~= DeathPosStatus.Fight then
|
|
PopupTipPanel.ShowTip(Language[11451])
|
|
return
|
|
end
|
|
if DeathPosManager.allowchallange == DeathPosStatus.Belated then
|
|
PopupTipPanel.ShowTip(Language[11452])
|
|
return
|
|
end
|
|
if DeathPosManager.battleTime <= 0 then
|
|
PopupTipPanel.ShowTip(Language[10938])
|
|
return
|
|
end
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.GUILD_DEATHPOS, curIndex)
|
|
end)
|
|
end
|
|
|
|
function DeathPosInfoPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshFirstChangeData, this.RefreshGuildNameAndServerName)
|
|
end
|
|
|
|
function DeathPosInfoPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshFirstChangeData, this.RefreshGuildNameAndServerName)
|
|
end
|
|
|
|
function DeathPosInfoPanel:OnOpen(...)
|
|
local args = { ... }
|
|
curIndex = args[1]
|
|
guildName = args[2]
|
|
guildServer = args[3]
|
|
end
|
|
|
|
function DeathPosInfoPanel:OnShow()
|
|
this.RefreshPanel()
|
|
end
|
|
|
|
function DeathPosInfoPanel:OnClose()
|
|
this.empty:SetActive(false)
|
|
for i = 1, #this.heroPreList do
|
|
local o = this.heroPreList[i]
|
|
if liveNodes[o] then
|
|
poolManager:UnLoadLive(liveNames[o], liveNodes[o])
|
|
liveNames[o] = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
function DeathPosInfoPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
this.scrollView = nil
|
|
rewardList = {}
|
|
end
|
|
|
|
-- tab按钮自定义显示设置
|
|
function this.TabAdapter(tab, index, status)
|
|
local img = Util.GetGameObject(tab, "Image")
|
|
local txt = Util.GetGameObject(tab, "Text")
|
|
img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabImgData[status])
|
|
txt:GetComponent("Text").text = _TabData[index].txt
|
|
txt:GetComponent("Text").color = _TabFontColor[status]
|
|
end
|
|
|
|
-- tab改变回调事件
|
|
function this.OnTabChange(index, lastIndex)
|
|
this.RefreshRank(index)
|
|
end
|
|
|
|
function this.RefreshPanel()
|
|
if DeathPosManager.status == DeathPosStatus.Close then
|
|
this:ClosePanel()
|
|
return
|
|
end
|
|
|
|
-- this.curGuildName.text=guildName~="" and guildName or "无" --设置公会名称 没有占据显示无
|
|
-- this.curGuildserverName.text = guildServer or ""
|
|
-- if not guildServer or guildServer == "" then
|
|
-- this.curGuildserverName.gameObject:SetActive(false)
|
|
-- else
|
|
-- this.curGuildserverName.gameObject:SetActive(true)
|
|
-- end
|
|
this.RefreshGuildNameAndServerName()
|
|
this.title.text = GetLanguageStrById(guildWarConfig[curIndex].Name) .. Language[11453]
|
|
--【线上问题】十绝阵挑战次数显示负数 < 0 and 0 or (DeathPosManager.maxBattleTime-msg.challengeCount)
|
|
DeathPosManager.battleTime = DeathPosManager.battleTime < 0 and 0 or DeathPosManager.battleTime
|
|
this.battleTime.text = Language[10631] .. DeathPosManager.battleTime
|
|
this.SetFormation()
|
|
this.SetReward()
|
|
|
|
this.TabCtrl = TabBox.New()
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
|
|
this.TabCtrl:Init(this.tabbox, _TabData)
|
|
end
|
|
|
|
--刷新第一名公会 服务器 名字信息
|
|
--为什么 再onshow 调一次 事件监听又调用一次呢 有可能刷新界面的时候 推送还没有过来
|
|
function this.RefreshGuildNameAndServerName()
|
|
local data = DeathPosManager.GetGuildInfoData()
|
|
for key, value in pairs(data) do
|
|
if curIndex == value.pathId then
|
|
if value.guildName and value.guildName ~= "" then
|
|
guildName = value.guildName
|
|
end
|
|
if value.serverName and value.serverName ~= "" then
|
|
guildServer = value.serverName
|
|
end
|
|
end
|
|
end
|
|
this.curGuildName.text = guildName ~= "" and guildName or Language[10179] --设置公会名称 没有占据显示无
|
|
this.curGuildserverName.text = guildServer or ""
|
|
if not guildServer or guildServer == "" then
|
|
this.curGuildserverName.gameObject:SetActive(false)
|
|
else
|
|
this.curGuildserverName.gameObject:SetActive(true)
|
|
end
|
|
end
|
|
|
|
--设置敌人编队
|
|
function this.SetFormation()
|
|
local monsterGroupId = guildWarConfig[curIndex].MonsterId
|
|
|
|
for i, v in pairs(monsterGroup[monsterGroupId].Contents[1]) do
|
|
local o = this.heroPreList[i]
|
|
o.transform.parent:GetComponent("Image").sprite = this.spLoader:LoadSprite("t_chengyuankuang_kuang")
|
|
if v ~= 0 then
|
|
local id = monsterConfig[v].MonsterId
|
|
this.SetCardSingleData(o, id, i, monsterConfig[v])
|
|
o:SetActive(true)
|
|
else
|
|
o:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
--设置单个上阵英雄信息
|
|
function this.SetCardSingleData(o, heroId, _pos, heroData)
|
|
local bg = Util.GetGameObject(o, "Bg1"):GetComponent("Image")
|
|
local fg = Util.GetGameObject(o, "Bg2"):GetComponent("Image")
|
|
-- local live=Util.GetGameObject(o,"Mask/Live")
|
|
local lv = Util.GetGameObject(o, "lv/Text"):GetComponent("Text")
|
|
local pro = Util.GetGameObject(o, "Pro/Image"):GetComponent("Image")
|
|
local starGrid = Util.GetGameObject(o, "StarGrid")
|
|
local namePa = Util.GetGameObject(o, "Name")
|
|
local name = Util.GetGameObject(namePa, "Text"):GetComponent("Text")
|
|
-- local pos=Util.GetGameObject(o,"Pos"):GetComponent("Image")
|
|
local yuanImage = Util.GetGameObject(o, "yuanImage")
|
|
local hp = Util.GetGameObject(o, "hpProgress")
|
|
hp.gameObject:SetActive(false)
|
|
local rage = Util.GetGameObject(o, "rageProgress")
|
|
rage.gameObject:SetActive(false)
|
|
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
|
|
local config = heroConfig[heroId]
|
|
local liveName = GetResourcePath(config.Live)
|
|
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroId)
|
|
local scale = roleConfig.play_liveScale
|
|
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
|
|
live.texture = CardRendererManager.GetSpineTexture(_pos, liveName, Vector3.one * scale, livePos, true)
|
|
live.transform.localScale = Vector3.one
|
|
live.transform.localPosition = Vector3.zero
|
|
|
|
local zs = Util.GetGameObject(o, "zs")
|
|
local zsName = GetHeroCardStarZs[heroData.Star]
|
|
if zsName == "" then
|
|
zs:SetActive(false)
|
|
else
|
|
zs:SetActive(true)
|
|
zs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName)
|
|
end
|
|
|
|
yuanImage:SetActive(false)
|
|
lv.text = heroData.Level
|
|
|
|
bg.sprite = this.spLoader:LoadSprite(GetHeroCardStarBg[heroData.Star])
|
|
fg.sprite = this.spLoader:LoadSprite(GetHeroCardStarFg[heroData.Star])
|
|
|
|
pro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
|
|
SetCardStars(starGrid, heroData.Star)
|
|
SetHeroFormationFlyEffect(o, this.spLoader, Util.GetGameObject(o, "UI_Effect_jinkuang_KaPai"), heroData.Star, 401)
|
|
name.text = GetLanguageStrById(heroData.ReadingName)
|
|
--SetTextVerTial(name.gameObject, Vector3.New(34.5, -7.5, 0), nil, nil, 6)
|
|
end
|
|
|
|
--刷新排行榜 index当前排行类型索引
|
|
function this.RefreshRank(index)
|
|
this.rankTitle.text = index == 1 and Language[11447] or Language[11454]
|
|
|
|
local curRankType = RANK_TYPE.GUILD_DEATHPOS_GUILD --默认公会排行
|
|
if index == 1 then
|
|
curRankType = RANK_TYPE.GUILD_DEATHPOS_GUILD --公会排行
|
|
elseif index == 2 then
|
|
curRankType = RANK_TYPE.GUILD_DEATHPOS_PERSON --个人排行
|
|
end
|
|
-- NetManager.RequestRankInfo(curRankType,function(msg)
|
|
-- this.empty:SetActive(#msg.ranks<=0)
|
|
-- this.scrollView:SetData(msg.ranks,function(index,root)
|
|
-- this.SetScrollPre(root,msg.ranks[index],curRankType)
|
|
-- end)
|
|
-- this.scrollView:SetIndex(1)
|
|
|
|
-- --当我的排名没数据时
|
|
-- this.mRSortNum:SetActive(msg.myRankInfo.rank~=-1)
|
|
-- if msg.myRankInfo.rank==-1 then
|
|
-- this.mRName.text="未上榜"
|
|
-- this.mRHurt.text=""
|
|
-- return
|
|
-- end
|
|
-- this.SetMyRank(msg.myRankInfo,curRankType)
|
|
-- end,curIndex)
|
|
RankingManager.InitData(curRankType, function()
|
|
local ranks, myRankInfo = RankingManager.GetRankingInfo()
|
|
this.empty:SetActive(#ranks <= 0)
|
|
this.SetRankDataShow(ranks, myRankInfo, curRankType, false, false)
|
|
this.scrollView:SetIndex(1)
|
|
--当我的排名没数据时
|
|
this.mRSortNum:SetActive(myRankInfo.rank > 0)
|
|
if myRankInfo.rank < 1 then
|
|
this.mRName.text = Language[10036]
|
|
this.mRHurt.text = ""
|
|
return
|
|
end
|
|
this.SetMyRank(myRankInfo, curRankType)
|
|
end, curIndex, 1)
|
|
end
|
|
|
|
function this.SetRankDataShow(ranks, myRankInfo, curRankType, isNotTop, isNotAni)
|
|
this.scrollView:SetData(ranks, function(index, root)
|
|
this.SetScrollPre(root, ranks[index], curRankType)
|
|
if index == #ranks then
|
|
RankingManager.RequestNextWarPowerPageData(function()
|
|
local ranks, myRankInfo = RankingManager.GetRankingInfo()
|
|
this.SetRankDataShow(ranks, myRankInfo, curRankType, true, true)
|
|
end)
|
|
end
|
|
end, isNotTop, isNotAni)
|
|
end
|
|
|
|
--设置每条数据
|
|
function this.SetScrollPre(root, data, curRankType)
|
|
local name = Util.GetGameObject(root, "Name"):GetComponent("Text")
|
|
local hurt = Util.GetGameObject(root, "Hurt"):GetComponent("Text")
|
|
|
|
this.SetRankingNum(root, data.rankInfo.rank, false)
|
|
LogGreen("data.serverName:" .. tostring(data.serverName))
|
|
if curRankType == RANK_TYPE.GUILD_DEATHPOS_GUILD then
|
|
LogGreen("data.guildName:" .. tostring(data.guildName))
|
|
name.text = (data.serverName and data.serverName ~= "")
|
|
and data.serverName .. " " .. string.format(Language[11455], data.guildName, data.rankInfo.param2)
|
|
or string.format(Language[11455], data.guildName, data.rankInfo.param2) --公会名称(人数) param2 挑战人数
|
|
elseif curRankType == RANK_TYPE.GUILD_DEATHPOS_PERSON then
|
|
LogGreen("data.guildName:" .. tostring(data.userName))
|
|
name.text = (data.serverName and data.serverName ~= "")
|
|
and data.serverName .. " " .. string.format("%s", data.userName)
|
|
or string.format("%s", data.userName)
|
|
end
|
|
|
|
hurt.text = DeathPosManager.ChangeDamageForm(data.rankInfo.param1)
|
|
end
|
|
|
|
--设置我的名次
|
|
function this.SetMyRank(data, curRankType)
|
|
local guildData = MyGuildManager.GetMyGuildInfo()
|
|
this.SetRankingNum(this.mRRank, data.rank, true)
|
|
LogYellow("data.serverName:" .. tostring(data.serverName))
|
|
if curRankType == RANK_TYPE.GUILD_DEATHPOS_GUILD then
|
|
this.mRName.text = (data.serverName and data.serverName ~= "")
|
|
and data.serverName .. " " .. string.format(Language[11455], guildData.name, data.param2)
|
|
or string.format(Language[11455], guildData.name, data.param2) --param2 人数
|
|
elseif curRankType == RANK_TYPE.GUILD_DEATHPOS_PERSON then
|
|
this.mRName.text = (data.serverName and data.serverName ~= "")
|
|
and data.serverName .. " " .. PlayerManager.nickName
|
|
or PlayerManager.nickName
|
|
end
|
|
|
|
this.mRHurt.text = DeathPosManager.ChangeDamageForm(data.param1) --param1 伤害
|
|
end
|
|
|
|
--设置名次 isMy 是否是设置我的名次
|
|
function this.SetRankingNum(root, rank, isMy)
|
|
if rank < 1 then
|
|
return
|
|
end
|
|
local sortNumTabs = {}
|
|
for i = 1, 4 do
|
|
sortNumTabs[i] = Util.GetGameObject(root, "SortNum/SortNum (" .. i .. ")")
|
|
sortNumTabs[i]:SetActive(false)
|
|
end
|
|
if rank < 4 then
|
|
sortNumTabs[rank]:SetActive(true)
|
|
else
|
|
sortNumTabs[4]:SetActive(true)
|
|
if rank > 100 and isMy then
|
|
rank = "100+"
|
|
end
|
|
Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = rank
|
|
end
|
|
if isMy then
|
|
for i = 1, 4 do
|
|
Util.GetGameObject(root, "MyRank/SortNum/SortNum (" .. i .. ")"):SetActive(false)
|
|
end
|
|
if rank < 4 then
|
|
Util.GetGameObject(root, "MyRank/SortNum/SortNum (" .. rank .. ")"):SetActive(true)
|
|
else
|
|
Util.GetGameObject(root, "MyRank/SortNum/SortNum (4)"):SetActive(true)
|
|
Util.GetGameObject(root, "MyRank/SortNum/SortNum (4)/TitleText"):GetComponent("Text").text = rank
|
|
end
|
|
end
|
|
end
|
|
|
|
--设置挑战奖励
|
|
function this.SetReward()
|
|
for index, value in ipairs(guildWarConfig[curIndex].RewardShow) do
|
|
if not rewardList[index] then
|
|
rewardList[index] = SubUIManager.Open(SubUIConfig.ItemView, this.rewardGrid.transform)
|
|
end
|
|
rewardList[index]:OnOpen(false, value, 1.1, false, false, false)
|
|
rewardList[index].gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
end
|
|
end
|
|
|
|
return DeathPosInfoPanel
|