miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_XiuXingSele...

163 lines
6.1 KiB
Lua

----- 修行选择英雄弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local func
local data
function this:InitComponent(gameObject)
self.spLoader = SpriteLoader.New()
self.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
self.tip=Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
self.scroll = Util.GetGameObject(gameObject, "Scroll")
self.confirm = Util.GetGameObject(gameObject, "ConfirmBtn")
self.cancel = Util.GetGameObject(gameObject, "CancelBtn")
self.itemPre = Util.GetGameObject(gameObject, "itemPre")
self.mask = Util.GetGameObject(gameObject, "itemPre/item")
-- 设置循环滚动,万一内容不停地加
local rootHight = self.scroll.transform.rect.height
local width = self.scroll.transform.rect.width
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scroll.transform,
self.itemPre, nil, Vector2.New(width, rootHight), 1, 5, Vector2.New(20, 35))
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
self.heroList={}
self.itemList = {}
self.maskList = {}--对勾的list
self.maskImprintList = {}--附身中的list
end
function this:BindEvent()
Util.AddClick(this.confirm,function()
--检测该英雄已附身神印
if self.heroD==nil then
return
end
if PracticeManager.CheckHeroWearImprint(self.heroD.dynamicId) then
MsgPanel.ShowTwo("该英雄已附身其他神印,是否替换?", nil, function()
parent:ClosePanel()
if func then
func(self.heroD)
end
end)
else
parent:ClosePanel()
if func then
func(self.heroD)
end
end
end)
Util.AddClick(this.cancel,function()
parent:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,_Data)
parent=_parent
sortingOrder = _parent.sortingOrder
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
local _args = _Data
data = _args[1]
func = _args[2]
self.heroList = HeroManager.GetHeroDataByPropertyAndProfession(data.FitList[1],data.FitList[2],1)
table.sort(self.heroList,function (a,b)
return a.warPower > b.warPower
end)
this:Refresh(true,true)
end
function this:Refresh(isTop,isAni)
this.titleText.text = "神印附身"
if not self.itemList then
self.itemList = {}
end
for i = 1, #self.itemList do
self.itemList[i].gameObject:SetActive(false)
end
-- LogRed("#self.heroList:"..tostring(#self.heroList))
self.scrollView:SetData(self.heroList, function (index, item)
this:ShowSingleData(item, self.heroList[index],index)
end,not isTop,not isAni)
if #self.heroList ~= 0 then
this.tip.text = "请选择您要附身的英雄"
self.tip.gameObject:GetComponent("RectTransform").localPosition = Vector3.New(0,500,0)
else
self.tip.text = "暂无可附身的英雄"
self.tip.gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
end
end
function this:ShowSingleData(go,heroData,index)
self.itemList[index] = go
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(heroData.icon)
Util.GetGameObject(go, "lv/Text"):GetComponent("Text").text = heroData.lv
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(heroData.icon)
Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
local starGrid = Util.GetGameObject(go, "star")
local starPre = Util.GetGameObject(go, "starPre")
self.maskList[index] = Util.GetGameObject(go, "choosed")
self.maskList[index]:SetActive(tostring(PracticeManager.ImprintServerData[data.Id].subId) == tostring(heroData.dynamicId))
self.maskImprintList[index] = {}
self.maskImprintList[index].heroDid = heroData.dynamicId
self.maskImprintList[index].obj = Util.GetGameObject(go, "imprint")
if self.maskList[index].activeInHierarchy then
self.maskImprintList[index].obj:SetActive(false)
else
self.maskImprintList[index].obj:SetActive(PracticeManager.CheckHeroHaveImprintAndActive(heroData.dynamicId))
end
local star,starType = heroData.GetStar(1)
SetHeroStars(self.spLoader, starGrid, star,starType)
SetHeroFlyEffect(Util.GetGameObject(go, "GameObject"),self.spLoader,heroData.star,sortingOrder + 1,1,3 ,0,true)
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
Util.SetParticleSortLayer(starGrid,sortingOrder + 1)
Util.AddOnceClick(go, function()
for i = 1, #self.maskList do
self.maskList[i]:SetActive(false)
end
for i = 1, #self.maskImprintList do
self.maskImprintList[i].obj:SetActive(PracticeManager.CheckHeroHaveImprintAndActive(self.maskImprintList[i].heroDid))
end
if self.maskImprintList[index].obj.activeInHierarchy then
self.maskImprintList[index].obj:SetActive(false)
end
self.maskList[index]:SetActive(true)
self.heroD = heroData
end)
Util.AddLongPressClick(go, function()
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
end, 0.5)
end
function this:OnClose()
self.selectId = nil
self.heroList={}
self.maskList = {}
self.maskImprintList = {}
end
function this:OnDestroy()
self.spLoader:Destroy()
self.itemList = {}
end
return this