2020-09-25 10:45:43 +08:00
|
|
|
|
----- 献祭 -----
|
|
|
|
|
|
local this = {}
|
|
|
|
|
|
local sortingOrder=0
|
|
|
|
|
|
local tabSortType = 0
|
|
|
|
|
|
local tarHero
|
|
|
|
|
|
local selectHeroData={}--选择的英雄list did = data
|
|
|
|
|
|
local maxSelectNum = 30--最大选择数量
|
|
|
|
|
|
--选择碎片的数量
|
|
|
|
|
|
local selectChipNum = 0
|
2020-10-23 08:54:49 +08:00
|
|
|
|
--显示的灵兽及碎片数据
|
|
|
|
|
|
local heroDatas={}
|
2020-09-29 15:13:06 +08:00
|
|
|
|
local oldChoosed=nil--上一个选中英雄
|
|
|
|
|
|
--选择的碎片id
|
|
|
|
|
|
local selectChipId=0
|
2020-09-25 10:45:43 +08:00
|
|
|
|
--碎片最大数量
|
|
|
|
|
|
local maxChipNum =0
|
|
|
|
|
|
--是否为灵兽/灵兽碎片
|
2020-10-23 08:54:49 +08:00
|
|
|
|
local isPokemon = false
|
2020-09-25 10:45:43 +08:00
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
|
|
--上部内容
|
|
|
|
|
|
this.helpBtn=Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/HelpBtn")
|
|
|
|
|
|
this.helpPos=this.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
|
--回溯按钮
|
|
|
|
|
|
this.confirmBtn=Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/ConfirmBtn")
|
|
|
|
|
|
Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/ConfirmBtn/Image"):GetComponent("Image").sprite=Util.LoadSprite("lingshou_fangshenganniu")
|
|
|
|
|
|
this.shopBtn=Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/shopBtn")
|
|
|
|
|
|
this.selectText = Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/selectNumText"):GetComponent("Text")
|
|
|
|
|
|
this.selectBtn = Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/btns/selectBtn")
|
2020-10-15 19:27:41 +08:00
|
|
|
|
this.cardPre = Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/equipTreasurePre")
|
2020-09-25 10:45:43 +08:00
|
|
|
|
this.scrollbar = Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/Scrollbar"):GetComponent("Scrollbar")
|
|
|
|
|
|
this.Empty = Util.GetGameObject(gameObject,"Content/Resolve_Pokemon/Empty")
|
|
|
|
|
|
local v21 = Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/ItemListRoot"):GetComponent("RectTransform").rect
|
|
|
|
|
|
Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/Empty/Bg/Text"):GetComponent("Text").text=Language[12393]
|
|
|
|
|
|
this.chipObj=Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/chipObj")
|
|
|
|
|
|
this.btn_remove=Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/chipObj/btn_remove")
|
|
|
|
|
|
this.btn_add=Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/chipObj/btn_add")
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.chipNumTxt=Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/chipObj/Text"):GetComponent("Text")
|
2020-09-25 10:45:43 +08:00
|
|
|
|
|
2020-10-21 15:41:11 +08:00
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "Content/Resolve_Pokemon/ItemListRoot").transform,
|
2020-09-25 10:45:43 +08:00
|
|
|
|
this.cardPre, this.scrollbar, Vector2.New(v21.width, v21.height), 1, 5, Vector2.New(43,15))
|
|
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
|
this.ScrollView.moveTween.Strength = 1
|
|
|
|
|
|
maxSelectNum = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,54).Value)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
|
--减少按钮
|
|
|
|
|
|
Util.AddClick(this.btn_remove,function()
|
|
|
|
|
|
if selectChipNum==1 then
|
|
|
|
|
|
--减少按钮置灰
|
2020-09-29 15:13:06 +08:00
|
|
|
|
Util.SetGray(this.btn_remove,true)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
if selectChipNum== maxChipNum-1 then
|
|
|
|
|
|
--取消增加按钮置灰
|
2020-09-29 15:13:06 +08:00
|
|
|
|
Util.SetGray(this.btn_add,false)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
selectChipNum=selectChipNum-1
|
|
|
|
|
|
this.chipNumTxt=selectChipNum
|
|
|
|
|
|
end
|
|
|
|
|
|
)
|
|
|
|
|
|
--增加按钮
|
|
|
|
|
|
Util.AddClick(this.btn_add,function()
|
|
|
|
|
|
if selectChipNum==maxChipNum then
|
|
|
|
|
|
--增加按钮置灰
|
2020-09-29 15:13:06 +08:00
|
|
|
|
Util.SetGray(this.btn_add,true)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
if selectChipNum== 2 then
|
|
|
|
|
|
--取消减少按钮置灰
|
2020-09-29 15:13:06 +08:00
|
|
|
|
Util.SetGray(this.btn_remove,false)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
selectChipNum=selectChipNum + 1
|
|
|
|
|
|
this.chipNumTxt=selectChipNum
|
|
|
|
|
|
end
|
|
|
|
|
|
)
|
|
|
|
|
|
Util.AddClick(this.helpBtn,function()
|
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Resolve_Dismantle,this.helpPos.x,this.helpPos.y)
|
|
|
|
|
|
end)
|
|
|
|
|
|
Util.AddClick(this.confirmBtn,function()
|
|
|
|
|
|
if tonumber(LengthOfTable(selectHeroData))==0 then
|
|
|
|
|
|
PopupTipPanel.ShowTip(Language[12394])
|
|
|
|
|
|
else
|
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.ResolveDismantle,
|
2020-10-23 08:54:49 +08:00
|
|
|
|
HeroManager.GetHeroReturnItems(selectHeroData,GENERAL_POPUP_TYPE.ResolveDismantle),selectHeroData,selectChipId,selectChipNum)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.shopBtn, function()
|
|
|
|
|
|
local isActive, errorTip = ShopManager.IsActive(SHOP_TYPE.SOUL_CONTRACT_SHOP)
|
|
|
|
|
|
if not isActive then
|
|
|
|
|
|
PopupTipPanel.ShowTip(errorTip or Language[10528])
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
UIManager.OpenPanel(UIName.MainShopPanel, SHOP_TYPE.SOUL_CONTRACT_SHOP)
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:OnShow(...)
|
|
|
|
|
|
sortingOrder =0
|
|
|
|
|
|
this.SortTypeClick(sortingOrder)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--展示数据
|
|
|
|
|
|
function this.SortTypeClick(_sortType)
|
|
|
|
|
|
tabSortType=_sortType
|
|
|
|
|
|
selectHeroData={}
|
2020-10-21 15:41:11 +08:00
|
|
|
|
--所有灵兽数据
|
|
|
|
|
|
|
|
|
|
|
|
local heros=PokemonManager.GetPokemonDatas()
|
|
|
|
|
|
if heros then
|
|
|
|
|
|
for i, v in pairs(heros) do
|
|
|
|
|
|
local hero={}
|
|
|
|
|
|
local heroConfig=v.config
|
|
|
|
|
|
hero.star=v.star
|
|
|
|
|
|
hero.lv=v.lv
|
|
|
|
|
|
hero.dynamicId=v.dynamicId
|
2020-10-23 08:54:49 +08:00
|
|
|
|
hero.ischip=0
|
2020-10-21 15:41:11 +08:00
|
|
|
|
hero.icon=heroConfig.Icon
|
|
|
|
|
|
hero.id=v.id
|
|
|
|
|
|
hero.quality=heroConfig.Quality
|
|
|
|
|
|
hero.name=heroConfig.Name
|
|
|
|
|
|
hero.returnCoin=heroConfig.CoinReturn
|
2020-10-23 08:54:49 +08:00
|
|
|
|
hero.frame=GetHeroQuantityImageByquality(heroConfig.Quality,1)
|
2020-10-21 15:41:11 +08:00
|
|
|
|
hero.num=1
|
|
|
|
|
|
table.insert(heroDatas,hero)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--所有灵兽碎片
|
2020-10-23 08:54:49 +08:00
|
|
|
|
local chips=BagManager.GetDataByItemType(22)
|
2020-10-21 15:41:11 +08:00
|
|
|
|
if chips then
|
|
|
|
|
|
for i, v in pairs(chips) do
|
|
|
|
|
|
local chip={}
|
|
|
|
|
|
chip.star=0
|
|
|
|
|
|
chip.lv=0
|
|
|
|
|
|
chip.ischip=1
|
|
|
|
|
|
chip.frame=v.frame
|
|
|
|
|
|
chip.icon=v.icon
|
|
|
|
|
|
chip.id=v.id
|
|
|
|
|
|
chip.quality=v.quality
|
|
|
|
|
|
chip.num=v.num
|
|
|
|
|
|
chip.name=v.name
|
|
|
|
|
|
chip.returnCoin=0
|
2020-10-23 08:54:49 +08:00
|
|
|
|
chip.dynamicId=v.id
|
2020-10-21 15:41:11 +08:00
|
|
|
|
table.insert(heroDatas,chip)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.chipObj:SetActive(false)
|
|
|
|
|
|
this.selectText.gameObject:SetActive(true)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
this.selectText.text = Language[11775].."0/"..maxSelectNum
|
2020-10-21 15:41:11 +08:00
|
|
|
|
-- this.SortHeroDatas(heroDatas)
|
|
|
|
|
|
this.Empty:SetActive(#heroDatas <= 0)
|
|
|
|
|
|
this.ScrollView:SetData(heroDatas, function (index, go)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.SingleHeroDataShow(go, heroDatas[index],false)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end)
|
|
|
|
|
|
this.ScrollView:ForeachItemGO(function(index, go)
|
|
|
|
|
|
Timer.New(function()
|
|
|
|
|
|
go.gameObject:SetActive(true)
|
|
|
|
|
|
PlayUIAnim(go.gameObject)
|
|
|
|
|
|
end, 0.001 * (index - 1)):Start()
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--英雄单个数据展示
|
2020-10-23 08:54:49 +08:00
|
|
|
|
function this.SingleHeroDataShow(go,_heroData,isGray)
|
2020-09-25 10:45:43 +08:00
|
|
|
|
local heroData = _heroData
|
|
|
|
|
|
local _go = go
|
2020-10-21 15:41:11 +08:00
|
|
|
|
Util.GetGameObject(_go.transform, "frame"):GetComponent("Image").sprite = Util.LoadSprite(heroData.frame)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
if heroData.ischip==1 then
|
|
|
|
|
|
Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = heroData.num
|
|
|
|
|
|
else
|
|
|
|
|
|
Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = heroData.lv
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-10-21 15:41:11 +08:00
|
|
|
|
Util.GetGameObject(_go.transform, "Text"):GetComponent("Text").text = heroData.name
|
|
|
|
|
|
Util.GetGameObject(_go.transform, "icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.icon)
|
2020-10-15 19:27:41 +08:00
|
|
|
|
local chipImg=Util.GetGameObject(_go.transform, "chipImg"):GetComponent("Image")
|
2020-10-23 08:54:49 +08:00
|
|
|
|
local formationMask =Util.GetGameObject(_go.transform, "mask")
|
2020-10-21 15:41:11 +08:00
|
|
|
|
if heroData.ischip==1 then
|
2020-10-15 19:27:41 +08:00
|
|
|
|
chipImg.gameObject:SetActive(true)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
formationMask:SetActive(isGray)
|
2020-10-21 15:41:11 +08:00
|
|
|
|
chipImg.sprite=Util.LoadSprite(GetHeroChipQuantityImageByquality(heroData.quality))
|
2020-10-15 19:27:41 +08:00
|
|
|
|
else
|
|
|
|
|
|
chipImg.gameObject:SetActive(false)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
formationMask:SetActive(false)
|
2020-10-15 19:27:41 +08:00
|
|
|
|
end
|
2020-09-25 10:45:43 +08:00
|
|
|
|
local starGrid = Util.GetGameObject(_go.transform, "star")
|
|
|
|
|
|
SetHeroStars(starGrid, heroData.star,1,Vector2.New(32.5,32.5),-15)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
local choosed =Util.GetGameObject(_go.transform, "choosed")
|
2020-09-29 15:13:06 +08:00
|
|
|
|
if heroData.ischip then
|
2020-10-21 15:41:11 +08:00
|
|
|
|
choosed:SetActive(selectChipId==heroData.dynamicId)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
else
|
|
|
|
|
|
choosed:SetActive(selectHeroData[heroData.dynamicId] ~= nil)
|
|
|
|
|
|
end
|
2020-09-25 10:45:43 +08:00
|
|
|
|
local cardclickBtn = Util.GetGameObject(_go.transform, "icon")
|
|
|
|
|
|
this.selectText.text = Language[11775]..LengthOfTable(selectHeroData).."/"..maxSelectNum
|
|
|
|
|
|
Util.AddOnceClick(cardclickBtn, function()
|
|
|
|
|
|
--如果点击的是碎片
|
2020-10-23 08:54:49 +08:00
|
|
|
|
if heroData.ischip==1 then
|
2020-09-29 15:13:06 +08:00
|
|
|
|
--第一个选中的碎片
|
|
|
|
|
|
if oldChoosed==nil then
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.selectText.gameObject:SetActive(false)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
this.chipObj:SetActive(true)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
choosed:SetActive(true)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
oldChoosed=choosed
|
|
|
|
|
|
else
|
|
|
|
|
|
--如果选中之前选中的,就取消选中
|
|
|
|
|
|
if oldChoosed==choosed then
|
|
|
|
|
|
oldChoosed=nil
|
|
|
|
|
|
selectChipId=0
|
|
|
|
|
|
choosed:SetActive(false)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.selectText.gameObject:SetActive(true)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
this.selectText.text = Language[11775].."0".."/"..maxSelectNum
|
|
|
|
|
|
this.chipObj:SetActive(false)
|
|
|
|
|
|
return
|
|
|
|
|
|
else
|
|
|
|
|
|
oldChoosed:SetActive(false)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
choosed:SetActive(true)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
oldChoosed=choosed
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
selectChipId=heroData.dynamicId
|
|
|
|
|
|
Util.SetGray(this.btn_add,true)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
selectChipNum=heroData.num
|
|
|
|
|
|
maxChipNum=heroData.num
|
2020-09-25 10:45:43 +08:00
|
|
|
|
this.chipNumTxt.text=selectChipNum
|
|
|
|
|
|
isPokemon=false
|
|
|
|
|
|
--点击的是灵兽
|
|
|
|
|
|
else
|
2020-09-29 15:13:06 +08:00
|
|
|
|
--如果灵兽是选中状态,取消选中
|
|
|
|
|
|
if selectHeroData[heroData.dynamicId] then
|
|
|
|
|
|
choosed:SetActive(false)
|
2020-10-23 08:54:49 +08:00
|
|
|
|
if oldChoosed then
|
|
|
|
|
|
oldChoosed:SetActive(false)
|
|
|
|
|
|
end
|
|
|
|
|
|
selectChipId=0
|
2020-09-29 15:13:06 +08:00
|
|
|
|
selectHeroData[heroData.dynamicId] = nil
|
|
|
|
|
|
local haveNum=LengthOfTable(selectHeroData)
|
|
|
|
|
|
this.selectText.text = Language[11775]..haveNum.."/"..maxSelectNum
|
|
|
|
|
|
if haveNum==0 then
|
|
|
|
|
|
-- --todo 取消所有碎片置灰
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.ScrollView:SetData(heroDatas, function (index, go)
|
|
|
|
|
|
this.SingleHeroDataShow(go, heroDatas[index],false)
|
|
|
|
|
|
end)
|
|
|
|
|
|
isPokemon=false
|
2020-09-29 15:13:06 +08:00
|
|
|
|
end
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
--如果选中灵兽的数量为最大
|
|
|
|
|
|
if LengthOfTable(selectHeroData)==maxSelectNum then
|
2020-09-25 10:45:43 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[12396],maxSelectNum))
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
2020-09-29 15:13:06 +08:00
|
|
|
|
if isPokemon==false then
|
|
|
|
|
|
--todo 首次点击灵兽,置灰所有碎片
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.ScrollView:SetData(heroDatas, function (index, go)
|
|
|
|
|
|
this.SingleHeroDataShow(go, heroDatas[index],true)
|
|
|
|
|
|
end)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
selectChipId=0
|
2020-10-23 08:54:49 +08:00
|
|
|
|
this.selectText.gameObject:SetActive(true)
|
2020-09-29 15:13:06 +08:00
|
|
|
|
this.chipObj:SetActive(false)
|
|
|
|
|
|
isPokemon = true
|
|
|
|
|
|
end
|
2020-09-25 10:45:43 +08:00
|
|
|
|
selectHeroData[heroData.dynamicId]=heroData
|
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
|
this.selectText.text = Language[11775]..LengthOfTable(selectHeroData).."/"..maxSelectNum
|
2020-09-29 15:13:06 +08:00
|
|
|
|
end
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
--灰色遮罩点击
|
|
|
|
|
|
Util.AddOnceClick(formationMask, function()
|
|
|
|
|
|
PopupTipPanel.ShowTip(Language[12395])
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
--英雄排序
|
|
|
|
|
|
function this.SortHeroDatas(_heroDatas)
|
|
|
|
|
|
--上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。
|
|
|
|
|
|
table.sort(_heroDatas, function(a, b)
|
|
|
|
|
|
if a ==nil or b == nil then
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
2020-10-21 15:41:11 +08:00
|
|
|
|
if a.quality ==b.quality then
|
|
|
|
|
|
if a.star == b.star then
|
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
|
return a.id > b.id
|
2020-09-25 10:45:43 +08:00
|
|
|
|
else
|
2020-10-21 15:41:11 +08:00
|
|
|
|
return a.lv < b.lv
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
else
|
2020-10-21 15:41:11 +08:00
|
|
|
|
return a.star < b.star
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
else
|
2020-10-21 15:41:11 +08:00
|
|
|
|
return a.quality < b.quality
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end
|
2020-10-21 15:41:11 +08:00
|
|
|
|
|
2020-09-25 10:45:43 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return this
|