193 lines
7.2 KiB
Lua
193 lines
7.2 KiB
Lua
require("Base/BasePanel")
|
|
IncarnationUpStarListPanel = Inherit(BasePanel)
|
|
local this = IncarnationUpStarListPanel
|
|
local curSelectHeroList={}
|
|
local heroDataList={}
|
|
local curNeedRoleNum
|
|
local openThisPanel
|
|
local curHeroData = {}
|
|
local needQuality
|
|
--初始化组件(用于子类重写)
|
|
function this:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.BtnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
|
Util.GetGameObject(self.gameObject, "bg/Text"):GetComponent("Text").text="奥义卡选择"
|
|
this.mask = Util.GetGameObject(self.gameObject, "mask")
|
|
this.BtnSure = Util.GetGameObject(self.gameObject, "btnSure")
|
|
this.btnAutoSelect = Util.GetGameObject(self.gameObject, "btnAutoSelect")
|
|
this.cardPre = Util.GetGameObject(self.gameObject, "item")
|
|
this.desText = Util.GetGameObject(self.gameObject, "desText"):GetComponent("Text")
|
|
this.numText = Util.GetGameObject(self.gameObject, "numText"):GetComponent("Text")
|
|
|
|
local v = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect
|
|
this.Scrollbar= Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,Util.GetGameObject(self.gameObject, "scroll").transform,
|
|
this.cardPre, this.Scrollbar, Vector2.New(v.width, v.height), 1, 5, Vector2.New(19.32,40))
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(6.78, 27)
|
|
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.moveTween.MomentumAmount = 1
|
|
this.ScrollView.moveTween.Strength = 1
|
|
|
|
this.NoneImage= Util.GetGameObject(self.gameObject, "NoneImage")
|
|
this.NoneImage.gameObject:SetActive(false)
|
|
Util.GetGameObject(self.gameObject, "NoneImage/TextImage/Text"):GetComponent("Text").text="无符合要求的奥义卡!"
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function this:BindEvent()
|
|
|
|
Util.AddClick(this.BtnBack, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.mask, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.BtnSure, function()
|
|
self:ClosePanel()
|
|
openThisPanel:UpdateUpStarCost(this.GetSelectNum(),curSelectHeroList)
|
|
end)
|
|
Util.AddClick(this.btnAutoSelect, function()
|
|
self:AutoSelectHero()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function this:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function this:RemoveListener()
|
|
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function this:OnOpen(_openThisPanel,_curSelectHeroList,_needInfo,curCardId)
|
|
openThisPanel= _openThisPanel
|
|
curSelectHeroList={}
|
|
--LogError("curCardId=="..curCardId)
|
|
print(#_curSelectHeroList)
|
|
for i = 1, #_curSelectHeroList do
|
|
table.insert(curSelectHeroList,_curSelectHeroList[i])
|
|
end
|
|
|
|
needQuality=_needInfo[1]
|
|
curNeedRoleNum=_needInfo[2]
|
|
heroDataList={}
|
|
local allItemList= BagManager.GetBagAllDataByItemType(29)
|
|
for i, v in pairs(allItemList) do
|
|
--LogError("v.id=="..v.id)
|
|
if v.num>0 and v.id==curCardId then
|
|
--LogError("v.id=="..v.id)
|
|
table.insert(heroDataList,v)
|
|
end
|
|
end
|
|
--LogError("len====="..#heroDataList)
|
|
if not heroDataList or #heroDataList < 1 then
|
|
this.NoneImage.gameObject:SetActive(true)
|
|
else
|
|
this.NoneImage.gameObject:SetActive(false)
|
|
end
|
|
|
|
this.ScrollView:SetData(heroDataList, function (index, go)
|
|
this.OnShowSingleCardData(go, heroDataList[index])
|
|
end,false,false)
|
|
|
|
this.desText.text=string.format(Language[10402],curNeedRoleNum,"奥义卡")
|
|
this.numText.text=string.format("%s/%s",this.GetSelectNum(),curNeedRoleNum)
|
|
end
|
|
|
|
function this.OnShowSingleCardData(go,heroData)--isSelect 1选择 2 没选择
|
|
local choosed = Util.GetGameObject(go.transform, "choosed")
|
|
choosed:SetActive(false)
|
|
for i = 1, #curSelectHeroList do
|
|
if curSelectHeroList[i].id == heroData.id then
|
|
choosed:SetActive(true)
|
|
end
|
|
end
|
|
local frame = Util.GetGameObject(go.transform, "frame"):GetComponent("Image")
|
|
local icon = Util.GetGameObject(go.transform, "icon"):GetComponent("Image")
|
|
local num = Util.GetGameObject(go.transform, "num"):GetComponent("Text")
|
|
local proIcon = Util.GetGameObject(go.transform, "proIcon"):GetComponent("Image")
|
|
local name = Util.GetGameObject(go.transform, "name"):GetComponent("Text")
|
|
local cardBtn = Util.GetGameObject(go.transform, "icon")
|
|
frame.sprite = this.spLoader:LoadSprite(heroData.frame)
|
|
icon.sprite = this.spLoader:LoadSprite(heroData.icon)
|
|
num.text = heroData.num
|
|
proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.itemConfig.val[9]))--9是阵营id
|
|
name.text =string.gsub(heroData.name, "变身", "")
|
|
Util.AddOnceClick(cardBtn, function()
|
|
local isSelect = false
|
|
local selectIndex = 0
|
|
for i = 1, #curSelectHeroList do
|
|
if curSelectHeroList[i].id == heroData.id then
|
|
isSelect = true
|
|
selectIndex = i
|
|
choosed:SetActive(true)
|
|
end
|
|
end
|
|
if isSelect then
|
|
choosed:SetActive(false)
|
|
table.remove(curSelectHeroList,selectIndex)
|
|
this.numText.text=string.format("%s/%s",this.GetSelectNum(),curNeedRoleNum)
|
|
return
|
|
end
|
|
|
|
if this.GetSelectNum()>=curNeedRoleNum then
|
|
PopupTipPanel.ShowTip(Language[10403])
|
|
return
|
|
end
|
|
|
|
local signData={}
|
|
signData.id=heroData.id
|
|
local residueNum=curNeedRoleNum-this.GetSelectNum()--剩余可选择数量
|
|
signData.num=heroData.num>=residueNum and residueNum or heroData.num
|
|
table.insert(curSelectHeroList,signData)
|
|
choosed:SetActive(true)
|
|
this.numText.text=string.format("%s/%s",this.GetSelectNum(),curNeedRoleNum)
|
|
end)
|
|
end
|
|
--获取当前已选择数量
|
|
function this.GetSelectNum()
|
|
local num=0
|
|
for i = 1, #curSelectHeroList do
|
|
num=num+curSelectHeroList[i].num
|
|
end
|
|
return num
|
|
end
|
|
|
|
--一键放入
|
|
function this:AutoSelectHero()
|
|
curSelectHeroList = {}
|
|
for i = 1, #heroDataList do
|
|
if this.GetSelectNum()<curNeedRoleNum then
|
|
local signData={}
|
|
signData.id=heroDataList[i].id
|
|
local residueNum=curNeedRoleNum-this.GetSelectNum()--剩余可选择数量
|
|
signData.num=heroDataList[i].num>=residueNum and residueNum or heroDataList[i].num
|
|
table.insert(curSelectHeroList,signData)
|
|
end
|
|
end
|
|
this.numText.text=string.format("%s/%s",this.GetSelectNum(),curNeedRoleNum)
|
|
this.ScrollView:SetData(heroDataList, function (index, go)
|
|
this.OnShowSingleCardData(go, heroDataList[index])
|
|
end,true,true)
|
|
end
|
|
--界面关闭时调用(用于子类重写)
|
|
function this:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function this:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
|
|
this.ScrollView = nil
|
|
end
|
|
|
|
return this
|
|
|