miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/RoleListPanel.lua

387 lines
16 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")
RoleListPanel = Inherit(BasePanel)
local this = RoleListPanel
local sortType = 1 -- 1品阶 2等级
local proId=0--0 全部 1 火 2风 3 水 4 地 5 光 6 暗
local tarHero = {}
local teamHero = {}
local roleDatas={}
this.isFirstOpen=true
local tabs = {}
local soulPrintData={}
local orginLayer = 0
local orginLayer2 = 0
local isFristOpenTime = Timer.New()
function RoleListPanel:InitComponent()
this.BtnBack = Util.GetGameObject(self.transform, "rightUp/btnBack")
this.cardPre = poolManager:LoadAsset("card", PoolManager.AssetType.GameObject)
this.cardPre.transform:SetParent(self.transform)
this.cardPre:GetComponent("RectTransform").localScale = Vector3.New(1,1,1)
this.btnPrant = Util.GetGameObject(self.gameObject, "Tabs")
for i = 0, 6 do
tabs[i] = Util.GetGameObject(self.transform, "Tabs/grid/Btn" .. i)
end
this.ShaiXuanBtn = Util.GetGameObject(self.gameObject, "ShaiXuanBtn")
this.ShaiXuanBtnLv = Util.GetGameObject(self.gameObject, "ShaiXuanBtn/Lv")
this.ShaiXuanBtnQu = Util.GetGameObject(self.gameObject, "ShaiXuanBtn/Qu")
this.selectBtn = Util.GetGameObject(self.gameObject, "Tabs/selectBtn")
this.heroNumText = Util.GetGameObject(self.gameObject, "heroNum")
this.ScrollBar = Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
this.fenJieBtn = Util.GetGameObject(self.gameObject, "fenJieBtn")
--this.fenJieBtn:SetActive(false)
this.formationBtn = Util.GetGameObject(self.gameObject, "formationBtn")
this.BtView =SubUIManager.Open(SubUIConfig.BtView, self.gameObject.transform)
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
local v2 = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.transform, "scroll").transform,
this.cardPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(19.32,15))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
-- 嚣张的头像
this.level = Util.GetGameObject(self.gameObject, "LeftUp/headBox/lvFrame/lv"):GetComponent("Text")
this.playName = Util.GetGameObject(self.gameObject, "LeftUp/headBox/name"):GetComponent("Text")
this.expSliderValue = Util.GetGameObject(self.gameObject, "LeftUp/headBox/exp"):GetComponent("Slider")
this.headBox = Util.GetGameObject(self.gameObject, "LeftUp/headBox")
this.headPos = Util.GetGameObject(self.gameObject, "LeftUp/headBox/headpos")
this.headRedpot = Util.GetGameObject(self.gameObject, "LeftUp/headBox/redpot")
this.teamPower = Util.GetGameObject(self.gameObject, "LeftUp/powerBtn/value"):GetComponent("Text")
this.maxk = Util.GetGameObject(self.gameObject, "maxk")
-- 特权
this.vipPrivilegeBtn = Util.GetGameObject(self.gameObject, "LeftUp/vipPrivilege/vipPrivilegeBtn")
this.vipLevelText = Util.GetGameObject(this.vipPrivilegeBtn, "bg/vip"):GetComponent("Image")
this.vipRedPoint = Util.GetGameObject(self.gameObject, "LeftUp/vipPrivilege/redPoint")
screenAdapte(this.vipPrivilegeBtn)
end
--绑定事件(用于子类重写)
function RoleListPanel:BindEvent()
Util.AddClick(this.BtnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
HeroManager.heroListPanelSortID=SortTypeConst.Natural
HeroManager.heroListPanelProID=ProIdConst.All
UIManager.OpenPanel(UIName.MainPanel)
end)
for i = 0, 6 do
Util.AddClick(tabs[i], function()
if this.isFirstOpen == false then
if i == proId then
proId=ProIdConst.All
HeroManager.heroListPanelProID=ProIdConst.All
else
proId=i
HeroManager.heroListPanelProID=proId
end
this:GetCurSortHeroListData()
end
end)
end
Util.AddClick(this.ShaiXuanBtn, function()
if sortType == SortTypeConst.Lv then
sortType = SortTypeConst.Natural
HeroManager.heroListPanelSortID=SortTypeConst.Natural
else
sortType = SortTypeConst.Lv
HeroManager.heroListPanelSortID=SortTypeConst.Lv
end
this.ShaiXuanBtnLv:SetActive(sortType ~= SortTypeConst.Lv)
this.ShaiXuanBtnQu:SetActive(sortType ~= SortTypeConst.Natural)
this:GetCurSortHeroListData()
end)
Util.AddClick(this.fenJieBtn, function()
UIManager.OpenPanel(UIName.HandBookHeroAndEquipListPanel,1)
--if ActTimeCtrlManager.SingleFuncState(24) then
-- UIManager.OpenPanel(UIName.HeroAndEquipResolvePanel,1)
--else
-- PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(24))
--end
end)
Util.AddClick(this.formationBtn, function()
if ActTimeCtrlManager.SingleFuncState(54) then
-- UIManager.OpenPanel(UIName.FormationSetPanel)
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION)
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(54))
end
end)
-- 点击你的猪头
Util.AddClick(this.headBox, function ()
UIManager.OpenPanel(UIName.SettingPanel)
end)
BindRedPointObject(RedPointType.Setting, this.headRedpot)
Util.AddClick(this.vipPrivilegeBtn, function()
UIManager.OpenPanel(UIName.VipPanelV2)
end)
BindRedPointObject(RedPointType.VipPrivilege, this.vipRedPoint)
end
--添加事件监听(用于子类重写)
function RoleListPanel:AddListener()
end
--移除事件监听(用于子类重写)
function RoleListPanel:RemoveListener()
end
function this:OnSortingOrderChange()
Util.AddParticleSortLayer(this.vipPrivilegeBtn, self.sortingOrder - orginLayer)
this.ScrollView:ForeachItemGO(function (index, go)
Util.AddParticleSortLayer(go, self.sortingOrder - orginLayer)
end)
orginLayer = self.sortingOrder
this.BtView:SetOrderStatus({ sortOrder = self.sortingOrder })
end
--界面打开时调用(用于子类重写)
function RoleListPanel:OnShow()
--检测成员红点
CheckRedPointStatus(RedPointType.Role)
tarHero=HeroManager.GetAllHeroDatas()
teamHero=FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL)
this.isFirstOpen=true
this.maxk:SetActive(true)
this.heroNumText:GetComponent("Text").text=string.format(Language[11856],#tarHero)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.RoleInfo })
this.BtView:OnOpen({sortOrder = self.sortingOrder,panelType = PanelTypeView.MemberPanel})
SoundManager.PlayMusic(SoundConfig.BGM_Main)
sortType = HeroManager.heroListPanelSortID
proId = HeroManager.heroListPanelProID
this:GetCurSortHeroListData()
--if ActTimeCtrlManager.SingleFuncState(24) then
-- Util.SetGray(this.fenJieBtn, false)
--else
--Util.SetGray(this.fenJieBtn, true)
--end
if ActTimeCtrlManager.SingleFuncState(54) then
Util.SetGray(this.formationBtn, false)
else
Util.SetGray(this.formationBtn, true)
end
if this.ScrollView then
this.ScrollView:SetIndex(1)
end
this.FreshPlayerInfo()
this.SetPlayerHead()
end
-- 刷新玩家信息显示
function this.FreshPlayerInfo()
this.vipLevelText.sprite = VipManager.SetVipLevelImg()
this.level.text = PlayerManager.level
this.expSliderValue.value = PlayerManager.exp / PlayerManager.userLevelData[PlayerManager.level].Exp
this.playName.text = PlayerManager.nickName
this.teamPower.text = FormationManager.GetFormationPower(FormationManager.curFormationIndex)
end
-- 设置头像
function this.SetPlayerHead()
if not this.playerHead then
this.playerHead = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.headPos.transform)
end
this.playerHead:SetHead(PlayerManager.head)
this.playerHead:SetFrame(PlayerManager.frame)
this.playerHead:SetScale(Vector3.one * 0.9)
this.playerHead:SetPosition(Vector3.New(-5, 0, 0))
end
--组合当前选项数据
function this:GetCurSortHeroListData()
local heros = {}
if proId ~= ProIdConst.All then
heros = HeroManager.GetHeroDataByProperty(proId)
else
heros = tarHero
end
this:SetRoleList(heros)
this:SetSelectBtn()
end
--设置英雄列表数据
function this:SetRoleList(_roleDatas)
roleDatas=_roleDatas
this:SortHeroDatas(_roleDatas)
HeroManager.heroSortedDatas = roleDatas
this.heroNumText:GetComponent("Text").text=string.format(Language[11856],#_roleDatas)
this.ScrollView:SetData(_roleDatas, function (index, go)
if this.isFirstOpen then
go.gameObject:SetActive(false)
end
this.SingleHeroDataShow(go, roleDatas[index])
end)
if this.isFirstOpen then
this.ScrollView:ForeachItemGO(function (index, go)
Timer.New(function ()
go.gameObject:SetActive(true)
PlayUIAnim(go.gameObject)
end, 0.03*(index-1)):Start()
end)
if isFristOpenTime then
isFristOpenTime:Stop()
isFristOpenTime = nil
end
isFristOpenTime = Timer.New(function()
this.isFirstOpen = false
this.maxk:SetActive(false)
end, 0.8):Start()
end
this.ScrollView:ForeachItemGO(function (index, go)
Util.AddParticleSortLayer(go, self.sortingOrder - orginLayer2)
end)
orginLayer2 =self.sortingOrder
orginLayer = self.sortingOrder
end
function this.SingleHeroDataShow(_go,_heroData)
local heroData = _heroData
SetHeroBg(Util.GetGameObject(_go.transform, "card"),Util.GetGameObject(_go.transform, "card/bg"),_heroData.star,heroData.heroConfig.Quality)
Util.GetGameObject(_go.transform, "card/lv/Text"):GetComponent("Text").text = heroData.lv
Util.GetGameObject(_go.transform, "card/name"):GetComponent("Text").text = heroData.heroConfig.ReadingName
Util.GetGameObject(_go.transform, "card/icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.painting)
-- Util.GetGameObject(_go.transform, "card/pos/icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon)
Util.GetGameObject(_go.transform, "card/pro/Image"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
Util.GetGameObject(_go.transform, "card/heroStage"):GetComponent("Image").sprite = Util.LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage])
local redPoint = Util.GetGameObject(_go.transform, "card/redAndLock/redPoint")
Util.GetGameObject(_go.transform, "card/redAndLock/lockImage"):SetActive(heroData.lockState == 1)
local starGrid = Util.GetGameObject(_go.transform, "star")
local starPre = Util.GetGameObject(_go.transform, "starPre")
--Util.ClearChild(starGrid.transform)
SetHeroStars(starGrid, heroData.star,1,Vector2(32.5,32.5),-10)
--local cardBtn = Util.GetGameObject(_go.transform, "card(Clone)")
SoulPrintManager.UnLockSoulPrintPos(heroData)
local soulPrintIsOpen = table.nums(SoulPrintManager.hasUnlockPos)>=1
if teamHero[heroData.dynamicId]~=nil then
Util.GetGameObject(_go.transform, "card/choosed"):SetActive(true)
local isCanShowSoulPrintPoint = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. heroData.dynamicId)
soulPrintData = SoulPrintManager.GetSoulPrintAndSort(SoulPrintManager.soulPrintData)
redPoint:SetActive(HeroManager.GetCurHeroIsShowRedPoint(heroData))
else
redPoint:SetActive(false)
Util.GetGameObject(_go.transform, "card/choosed"):SetActive(false)
end
--Util.GetGameObject(_go.transform, "card/choosed"):SetActive(teamHero[heroData
-- .dynamicId]~=nil)
Util.AddOnceClick(Util.GetGameObject(_go.transform, "card"), function()
this.OnClickEnterHeroInfo(heroData, HeroManager.heroSortedDatas,teamHero[heroData.dynamicId]~=nil)
end)
end
function this:SetSelectBtn()
this.selectBtn.transform:SetParent(tabs[proId].transform)
this.selectBtn:GetComponent("RectTransform").localPosition = Vector3.zero
end
function this:SortHeroDatas(_heroDatas)
--上阵最优先星级优先同星级等级优先同星级同等级按sortId排序。排序时降序排序。
table.sort(_heroDatas, function(a, b)
if (teamHero[a.dynamicId] and teamHero[b.dynamicId]) or (not teamHero[a.dynamicId] and not teamHero[b.dynamicId]) then
if sortType==SortTypeConst.Lv then
if a.lv ==b.lv then
if a.heroConfig.Quality ==b.heroConfig.Quality then--Natural
if a.star == b.star then
if a.warPower == b.warPower then
if a.heroConfig.Natural ==b.heroConfig.Natural then--Natural
return a.heroConfig.Id < b.heroConfig.Id
else
return a.heroConfig.Natural > b.heroConfig.Natural
end
else
return a.warPower > b.warPower
end
else
return a.star > b.star
end
else
return a.heroConfig.Quality > b.heroConfig.Quality
end
else
return a.lv>b.lv
end
elseif sortType==SortTypeConst.Natural then
if a.heroConfig.Quality ==b.heroConfig.Quality then--Natural
if a.star == b.star then
if a.lv == b.lv then
if a.warPower == b.warPower then
if a.heroConfig.Natural ==b.heroConfig.Natural then--Natural
return a.heroConfig.Id < b.heroConfig.Id
else
return a.heroConfig.Natural > b.heroConfig.Natural
end
else
return a.warPower > b.warPower
end
else
return a.lv > b.lv
end
else
return a.star > b.star
end
else
return a.heroConfig.Quality > b.heroConfig.Quality
end
end
else
return teamHero[a.dynamicId] and not teamHero[b.dynamicId]
end
end)
end
function this.OnClickEnterHeroInfo(_curhero, _heros,isUpZhen)
UIManager.OpenPanel(UIName.RoleInfoPanel, _curhero, _heros,isUpZhen)
end
function this.GetRoleItemByName(name)
local targetItem
this.ScrollView:ForeachItemGO(function (index, go)
local itemName = Util.GetGameObject(go.transform, "card/name"):GetComponent("Text").text
if Util.GetGameObject(go.transform, "card/choosed").activeInHierarchy then
if not targetItem and name == itemName then
targetItem = go
return
end
end
if not targetItem and name == itemName then
targetItem = go
end
end)
return targetItem
end
--界面关闭时调用(用于子类重写)
function RoleListPanel:OnClose()
proId=0--面板关闭时 重置筛选按钮为全部
if isFristOpenTime then
isFristOpenTime:Stop()
isFristOpenTime = nil
end
end
--界面销毁时调用(用于子类重写)
function RoleListPanel:OnDestroy()
SubUIManager.Close(this.UpView)
SubUIManager.Close(this.BtView)
ClearRedPointObject(RedPointType.Setting, this.headRedpot)
ClearRedPointObject(RedPointType.VipPrivilege, this.vipRedPoint)
this.ScrollView = nil
end
return RoleListPanel