miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/ExpeditionHeroListInfoPopup...

276 lines
12 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
ExpeditionHeroListInfoPopup = Inherit(BasePanel)
local this = ExpeditionHeroListInfoPopup
local sortType = 1 -- 1品阶 2等级
local proId=0--0 全部 1 火 2风 3 水 4 地 5 光 6 暗
local tabs = {}
--初始化组件(用于子类重写)
function ExpeditionHeroListInfoPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.BtnBack = Util.GetGameObject(self.transform, "bg/btnBack")
this.BtnSure = Util.GetGameObject(self.transform, "bg/btnSure")
this.cardPre = Util.GetGameObject(self.gameObject, "item")
2020-06-30 18:59:44 +08:00
this.noOneImage = Util.GetGameObject(self.gameObject, "bg/noOneImage")
this.noOneImageText = Util.GetGameObject(self.gameObject, "bg/noOneImage/talkImage/Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
this.grid = Util.GetGameObject(self.gameObject, "bg/scroll/grid")
2020-06-19 20:19:35 +08:00
for i = 1, 4 do
tabs[i] = Util.GetGameObject(self.transform, "bg/Tabs/grid/Btn" .. i)
2020-05-09 13:31:21 +08:00
end
this.ShaiXuanBtn = Util.GetGameObject(self.gameObject, "bg/ShaiXuanBtn")
this.ShaiXuanBtnLv = Util.GetGameObject(self.gameObject, "bg/ShaiXuanBtn/Lv")
this.ShaiXuanBtnQu = Util.GetGameObject(self.gameObject, "bg/ShaiXuanBtn/Qu")
2020-06-18 20:39:29 +08:00
this.desc = Util.GetGameObject(self.gameObject, "bg/desc"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
this.selectBtn = Util.GetGameObject(self.gameObject, "bg/Tabs/selectBtn")
this.ScrollBar = Util.GetGameObject(self.gameObject, "bg/Scrollbar"):GetComponent("Scrollbar")
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "scroll").transform,
2020-06-19 20:19:35 +08:00
this.cardPre, this.ScrollBar, Vector2.New(927.5, 978.2), 1, 5, Vector2.New(19.32, 40))
2020-05-09 13:31:21 +08:00
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 = 1
this.isHaveInTeam = false
end
--绑定事件(用于子类重写)
function ExpeditionHeroListInfoPopup:BindEvent()
Util.AddClick(this.BtnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(this.BtnSure, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
2020-06-19 20:19:35 +08:00
for i = 1, 4 do
2020-05-09 13:31:21 +08:00
Util.AddClick(tabs[i], function()
if i == proId then
proId=ProIdConst.All
else
proId=i
end
this:OnClickTabBtn(proId)
end)
end
Util.AddClick(this.ShaiXuanBtn, function()
if sortType == SortTypeConst.Lv then
sortType = SortTypeConst.Natural
else
sortType = SortTypeConst.Lv
end
this.ShaiXuanBtnLv:SetActive(sortType ~= SortTypeConst.Lv)
this.ShaiXuanBtnQu:SetActive(sortType ~= SortTypeConst.Natural)
this:OnClickTabBtn(proId)
end)
end
--添加事件监听(用于子类重写)
function ExpeditionHeroListInfoPopup:AddListener()
end
--移除事件监听(用于子类重写)
function ExpeditionHeroListInfoPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ExpeditionHeroListInfoPopup:OnOpen()
sortType = SortTypeConst.Lv
proId = ProIdConst.All
this:OnClickTabBtn(proId)
this.ShaiXuanBtnLv:SetActive(sortType ~= SortTypeConst.Lv)
this.ShaiXuanBtnQu:SetActive(sortType ~= SortTypeConst.Natural)
2021-03-02 16:53:12 +08:00
this.desc.text = Language[10538]
this.noOneImageText.text = Language[10539]
2020-05-09 13:31:21 +08:00
end
--设置英雄列表数据
function this.SetRoleList(_roleDatas)
this:SortHeroDatas(_roleDatas)
this.ScrollView:SetData(_roleDatas, function(index, go)
this.SingleHeroDataShow(go, _roleDatas[index])
end)
end
function this.SingleHeroDataShow(_go, _heroData)
local heroData = _heroData
local go = _go
Util.GetGameObject(go, "choosed"):SetActive(false)
local orderImage= Util.GetGameObject(go, "orderImage")
orderImage:SetActive(false)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality, heroData.star))
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "lv/Text"):GetComponent("Text").text = heroData.lv
2021-04-21 13:12:04 +08:00
--Util.GetGameObject(go, "posIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.professionIcon)
Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
2021-04-21 13:12:04 +08:00
--Util.GetGameObject(go, "heroStage"):GetComponent("Image").sprite = this.spLoader:LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage])
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "heroStage"):SetActive(false)
2020-05-25 19:16:23 +08:00
Util.GetGameObject(go, "yuanImage"):SetActive(heroData.createtype == 1)
2022-01-12 16:41:51 +08:00
--local flyImg=Util.GetGameObject(go, "flyImg"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
--剩余血量 无尽副本才显示
local hpExp = Util.GetGameObject(go, "hpExp")
2020-08-27 22:52:51 +08:00
if not ExpeditionManager.heroInfo[heroData.dynamicId] then
ExpeditionManager.InitHeroHpValue(heroData.dynamicId)
end
2020-05-09 13:31:21 +08:00
local heroHp = ExpeditionManager.heroInfo[heroData.dynamicId].remainHp
local starGrid = Util.GetGameObject(go, "star")
2021-10-26 16:00:31 +08:00
local star,starType = heroData.GetStar(1)
SetHeroStars(this.spLoader, starGrid, star,starType)
2022-01-12 16:41:51 +08:00
local effect=SetHeroFlyEffect(_go,this.spLoader,heroData.star,this.sortingOrder + 1,1,2)
if effect then
local meshs2=effect:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer))
for key, value in pairs(meshs2:ToTable()) do
if value.material.shader.name=="YXZ/Effect/TransparentRim" then
value.material.shader=poolManager:LoadAsset("YXZ_Effect_TransparentRim_1",poolManager.AssetType.Other)
end
end
end
local meshs1=starGrid:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
for key, value in pairs(meshs1:ToTable()) do
local mat=value:GetComponent(typeof(UnityEngine.Renderer))
if mat.material.shader.name=="UI Particles/Additive" then
mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other)
end
end
2021-11-05 10:18:10 +08:00
Util.SetParticleSortLayer(starGrid,this.sortingOrder + 1)
2020-05-09 13:31:21 +08:00
this.SetHeroBlood(hpExp, heroHp, go)
Util.AddOnceClick(go, function()
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
end)
end
2021-11-05 10:18:10 +08:00
function ExpeditionHeroListInfoPopup:OnSortingOrderChange()
this.ScrollView:ForeachItemGO(function(index, go)
Util.SetParticleSortLayer(go,this.sortingOrder + 1 )
end)
end
2020-05-09 13:31:21 +08:00
-- 设置妖灵师血量
function this.SetHeroBlood(hpExp, heroHp, go)
if heroHp then
hpExp:SetActive(true)
hpExp:GetComponent("Slider").value = heroHp
Util.SetGray(go, heroHp <= 0)
else
hpExp:SetActive(false)
end
end
function this.SetSelectBtn()
this.selectBtn:SetActive(proId ~= ProIdConst.All)
if proId ~= ProIdConst.All then
this.selectBtn.transform.localPosition = tabs[proId].transform.localPosition
end
end
--点击页签__根据sortType和职业属性/类型进行排序
function this:OnClickTabBtn(_proId)
local heros
this.SetSelectBtn()
2020-05-25 19:16:23 +08:00
local limitLevel = 20
2020-05-09 13:31:21 +08:00
if _proId == ProIdConst.All then
2020-05-25 19:16:23 +08:00
heros = HeroManager.GetAllHeroDatas(limitLevel)
heros = ExpeditionManager.GetAllHeroDatas(heros,limitLevel)
2020-05-09 13:31:21 +08:00
else
2020-05-25 19:16:23 +08:00
heros = HeroManager.GetHeroDataByProperty(_proId, limitLevel)
heros = ExpeditionManager.GetHeroDataByProperty(heros,_proId, limitLevel)
2020-05-09 13:31:21 +08:00
end
--LogGreen("#heros "..#heros)
2020-06-30 18:59:44 +08:00
this.noOneImage:SetActive(#heros<=0)
2020-05-09 13:31:21 +08:00
this.SetRoleList(heros)
end
function this:SortHeroDatas(_heroDatas)
local dieHeros = {}
for i = 1, #_heroDatas do
local heroHp = 0
if ExpeditionManager.heroInfo[_heroDatas[i].dynamicId] then
heroHp = ExpeditionManager.heroInfo[_heroDatas[i].dynamicId].remainHp
if heroHp <= 0 then
dieHeros[_heroDatas[i].dynamicId] = _heroDatas[i].dynamicId
end
end
end
table.sort(_heroDatas, function(a, b)
if (dieHeros[a.dynamicId] and dieHeros[b.dynamicId]) or
(not dieHeros[a.dynamicId] and not dieHeros[b.dynamicId])
then
if sortType == SortTypeConst.Natural then
if a.heroConfig.Natural == b.heroConfig.Natural then
if a.heroConfig.Quality == b.heroConfig.Quality then
if a.star == b.star then
if a.lv == b.lv then
2020-07-31 14:45:32 +08:00
if a.warPower == b.warPower then
if a.id == b.id then
return a.sortId > b.sortId
else
return a.id > b.id
end
2020-05-09 13:31:21 +08:00
else
2020-07-31 14:45:32 +08:00
return a.warPower > b.warPower
2020-05-09 13:31:21 +08:00
end
else
return a.lv > b.lv
end
else
return a.star > b.star
end
else
return a.heroConfig.Quality > b.heroConfig.Quality
end
else
return a.heroConfig.Natural > b.heroConfig.Natural
end
else
if a.lv == b.lv then
if a.heroConfig.Quality == b.heroConfig.Quality then
if a.star == b.star then
if a.heroConfig.Natural == b.heroConfig.Natural then
2020-07-31 14:45:32 +08:00
if a.warPower == b.warPower then
if a.id == b.id then
return a.sortId > b.sortId
else
return a.id > b.id
end
2020-05-09 13:31:21 +08:00
else
2020-07-31 14:45:32 +08:00
return a.warPower > b.warPower
2020-05-09 13:31:21 +08:00
end
else
return a.heroConfig.Natural > b.heroConfig.Natural
end
else
return a.star > b.star
end
else
return a.heroConfig.Quality > b.heroConfig.Quality
end
else
return a.lv > b.lv
end
end
else
return not dieHeros[a.dynamicId] and dieHeros[b.dynamicId]
end
end)
end
--界面关闭时调用(用于子类重写)
function ExpeditionHeroListInfoPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function ExpeditionHeroListInfoPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
this.ScrollView = nil
end
2021-04-21 13:12:04 +08:00
return ExpeditionHeroListInfoPopup