2023-03-28 13:57:59 +08:00
|
|
|
|
----- 献祭 -----
|
|
|
|
|
local this = {}
|
|
|
|
|
local sortingOrder=0
|
|
|
|
|
local tabSortType = 0
|
|
|
|
|
local tarHero
|
|
|
|
|
local selectHeroData={}--选择的英雄list did = data
|
|
|
|
|
local maxSelectNum = 30--最大选择数量
|
|
|
|
|
--选择碎片的数量
|
|
|
|
|
local selectChipNum = 0
|
|
|
|
|
--显示的灵兽及碎片数据
|
|
|
|
|
local heroDatas={}
|
|
|
|
|
local oldChoosed=nil--上一个选中英雄
|
|
|
|
|
--选择的碎片id
|
|
|
|
|
local selectChipId=0
|
|
|
|
|
--碎片最大数量
|
|
|
|
|
local maxChipNum =0
|
|
|
|
|
--是否为灵兽/灵兽碎片
|
|
|
|
|
local isPokemon = false
|
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
|
this.spLoader = SpriteLoader.New()
|
|
|
|
|
--上部内容
|
|
|
|
|
this.helpBtn=Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/HelpBtn")
|
|
|
|
|
this.helpPos=this.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
--回溯按钮
|
|
|
|
|
this.confirmBtn=Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/ConfirmBtn")
|
2023-09-28 17:05:40 +08:00
|
|
|
|
Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/ConfirmBtn/Image"):GetComponent("Image").sprite=this.spLoader:LoadSprite("UI_hz_ls_03")
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.shopBtn=Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/shopBtn")
|
|
|
|
|
this.selectText = Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/selectNumText"):GetComponent("Text")
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectNumDes = Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/selectNumDes"):GetComponent("Text")
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.selectBtn = Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/btns/selectBtn")
|
|
|
|
|
this.cardPre = Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/equipTreasurePre")
|
|
|
|
|
this.scrollbar = Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/Scrollbar"):GetComponent("Scrollbar")
|
|
|
|
|
this.Empty = Util.GetGameObject(gameObject,"Content/Resolve_GodWeapon/Empty")
|
|
|
|
|
local v21 = Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/ItemListRoot"):GetComponent("RectTransform").rect
|
2024-01-16 17:02:06 +08:00
|
|
|
|
Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/Empty/Bg/Text"):GetComponent("Text").text="无可分解名刀"
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.chipObj=Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/chipObj")
|
|
|
|
|
this.btn_remove=Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/chipObj/btn_remove")
|
|
|
|
|
this.btn_add=Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/chipObj/btn_add")
|
|
|
|
|
this.chipNumTxt=Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/chipObj/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "Content/Resolve_GodWeapon/ItemListRoot").transform,
|
2024-01-16 17:22:15 +08:00
|
|
|
|
this.cardPre, this.scrollbar, Vector2.New(v21.width, v21.height), 1, 5, Vector2.New(40,15))
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.ScrollView.moveTween.Strength = 1
|
|
|
|
|
maxSelectNum = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,54).Value)
|
|
|
|
|
this.chooseObjList = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
--减少按钮
|
|
|
|
|
Util.AddClick(this.btn_remove,function()
|
|
|
|
|
if selectChipNum==1 then
|
|
|
|
|
--减少按钮置灰
|
|
|
|
|
Util.SetGray(this.btn_remove,true)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if selectChipNum== maxChipNum-1 then
|
|
|
|
|
--取消增加按钮置灰
|
|
|
|
|
Util.SetGray(this.btn_add,false)
|
|
|
|
|
end
|
|
|
|
|
selectChipNum=selectChipNum-1
|
|
|
|
|
this.chipNumTxt.text=selectChipNum
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--增加按钮
|
|
|
|
|
Util.AddClick(this.btn_add,function()
|
|
|
|
|
if selectChipNum==maxChipNum then
|
|
|
|
|
--增加按钮置灰
|
|
|
|
|
Util.SetGray(this.btn_add,true)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if selectChipNum== 2 then
|
|
|
|
|
--取消减少按钮置灰
|
|
|
|
|
Util.SetGray(this.btn_remove,false)
|
|
|
|
|
end
|
|
|
|
|
selectChipNum=selectChipNum + 1
|
|
|
|
|
this.chipNumTxt.text=selectChipNum
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.helpBtn,function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.PokemonResolve,this.helpPos.x,this.helpPos.y)
|
|
|
|
|
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[10574])
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
UIManager.OpenPanel(UIName.MainShopPanel, SHOP_TYPE.SOUL_CONTRACT_SHOP)
|
|
|
|
|
end)
|
|
|
|
|
--放生按钮
|
|
|
|
|
Util.AddClick(this.confirmBtn,function()
|
|
|
|
|
if isPokemon and tonumber(LengthOfTable(selectHeroData))==0 then
|
2024-01-16 17:08:37 +08:00
|
|
|
|
PopupTipPanel.ShowTip("请选择名刀或名刀碎片")
|
2023-03-28 13:57:59 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not isPokemon and (selectChipId==0 or selectChipNum==0) then
|
2024-01-16 17:08:37 +08:00
|
|
|
|
PopupTipPanel.ShowTip("请选择名刀或名刀碎片")
|
2023-03-28 13:57:59 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
--奖励物品
|
2023-04-06 13:40:13 +08:00
|
|
|
|
--所有材料
|
|
|
|
|
local allMaterials={}
|
|
|
|
|
local pokemonIds={}
|
2023-03-28 13:57:59 +08:00
|
|
|
|
--灵兽
|
|
|
|
|
if isPokemon then
|
|
|
|
|
local allCoin=0
|
|
|
|
|
for key, value in pairs(selectHeroData) do
|
|
|
|
|
--升级消耗
|
|
|
|
|
table.insert(pokemonIds,key)
|
2023-04-04 11:15:32 +08:00
|
|
|
|
local lvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Level",value.lv,"Quality",value.quality)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
if lvConfig then
|
|
|
|
|
local matrs=lvConfig.SumConsume
|
|
|
|
|
if matrs then
|
2023-04-04 11:15:32 +08:00
|
|
|
|
for i = 1, #matrs do
|
|
|
|
|
local mat=matrs[i]
|
|
|
|
|
if CheckListIsContainValue2(allMaterials,mat[1]) then
|
|
|
|
|
--allMaterials[mat[1]]=allMaterials[mat[1]]+mat[2]
|
|
|
|
|
|
|
|
|
|
for key, value in pairs(allMaterials) do
|
|
|
|
|
if value[1]==mat[1] then
|
|
|
|
|
value[2]=value[2]+mat[2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
2023-04-06 13:40:13 +08:00
|
|
|
|
if mat[2]>0 then
|
|
|
|
|
table.insert(allMaterials,{mat[1],mat[2]})
|
|
|
|
|
end
|
2023-04-04 11:15:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
2023-03-28 13:57:59 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--升星消耗
|
2023-04-04 11:15:32 +08:00
|
|
|
|
local lingshouConfig=ConfigManager.GetConfigData(ConfigName.ShenBing,value.id)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
local haveNum=0
|
2023-04-04 11:15:32 +08:00
|
|
|
|
if value.star>=0 then
|
|
|
|
|
LogError("value.star====="..value.star)
|
|
|
|
|
local starConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenbingStar,"Star",value.star,"Quality",value.quality)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
if starConfig then
|
|
|
|
|
haveNum=starConfig.SumItemNum
|
|
|
|
|
local starMatrs=starConfig.SumConsume
|
|
|
|
|
--消耗材料
|
|
|
|
|
if starMatrs then
|
|
|
|
|
for i = 1, #starMatrs do
|
|
|
|
|
local starm=starMatrs[i]
|
|
|
|
|
table.insert(allMaterials,{starm[1],starm[2]})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-04-04 11:15:32 +08:00
|
|
|
|
--消耗本体数量,分解成碎片
|
|
|
|
|
LogError("havenum==="..haveNum)
|
|
|
|
|
allCoin=allCoin+starConfig.CoinReturn[2]
|
2023-03-28 13:57:59 +08:00
|
|
|
|
end
|
2023-04-04 11:15:32 +08:00
|
|
|
|
|
2023-03-28 13:57:59 +08:00
|
|
|
|
end
|
|
|
|
|
--加上所有的分解币
|
2023-04-04 11:15:32 +08:00
|
|
|
|
table.insert(allMaterials,{22302,allCoin})
|
2023-03-28 13:57:59 +08:00
|
|
|
|
else--灵兽碎片
|
|
|
|
|
local itemConfig=ConfigManager.GetConfigData(ConfigName.ItemConfig,selectChipId)
|
|
|
|
|
if itemConfig then
|
|
|
|
|
local groupId=tonumber(itemConfig.ResolveReward)
|
|
|
|
|
local groupConfig=ConfigManager.GetConfigData(ConfigName.RewardGroup,groupId)
|
|
|
|
|
if groupConfig then
|
|
|
|
|
LogError("掉落组显示:"..groupConfig.ShowItem[1][1])
|
|
|
|
|
--local pokemon=ConfigManager.GetConfigData(ConfigName.ShenBing,groupConfig.ShowItem[1][1])
|
|
|
|
|
-- if pokemon then
|
|
|
|
|
LogError("groupConfig.ShowItem[1][1]=="..groupConfig.ShowItem[1][1].." groupConfig.ShowItem[1][2]=="..groupConfig.ShowItem[1][2])
|
|
|
|
|
table.insert(allMaterials,{groupConfig.ShowItem[1][1],groupConfig.ShowItem[1][2]*selectChipNum})
|
|
|
|
|
--end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--显示分解界面
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.PokemonRestore,allMaterials,function()
|
|
|
|
|
LogError("灵兽长度 "..#pokemonIds.."碎片id "..selectChipId.." num"..selectChipNum)
|
|
|
|
|
|
|
|
|
|
if isPokemon then
|
2023-04-04 11:15:32 +08:00
|
|
|
|
NetManager.RequestMagicSoldierSpilt(pokemonIds,function(msg)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1)
|
|
|
|
|
if pokemonIds and #pokemonIds>0 then
|
2023-04-04 11:15:32 +08:00
|
|
|
|
GodWeaponManager.RemoveWeaponData(pokemonIds)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
end
|
|
|
|
|
selectChipId = 0
|
|
|
|
|
oldChoosed = nil
|
|
|
|
|
this.SortTypeClick(0,sortingOrder)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
local items={}
|
|
|
|
|
for key, value in pairs(allMaterials) do
|
|
|
|
|
LogError("key==="..value[1].." value=="..value[2])
|
|
|
|
|
table.insert(items,{itemId=value[1],itemNum=value[2]})
|
|
|
|
|
end
|
|
|
|
|
NetManager.UseAndPriceItemRequest(1,items,function (drop)
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,drop)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end,2)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnShow(...)
|
|
|
|
|
local args={...}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogError("显示神兵分解界面=======")
|
|
|
|
|
sortingOrder =0
|
|
|
|
|
this.chooseObjList = {}
|
|
|
|
|
this.SortTypeClick(0,sortingOrder,args[3],args[4])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--展示数据
|
|
|
|
|
function this.SortTypeClick(_sort,_sortType,isTop,isAni)
|
|
|
|
|
tabSortType=_sortType
|
|
|
|
|
selectHeroData={}
|
|
|
|
|
--所有灵兽数据
|
|
|
|
|
local items={}
|
2023-03-29 10:48:35 +08:00
|
|
|
|
local heros=GodWeaponManager.GetNoUpZhenWeapons()
|
2023-03-28 13:57:59 +08:00
|
|
|
|
if heros then
|
|
|
|
|
for i, v in pairs(heros) do
|
|
|
|
|
local hero={}
|
|
|
|
|
local heroConfig=v.config
|
|
|
|
|
if heroConfig then
|
|
|
|
|
hero.star=v.star
|
|
|
|
|
hero.lv=v.lv
|
|
|
|
|
hero.dynamicId=v.dynamicId
|
|
|
|
|
hero.ischip=0
|
|
|
|
|
hero.icon= GetResourcePath(heroConfig.Icon)
|
|
|
|
|
hero.id=v.id
|
|
|
|
|
hero.quality=heroConfig.Quality
|
|
|
|
|
hero.name=heroConfig.Name
|
|
|
|
|
hero.returnCoin=heroConfig.CoinReturn
|
|
|
|
|
hero.frame=GetHeroQuantityImageByquality(heroConfig.Quality)
|
|
|
|
|
hero.num=1
|
|
|
|
|
table.insert(items,hero)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--所有灵兽碎片
|
|
|
|
|
local chips=BagManager.GetDataByItemType(ItemType.GodWeaponChip)
|
|
|
|
|
LogError("#chips len=="..#chips)
|
|
|
|
|
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
|
|
|
|
|
chip.dynamicId=v.id
|
|
|
|
|
table.insert(items,chip)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
heroDatas=items
|
|
|
|
|
LogError("heroDatas len=="..#heroDatas)
|
|
|
|
|
this.chipObj:SetActive(selectChipId~=0)
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectNumDes.gameObject:SetActive(selectChipId==0)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.selectText.gameObject:SetActive(selectChipId==0)
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectText.text = "0/"..maxSelectNum
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.SortHeroDatas(heroDatas)
|
|
|
|
|
if oldChoosed then
|
|
|
|
|
oldChoosed:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
this.Empty:SetActive(#heroDatas <= 0)
|
|
|
|
|
this.ScrollView:SetData(heroDatas, function (index, go)
|
|
|
|
|
this.SingleHeroDataShow(go, heroDatas[index],false)
|
|
|
|
|
end,isTop,isAni)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--英雄单个数据展示
|
|
|
|
|
function this.SingleHeroDataShow(go,_heroData,isGray)
|
|
|
|
|
local heroData = _heroData
|
|
|
|
|
local _go = go
|
|
|
|
|
Util.GetGameObject(_go.transform, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.frame)
|
|
|
|
|
if heroData.ischip==1 then
|
|
|
|
|
Util.GetGameObject(_go.transform, "lv"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(_go.transform, "num"):SetActive(true)
|
|
|
|
|
Util.GetGameObject(_go.transform, "num"):GetComponent("Text").text = heroData.num
|
|
|
|
|
else
|
|
|
|
|
Util.GetGameObject(_go.transform, "lv"):SetActive(true)
|
|
|
|
|
Util.GetGameObject(_go.transform, "num"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = heroData.lv
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.GetGameObject(_go.transform, "Text"):GetComponent("Text").text = SubString2(GetLanguageStrById(heroData.name),8)
|
|
|
|
|
Util.GetGameObject(_go.transform, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon)
|
|
|
|
|
local chipImg=Util.GetGameObject(_go.transform, "chipImg"):GetComponent("Image")
|
|
|
|
|
local formationMask =Util.GetGameObject(_go.transform, "mask")
|
|
|
|
|
formationMask:SetActive(false)
|
|
|
|
|
Util.GetGameObject(_go.transform, "mask/formationImage"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(_go.transform, "mask/formationImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite("t_tongyong-yishangzheng_zh")
|
|
|
|
|
if heroData.ischip==1 then
|
|
|
|
|
chipImg.gameObject:SetActive(true)
|
|
|
|
|
-- formationMask:SetActive(isGray)
|
|
|
|
|
chipImg.sprite=this.spLoader:LoadSprite(GetHeroChipQuantityImageByquality(heroData.quality))
|
|
|
|
|
else
|
|
|
|
|
chipImg.gameObject:SetActive(false)
|
|
|
|
|
-- formationMask:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
local starGrid = Util.GetGameObject(_go.transform, "star")
|
|
|
|
|
SetHeroStars(this.spLoader, starGrid, heroData.star,1,Vector2.New(32.5,32.5),-15)
|
|
|
|
|
local choosed =Util.GetGameObject(_go.transform, "choosed")
|
|
|
|
|
if heroData.ischip==1 then
|
|
|
|
|
choosed:SetActive(selectChipId==heroData.dynamicId)
|
|
|
|
|
else
|
|
|
|
|
choosed:SetActive(selectHeroData[heroData.dynamicId] ~= nil)
|
|
|
|
|
this.chooseObjList[heroData.dynamicId] = choosed
|
|
|
|
|
end
|
|
|
|
|
local cardclickBtn = Util.GetGameObject(_go.transform, "icon")
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectText.text = LengthOfTable(selectHeroData).."/"..maxSelectNum
|
2023-03-28 13:57:59 +08:00
|
|
|
|
Util.AddOnceClick(cardclickBtn, function()
|
|
|
|
|
--如果点击的是碎片
|
|
|
|
|
if heroData.ischip==1 then
|
|
|
|
|
--第一个选中的碎片
|
|
|
|
|
if oldChoosed==nil then
|
|
|
|
|
this.selectText.gameObject:SetActive(false)
|
|
|
|
|
this.chipObj:SetActive(true)
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
oldChoosed=choosed
|
|
|
|
|
else
|
|
|
|
|
--如果选中之前选中的,就取消选中
|
|
|
|
|
if oldChoosed==choosed then
|
|
|
|
|
oldChoosed=nil
|
|
|
|
|
selectChipId=0
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
this.selectText.gameObject:SetActive(true)
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectText.text = "0".."/"..maxSelectNum
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.chipObj:SetActive(false)
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
oldChoosed:SetActive(false)
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
oldChoosed=choosed
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
selectChipId=heroData.dynamicId
|
|
|
|
|
Util.SetGray(this.btn_add,true)
|
|
|
|
|
selectChipNum=heroData.num
|
|
|
|
|
maxChipNum=heroData.num
|
|
|
|
|
this.chipNumTxt.text=selectChipNum
|
|
|
|
|
isPokemon=false
|
|
|
|
|
--如果选中灵兽,则取消灵兽选择
|
|
|
|
|
if LengthOfTable(selectHeroData) > 0 then
|
|
|
|
|
for k,v in pairs(selectHeroData) do
|
|
|
|
|
selectHeroData[k] = nil
|
|
|
|
|
this.chooseObjList[k]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else--点击的是灵兽
|
|
|
|
|
--取消碎片选中
|
|
|
|
|
selectChipId=0
|
|
|
|
|
selectChipNum=0
|
|
|
|
|
if oldChoosed then
|
|
|
|
|
oldChoosed:SetActive(false)
|
|
|
|
|
oldChoosed=nil
|
|
|
|
|
end
|
|
|
|
|
--如果灵兽是选中状态,取消选中
|
|
|
|
|
if selectHeroData[heroData.dynamicId] then
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
selectHeroData[heroData.dynamicId] = nil
|
|
|
|
|
local haveNum=LengthOfTable(selectHeroData)
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectText.text = haveNum.."/"..maxSelectNum
|
2023-03-28 13:57:59 +08:00
|
|
|
|
if haveNum==0 then
|
|
|
|
|
-- --todo 取消所有碎片置灰
|
|
|
|
|
this.ScrollView:SetData(heroDatas, function (index, go)
|
|
|
|
|
this.SingleHeroDataShow(go, heroDatas[index],false)
|
|
|
|
|
end,true,true)
|
|
|
|
|
isPokemon=false
|
|
|
|
|
end
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
--如果选中灵兽的数量为最大
|
|
|
|
|
if LengthOfTable(selectHeroData)>=maxSelectNum then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[11747],maxSelectNum))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
--否则就是正常选择
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
selectHeroData[heroData.dynamicId]=heroData
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectText.text = LengthOfTable(selectHeroData).."/"..maxSelectNum
|
2023-03-28 13:57:59 +08:00
|
|
|
|
if isPokemon==false then
|
|
|
|
|
--todo 首次点击灵兽,置灰所有碎片
|
|
|
|
|
this.ScrollView:SetData(heroDatas, function (index, go)
|
|
|
|
|
this.SingleHeroDataShow(go, heroDatas[index],true)
|
|
|
|
|
end,true,true)
|
|
|
|
|
this.selectText.gameObject:SetActive(true)
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectNumDes.gameObject:SetActive(true)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.chipObj:SetActive(false)
|
|
|
|
|
isPokemon = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- LogGreen("selectChipId:"..tostring(selectChipId).." isPokemon:"..tostring(isPokemon))
|
|
|
|
|
this.selectText.gameObject:SetActive(isPokemon)
|
2023-09-28 17:05:40 +08:00
|
|
|
|
this.selectNumDes.gameObject:SetActive(isPokemon)
|
2023-03-28 13:57:59 +08:00
|
|
|
|
this.chipObj:SetActive(not isPokemon)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--灰色遮罩点击
|
|
|
|
|
-- Util.AddOnceClick(formationMask, function()
|
|
|
|
|
-- PopupTipPanel.ShowTip(Language[11748])
|
|
|
|
|
-- end)
|
|
|
|
|
end
|
|
|
|
|
--英雄排序
|
|
|
|
|
function this.SortHeroDatas(_heroDatas)
|
|
|
|
|
--上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。
|
|
|
|
|
table.sort(_heroDatas, function(a, b)
|
|
|
|
|
if a ==nil or b == nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if a.ischip==b.ischip then
|
|
|
|
|
if a.quality ==b.quality then
|
|
|
|
|
if a.star == b.star then
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
return a.id > b.id
|
|
|
|
|
else
|
|
|
|
|
return a.lv < b.lv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.star < b.star
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.quality < b.quality
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.ischip<b.ischip
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
selectChipId=0
|
|
|
|
|
selectHeroData={}
|
|
|
|
|
isPokemon=false
|
|
|
|
|
oldChoosed=nil
|
|
|
|
|
this.chooseObjList = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
this.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|
|
|
|
|
|