miduo_client/Assets/ManagedResources/~Lua/Modules/Ranking/RankingListMainPanel.lua

193 lines
8.0 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.

require("Base/BasePanel")
RankingListMainPanel = Inherit(BasePanel)
local this = RankingListMainPanel
local curIndex = 1
local rankKingListGo = {}
local TabBox = require("Modules/Common/TabBox")
local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001",lock = "r_hero_xuanze_002", name = Language[11673] },
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001",lock = "r_hero_xuanze_002", name = Language[11674] },
}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1),
lock = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
}
local ranks = {}
local proud = {}
this.playerScrollHead = {}--排行第一头像
--初始化组件(用于子类重写)
function RankingListMainPanel:InitComponent()
this.tabBox = Util.GetGameObject(self.gameObject, "TabBox")
this.TabCtrl = TabBox.New()
this.BackBtn = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.ItemPre = Util.GetGameObject(self.gameObject, "bg/panel/ItemPre")
this.grid = Util.GetGameObject(self.gameObject, "bg/panel/ScrollParentView/grid")
end
--绑定事件(用于子类重写)
function RankingListMainPanel:BindEvent()
Util.AddClick(this.BackBtn, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function RankingListMainPanel:AddListener()
end
--移除事件监听(用于子类重写)
function RankingListMainPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RankingListMainPanel:OnOpen(msg)
ranks = msg.ranks
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function RankingListMainPanel:OnShow()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
this.TabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
this.TabCtrl:Init(this.tabBox, _TabData, curIndex)
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status])
tabLab:GetComponent("Text").text = GetCurLanguage() ~= 2 and _TabData[index].name or "<size=40>".._TabData[index].name.."</size>"
tabLab:GetComponent("Text").color = _TabFontColor[status]
Util.GetGameObject(tab, "LockImage"):SetActive(status == "lock" )
end-- tab可用性检测
function this.PageTabIsLockCheck(index)
if index == 2 then
return true ,Language[11675]
else
return false
end
end
--切换视图
function this.SwitchView(index)
curIndex = index
proud = RankingManager.GetRankProud()
--先执行上一面板关闭逻辑
for i = 1, math.max(#rankKingListGo, #rankKingList) do
if rankKingList[i].isRankingMainPanelShow then
local go = rankKingListGo[i]
if not go then
go=newObject(this.ItemPre)
go.transform:SetParent(this.grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition=Vector3.zero;
rankKingListGo[i] = go
end
go.gameObject:SetActive(false)
end
end
for i = 1, #rankKingList do
if rankKingList[i].isRankingMainPanelShow then
rankKingListGo[i]:SetActive(true)
this.SingleRankKingListShow(i)
end
end
end
function this.SingleRankKingListShow(index)
local go = rankKingListGo[index]
local sData = rankKingList[index]
local dData = ranks[index]
local proud = proud[sData.rankType]
Util.GetGameObject(go,"BG"):GetComponent("Image").sprite = Util.LoadSprite(sData.bgImage)
Util.GetGameObject(go,"heor"):SetActive(dData.uid ~= 0 )
if dData.uid ~= 0 then
this.SetInfoShow(Util.GetGameObject(go,"heor/infoGo"),dData,sData.rankType,Util.GetGameObject(go,"heor/nameText"))
--头像
local headObj=Util.GetGameObject(go,"heor/Head")
if not this.playerScrollHead[go] then
this.playerScrollHead[go]=CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,headObj)
end
this.playerScrollHead[go]:Reset()
this.playerScrollHead[go]:SetHead(dData.head)
this.playerScrollHead[go]:SetFrame(dData.headFrame)
this.playerScrollHead[go]:SetLevel(dData.level)
this.playerScrollHead[go]:SetScale(Vector3.one*0.6)
this.playerScrollHead[go]:SetLayer(this.sortingOrder)
this.playerScrollHead[go]:SetEffectScale(0.7)
end
--膜拜
local clickBtn = Util.GetGameObject(go,"clickBtn")
local getRewardBtn = Util.GetGameObject(go,"getRewardBtn")
local getRewardBtnText = Util.GetGameObject(go,"getRewardBtn/Text"):GetComponent("Text")
getRewardBtn:SetActive(dData.uid ~= 0 )
Util.SetGray(getRewardBtn,proud ~= 0)
Util.AddOnceClick(clickBtn, function()
UIManager.OpenPanel(UIName.RankingSingleListPanel,sData)
end)
getRewardBtnText.fontSize = GetCurLanguage() ~= 2 and 50 or 40--根据语言设置大小
if proud == 0 then--没有膜拜过
getRewardBtn:GetComponent("Button").enabled = true
Util.GetGameObject(go,"getRewardBtn/redPoint"):SetActive(true)
getRewardBtnText.text = Language[11120]
Util.AddOnceClick(getRewardBtn, function()
NetManager.RankProudRequest(sData.rankType,function ()
RankingManager.SetSingleRankProud(sData.rankType,1)
local spFata = ConfigManager.GetConfigData(ConfigName.SpecialConfig,50)
local itemData = string.split(spFata.Value, "#")
PopupTipPanel.ShowTip(Language[11676]..GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,tonumber(itemData[1])).Name).."×"..itemData[2].."")
this.SwitchView(curIndex)
CheckRedPointStatus(RedPointType.RankingSort)
end)
end)
else
getRewardBtn:GetComponent("Button").enabled = false
getRewardBtnText.text = Language[11677]
Util.GetGameObject(go,"getRewardBtn/redPoint"):SetActive(false)
end
end
--界面关闭时调用(用于子类重写)
function RankingListMainPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function RankingListMainPanel:OnDestroy()
for _, playerHead in ipairs(this.playerScrollHead) do
playerHead:Recycle()
end
this.playerScrollHead = {}
rankKingListGo = {}
end
function this.SetInfoShow(go,data,rankType,nameText)
local fight = Util.GetGameObject(go,"fight")
local warPower = Util.GetGameObject(go,"warPower")
local trial = Util.GetGameObject(go,"trial")
fight:SetActive(false)
warPower:SetActive(false)
trial:SetActive(false)
if rankType == RANK_TYPE.FIGHT_LEVEL_RANK then
fight:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.userName
end
Util.GetGameObject(go,"fight"):GetComponent("Text").text = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.MainLevelConfig,data.rankInfo.param1).Name)
elseif rankType == RANK_TYPE.FORCE_CURR_RANK then
warPower:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.userName
end
Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1--data.force
elseif rankType == RANK_TYPE.GUILD_FORCE_RANK then
warPower:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.guildName
end
Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1
elseif rankType == RANK_TYPE.MONSTER_RANK then
trial:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.userName
end
Util.GetGameObject(go,"trial"):GetComponent("Text").text = GetLanguageStrById(Language[11689])..data.rankInfo.param1
end
end
return RankingListMainPanel