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

135 lines
4.9 KiB
Lua
Raw Normal View History

2021-05-13 21:03:27 +08:00
----- 修行选择英雄弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local func
local data
function this:InitComponent(gameObject)
self.spLoader = SpriteLoader.New()
2021-05-13 21:03:27 +08:00
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,
2021-05-24 11:53:44 +08:00
self.itemPre, nil, Vector2.New(width, rootHight), 1, 5, Vector2.New(20, 35))
2021-05-13 21:03:27 +08:00
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
self.heroList={}
self.itemList = {}
self.maskList = {}
end
function this:BindEvent()
Util.AddClick(this.confirm,function()
2021-05-18 21:00:38 +08:00
--检测该英雄已附身神印
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
2021-05-13 21:03:27 +08:00
end
end)
Util.AddClick(this.cancel,function()
parent:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder = _parent.sortingOrder
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
local _args = {...}
data = _args[1]
func = _args[2]
2021-05-14 13:21:38 +08:00
self.heroList = HeroManager.GetHeroDataByPropertyAndProfession(data.FitList[1],data.FitList[2],5)
table.sort(self.heroList,function (a,b)
return a.warPower > b.warPower
end)
2021-05-13 21:03:27 +08:00
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
2021-05-14 14:54:57 +08:00
-- LogRed("#self.heroList:"..tostring(#self.heroList))
2021-05-13 21:03:27 +08:00
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)
2021-05-13 21:03:27 +08:00
else
self.tip.text = "暂无可附身的神将"
self.tip.gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
end
end
2021-05-14 13:21:38 +08:00
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)
2021-05-14 13:21:38 +08:00
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.heroConfig.PropertyName))
2021-05-14 13:21:38 +08:00
local starGrid = Util.GetGameObject(go, "star")
local starPre = Util.GetGameObject(go, "starPre")
self.maskList[index] = Util.GetGameObject(go, "choosed")
2021-05-14 14:54:57 +08:00
-- LogGreen("data.UnlockId:"..tostring(data.UnlockId))
2021-05-14 13:21:38 +08:00
self.maskList[index]:SetActive(tostring(PracticeManager.ImprintServerData[data.Id].subId) == tostring(heroData.dynamicId))
2021-05-24 11:53:44 +08:00
SetHeroStars(self.spLoader,starGrid, heroData.star)
2021-05-13 21:03:27 +08:00
2021-05-14 13:21:38 +08:00
Util.AddOnceClick(go, function()
2021-05-14 14:54:57 +08:00
-- LogGreen("subId:"..tostring(PracticeManager.ImprintServerData[data.Id].subId).." did:"..tostring(heroData.dynamicId))
2021-05-14 13:21:38 +08:00
for i = 1, #self.maskList do
self.maskList[i]:SetActive(false)
2021-05-13 21:03:27 +08:00
end
2021-05-14 13:21:38 +08:00
self.maskList[index]:SetActive(true)
self.heroD = heroData
2021-05-13 21:03:27 +08:00
end)
2021-05-14 13:21:38 +08:00
Util.AddLongPressClick(go, function()
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
end, 0.5)
2021-05-13 21:03:27 +08:00
end
function this:OnClose()
self.selectId = nil
self.heroList={}
self.maskList = {}
end
function this:OnDestroy()
self.spLoader:Destroy()
2021-05-13 21:03:27 +08:00
self.itemList = {}
end
return this