miduo_client/Assets/ManagedResources/~Lua/Modules/CompoundHero/view/CompoundHero_Compound.lua

628 lines
33 KiB
Lua

----- 神将合成 -----
local this = {}
local sortingOrder=0
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local curIndex = 0
local curNeedHero = {}
local curSelectHero = {}
local curSelectHeroConfig = {}
local curSelectGO
local materidaIsCan = false
local tabs={}
local needHeros={}
function this:InitComponent(gameObject)
this.compoundBtn = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/compoundBtn")
needHeros = {}
for i = 1, 4 do
needHeros[i] = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/titleGo/needHero" .. i)
end
for i = 1, 5 do
tabs[i] = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/Tabs/grid/Btn" .. i)
end
this.selectBtn=Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/Tabs/selectBtn")
this.heroPre = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/heroPre")
this.ScrollBar=Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/Scrollbar"):GetComponent("Scrollbar")
local v2 = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/scroll"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/scroll").transform,
this.heroPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(50,15))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
--up compound Hero info
this.compoundHero = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/titleGo/compoundHero/Hero")
this.compoundHeroTipText = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/titleGo/compoundHero/tipText")
this.compoundHeroTipText:GetComponent("Text").text = "请选择需要合成的神将"
this.compoundHerobg=Util.GetGameObject(this.compoundHero,"Bg1"):GetComponent("Image")
this.compoundHerolv=Util.GetGameObject(this.compoundHero,"lv/Text"):GetComponent("Text")
this.compoundHerohp = Util.GetGameObject(this.compoundHero,"hpProgress/hp"):GetComponent("Image")
this.compoundHerohpPass = Util.GetGameObject(this.compoundHero,"hpProgress/hpPass"):GetComponent("Image")
this.compoundHerorage = Util.GetGameObject(this.compoundHero,"rageProgress/rage"):GetComponent("Image")
this.compoundHerofg=Util.GetGameObject(this.compoundHero,"Bg2"):GetComponent("Image")
this.compoundHeropro=Util.GetGameObject(this.compoundHero,"Pro/Image"):GetComponent("Image")
this.compoundHerostarGrid=Util.GetGameObject(this.compoundHero,"StarGrid")
this.compoundHeroname=Util.GetGameObject(this.compoundHero,"Name/Text"):GetComponent("Text")
this.compoundHeroyuanImage=Util.GetGameObject(this.compoundHero,"yuanImage")
this.compoundHerolive = Util.GetGameObject(this.compoundHero, "Mask/icon"):GetComponent("RawImage")
this.compoundHerozs = Util.GetGameObject(this.compoundHero, "zs")
Util.GetGameObject(this.compoundHero,"hpProgress").gameObject:SetActive(false)
Util.GetGameObject(this.compoundHero,"rageProgress").gameObject:SetActive(false)
Util.GetGameObject(this.compoundHero,"UI_Effect_jinkuang_KaPai").gameObject:SetActive(false)
end
function this:BindEvent()
Util.AddClick(this.compoundBtn, function()
this.Compound(curIndex)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
local sortingOrder = 0
function this:OnSortingOrderChange(_sortingOrder)
sortingOrder = _sortingOrder
end
function this:OnShow(...)
curIndex = 0
sortingOrder =0
for i = 0,#tabs - 1 do
local index=i
Util.GetGameObject(tabs[i + 1], "Image"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(index))
Util.AddOnceClick(tabs[i + 1], function()
this.HeroCompoundBtnClick(tabs[i + 1],index)
end)
end
this.HeroCompoundBtnClick(tabs[1],curIndex)
end
--英雄类型按钮点击事件
function this.HeroCompoundBtnClick(_btn,_curIndex)
curIndex = _curIndex
this.SetBtnSelect(_btn)
this.ShowCurrPosHeroCompound()
end
--显示当前阵营的英雄
function this.ShowCurrPosHeroCompound()
local heroDatas = this.GetAllHeroCompoundData(curIndex)
this.SelectHeroShow(nil)
this.ScrollView:SetData(heroDatas, function (index, go)
this.SingleHeroDataShow(go, heroDatas[index])
end)
end
--设置按钮选中
function this.SetBtnSelect(_parObj)
this.selectBtn.transform:SetParent(_parObj.transform)
this.selectBtn.transform.localScale = Vector3.one
this.selectBtn.transform.localPosition=Vector3.zero
end
function this.ShowTitleData(curHeroCompoundData)
if curHeroCompoundData then
local _star = curHeroCompoundData.star
local heroData = curHeroCompoundData.haveHeroList[1][1]
local heroConfig = heroData and heroData.heroConfig or curHeroCompoundData.config
this.compoundHero:SetActive(true)
this.compoundHeroTipText:SetActive(false)
this.compoundHerobg.sprite = Util.LoadSprite(GetHeroCardStarBg[_star])
local zsName = GetHeroCardStarZs[_star]
this.compoundHerofg.sprite = Util.LoadSprite(GetHeroCardStarFg[_star])
this.compoundHeroyuanImage:SetActive(false)
SetCardStars(this.compoundHerostarGrid,_star)
local curHeroHpVal = nil--FormationManager.GetFormationHeroHp(this.curFormationIndex,_heroData.dynamicId)
this.compoundHerohp.fillAmount = curHeroHpVal or 1
this.compoundHerohpPass.fillAmount = curHeroHpVal or 1
this.compoundHerorage.fillAmount = 0.5
local liveName = GetResourcePath(heroConfig.Live)
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroConfig.Id)
local scale = roleConfig.play_liveScale
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
this.compoundHerolive.texture = CardRendererManager.GetSpineTexture(1, liveName, Vector3.one * scale, livePos, true)
this.compoundHerolive.transform.localScale = Vector3.one
this.compoundHerolive.transform.localPosition = Vector3.zero
this.compoundHeropro.sprite=Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
this.compoundHeroname.text=heroConfig.ReadingName
if zsName == "" then
this.compoundHerozs:SetActive(false)
else
this.compoundHerozs:SetActive(true)
this.compoundHerozs:GetComponent("Image").sprite = Util.LoadSprite(zsName)
end
if heroData then--第一位是否有英雄
this.compoundHerolv.text=heroData.lv
else
this.compoundHerolv.text=1
end
else
this.compoundHero:SetActive(false)
this.compoundHeroTipText:SetActive(true)
end
end
local upStarConsumeMaterial = {}
local upStarMaterialIsAll = {}
local curSelectUpStarData
local curSelectUpStarGo
local upStarRankUpConfig
--更新英雄进阶数据
function this.UpdateHeroUpStarData(_curUpStarData)
--进阶吞英雄条件
if _curUpStarData then
upStarConsumeMaterial={}
upStarMaterialIsAll = {}
for i = 1, #_curUpStarData.upStarMaterialsData do
local upStarMaterialsData = _curUpStarData.upStarMaterialsData[i]
local curUpStarData = _curUpStarData.upStarData[i]
local go = needHeros[i + 1]
go:SetActive(true)
upStarConsumeMaterial[i]={}
upStarMaterialIsAll[i]=false
local proImage = Util.GetGameObject(go.transform, "iconbg/proImage")
local iconDefault = Util.GetGameObject(go.transform,"iconDefault")
local icon = Util.GetGameObject(go.transform,"icon")
local frame = Util.GetGameObject(go.transform,"frame")
local addBtn=Util.GetGameObject(go.transform,"add")
local addBtnImage = Util.GetGameObject(go.transform,"add/add")
local num = Util.GetGameObject(go.transform,"num")
local num = Util.GetGameObject(go.transform,"num")
local starGrid = Util.GetGameObject(go.transform, "iconbg/starGrid")
proImage:SetActive(false)
if upStarMaterialsData.Issame==1 or upStarMaterialsData.IsId>0 then
iconDefault:SetActive(false)
icon:SetActive(true)
proImage:SetActive(true)
if upStarMaterialsData.Issame==1 then
icon:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(_curUpStarData.config.Icon))
frame:GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(_curUpStarData.config.Quality, upStarMaterialsData.StarLimit))
proImage:GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(_curUpStarData.config.PropertyName))
elseif upStarMaterialsData.IsId>0 then
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, upStarMaterialsData.IsId)
icon:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(heroConfig.Icon))
frame:GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroConfig.Quality, upStarMaterialsData.StarLimit))
proImage:GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
end
else
if upStarMaterialsData.IsSameClan ==1 then
proImage:SetActive(true)
proImage:GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(_curUpStarData.config.PropertyName))
end
iconDefault:SetActive(true)
icon:SetActive(false)
frame:GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(nil,upStarMaterialsData.StarLimit))
end
-- local upStarHeroListData=HeroManager.GetUpStarHeroListData(curUpStarData.Id,curSelectHero)
-- if upStarHeroListData.state>0 then
-- addBtnImage:SetActive(true)
-- else
-- addBtnImage:SetActive(false)
-- end
num:GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>",0,curUpStarData[4])
-- if #_curUpStarData.haveHeroList[i + 1] >= curUpStarData[4] then
-- num:GetComponent("Text").text=string.format("<color=#FFFFFF>%s/%s</color>",#_curUpStarData.haveHeroList[i + 1],curUpStarData[4])
-- else
-- num:GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>",#_curUpStarData.haveHeroList[i + 1],curUpStarData[4])
-- end
SetHeroStars(starGrid, upStarMaterialsData.StarLimit,1,nil,-15.3)
-- LogGreen("_curUpStarData.haveHeroList3[i] "..#_curUpStarData.haveHeroList3[i + 1])
Util.AddOnceClick(addBtn, function()
-- curSelectUpStarData=curUpStarData[i]
-- curSelectUpStarGo=go
-- local curShowHeroListData=self:SetShowHeroListData(upStarConsumeMaterial,upStarHeroListData.heroList)
-- --参数1 显示的herolist 2 3 升当前星的规则 4 打开RoleUpStarListPanel的界面
-- UIManager.OpenPanel(UIName.RoleUpStarListPanel,curShowHeroListData,upStarMaterialsData,curUpStarData,this,upStarConsumeMaterial[i],curSelectHero)
curSelectUpStarData=curUpStarData
curSelectUpStarGo=go
local curShowHeroListData=this.SetShowHeroListData(upStarConsumeMaterial,_curUpStarData.haveHeroList3[i + 1])
--参数1 显示的herolist 2 3 升当前星的规则 4 打开RoleUpStarListPanel的界面
UIManager.OpenPanel(UIName.CompoundHeroUpStarListPanel,curShowHeroListData,upStarMaterialsData,curUpStarData,this,upStarConsumeMaterial[i],curSelectHero)
end)
end
if curSelectHero then
--自动选择进阶妖灵师材料
this.AutoSelectUpStarHeroList(_curUpStarData)
end
else
for i = 1, #needHeros do
needHeros[i]:SetActive(false)
end
end
end
--分析设置升星界面显示的英雄list数据 如果当前升星材料的坑位的英雄数据与 以其他坑位有重合并且选择上的英雄不显示 如果是当前坑位显示的英雄显示对勾
function this.SetShowHeroListData(upStarConsumeMaterial,curHeroList)--1 消耗的总消耗组 2 当前坑位可选择的所有英雄
local curEndShowHeroListData={}
for i = 1, #curHeroList do
if curHeroList[i].dynamicId ~= curSelectHero.dynamicId then
curHeroList[i].isSelect=2
-- LogGreen("curHeroList[i] "..curHeroList[i].dynamicId)
table.insert(curEndShowHeroListData,curHeroList[i])
end
end
-- LogGreen("#curEndShowHeroListData "..#curEndShowHeroListData)
for j = 1, #upStarConsumeMaterial do
if upStarConsumeMaterial[j] and #upStarConsumeMaterial[j]>0 then
for k = 1, #upStarConsumeMaterial[j] do
if j==curSelectUpStarData[2] then--curSelectUpStarData 当前坑位选择的英雄信息
for _, v in pairs(curEndShowHeroListData) do
if v.dynamicId==upStarConsumeMaterial[j][k] then
v.isSelect=1
end
end
else
for i, v in pairs(curEndShowHeroListData) do
if v.dynamicId==upStarConsumeMaterial[j][k] then
curEndShowHeroListData[i] = nil
end
end
end
end
end
end
local curList={}
for _, v in pairs(curEndShowHeroListData) do
-- LogGreen("#curList "..v.id.." "..v.isSelect)
table.insert(curList,v)
end
return curList
end
--升星选择祭品后刷新界面
function this.AutoSelectUpStarHeroList(_curUpStarData)
local curUpStarData= _curUpStarData.upStarMaterialsData
if curUpStarData and #curUpStarData>0 then
for i = 1, #curUpStarData do
curSelectUpStarGo = needHeros[i + 1]
curSelectUpStarData=curUpStarData[i]
local upStarHeroListData=_curUpStarData.haveHeroList3[i + 1]
local curSelectHeroList = {}
if curSelectUpStarData.Issame ==1
or curSelectUpStarData.IsId > 0
or (curSelectUpStarData.IsSameClan == 1
and curSelectUpStarData.StarLimit == 3
and curSelectHero.heroConfig.Qualiy ~= 3) then
if LengthOfTable(upStarHeroListData) >= _curUpStarData.upStarData[i][4] then
for j = 1, LengthOfTable(upStarHeroListData) do
LogGreen(_curUpStarData.upStarData[i][4])
if #curSelectHeroList < _curUpStarData.upStarData[i][4] then
if upStarHeroListData[j].lockState == 0 and upStarHeroListData[j].dynamicId ~= curSelectHero.dynamicId then--upStarHeroListData[i].isFormation == ""
table.insert(curSelectHeroList,upStarHeroListData[j])
end
end
end
this.UpdateUpStarPosHeroData(curSelectHeroList, _curUpStarData.upStarData[i])
end
end
end
end
end
--刷新当前升星坑位英雄的信息
function this.UpdateUpStarPosHeroData(curSelectHeroList,_upStarData)
-- LogGreen("LengthOfTable(curSelectHeroList) "..LengthOfTable(curSelectHeroList))
local upStarData = _upStarData and _upStarData or curSelectUpStarData
if LengthOfTable(curSelectHeroList) < upStarData[4] then
upStarMaterialIsAll[upStarData[2]]=2
Util.GetGameObject(curSelectUpStarGo.transform,"add/add"):SetActive(true)
-- local upStarHeroListData=HeroManager.GetUpStarHeroListData(curSelectUpStarData.upStarMaterialsData.Id,curHeroData)
-- if upStarHeroListData.state<=0 then
-- Util.GetGameObject(curSelectUpStarGo.transform,"add/add"):SetActive(false)
-- end
Util.GetGameObject(curSelectUpStarGo.transform,"num"):GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>", LengthOfTable(curSelectHeroList),upStarData[4])
else
upStarMaterialIsAll[upStarData[2]]=1
Util.GetGameObject(curSelectUpStarGo.transform,"add/add"):SetActive(false)
Util.GetGameObject(curSelectUpStarGo.transform,"num"):GetComponent("Text").text=string.format("<color=#FFFFFFFF>%s/%s</color>", LengthOfTable(curSelectHeroList),upStarData[4])
end
local curUpStarConsumeMaterial={}
for i, v in pairs(curSelectHeroList) do
table.insert(curUpStarConsumeMaterial,v.dynamicId)
end
upStarConsumeMaterial[upStarData[2]]=curUpStarConsumeMaterial
for i = 1, #upStarConsumeMaterial do
-- LogGreen("选择升星位置的英雄数量 "..#upStarConsumeMaterial[i])
if #upStarConsumeMaterial[i]>0 then
for j = 1, #upStarConsumeMaterial[i] do
-- LogGreen("选择升星位置的英雄都有谁 "..upStarConsumeMaterial[i][j])
end
end
end
end
--更新英雄进阶数据
function this.UpdateFirstHeroUpStarData(curHeroCompoundData)
local go = needHeros[1]
local proImage = Util.GetGameObject(go.transform, "iconbg/proImage")
local iconDefault = Util.GetGameObject(go.transform,"iconDefault")
local icon = Util.GetGameObject(go.transform,"icon")
local frame = Util.GetGameObject(go.transform,"frame")
local addBtn=Util.GetGameObject(go.transform,"add")
local addBtnImage = Util.GetGameObject(go.transform,"add/add")
local num = Util.GetGameObject(go.transform,"num")
local num = Util.GetGameObject(go.transform,"num")
local starGrid = Util.GetGameObject(go.transform, "iconbg/starGrid")
if curSelectHero or curHeroCompoundData then
local heroConfig = curSelectHero and curSelectHero.heroConfig or curHeroCompoundData.config
go:SetActive(true)
proImage:SetActive(true)
iconDefault:SetActive(false)
addBtnImage:SetActive(false)
icon:GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(heroConfig.Icon))
frame:GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroConfig.Quality, heroConfig.Star))
proImage:GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
SetHeroStars(starGrid, heroConfig.Star,1,nil,-15.3)
if curSelectHero then
num:GetComponent("Text").text=string.format("<color=#FFFFFF>%s/%s</color>",1,1)
else
num:GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>",0,1)
end
else
needHeros[1]:SetActive(false)
end
end
--数据显示
function this.SingleHeroDataShow(_go,_heroData)
local go = _go
local heroData = _heroData
Util.GetGameObject(go.transform, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroData.config.Quality,heroData.star))
Util.GetGameObject(go.transform, "lv"):SetActive(false)-- :GetComponent("Text").text = heroData.lv
Util.GetGameObject(go.transform, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(heroData.config.Icon))
Util.GetGameObject(go.transform, "posIcon"):SetActive(false)--:GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon)
Util.GetGameObject(go.transform, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.config.PropertyName))
local formationMask = Util.GetGameObject(go.transform, "formationMask")
formationMask:SetActive(false)--(heroData.isFormation ~= "" and heroData.isFormation ~= Language[11108]) or heroData.lockState == 1)
local starGrid = Util.GetGameObject(go.transform, "star")
SetHeroStars(starGrid, heroData.star,1,nil,nil,Vector2.New(0,1))
local progress1 = Util.GetGameObject(go.transform, "progressBg/progress1")--红
local progress2 = Util.GetGameObject(go.transform, "progressBg/progress2")--蓝
local progressText = Util.GetGameObject(go.transform, "progressBg/progressText"):GetComponent("Text")
local num = LengthOfTable(heroData.haveHeroList2)/heroData.needNum
progress1:SetActive(LengthOfTable(heroData.haveHeroList2) < heroData.needNum)
progress2:SetActive(LengthOfTable(heroData.haveHeroList2) >= heroData.needNum)
progress1:GetComponent("Image").fillAmount = num
progress2:GetComponent("Image").fillAmount = num
progressText.text = LengthOfTable(heroData.haveHeroList2).."/"..heroData.needNum
local cardBtn = Util.GetGameObject(go.transform, "icon")
local choosed = Util.GetGameObject(go.transform, "choosed")
choosed:SetActive(false)
if curSelectHeroConfig and curSelectHeroConfig.config and curSelectHeroConfig.config.Id == _heroData.config.Id then
choosed:SetActive(true)
curSelectGO = choosed
this.SelectHeroShow(curSelectHeroConfig)
end
Util.AddOnceClick(cardBtn, function()
if curSelectHeroConfig and curSelectHeroConfig.config then
if curSelectHeroConfig.config.Id == _heroData.config.Id then
choosed:SetActive(false)
curSelectHeroConfig = nil
curSelectGO = nil
this.SelectHeroShow(nil)
return
else
curSelectHeroConfig = heroData
if curSelectGO then
curSelectGO:SetActive(false)
end
choosed:SetActive(true)
curSelectGO = choosed
this.SelectHeroShow(curSelectHeroConfig)
end
else
curSelectHeroConfig = heroData
choosed:SetActive(true)
curSelectGO = choosed
this.SelectHeroShow(curSelectHeroConfig)
end
end)
end
function this.Compound()
for k, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroRankupConfig)) do
if v.Star == curSelectHero.heroConfig.Star and v.LimitStar == curSelectHero.heroConfig.Star and v.OpenStar == curSelectHero.heroConfig.Star + 1 then
upStarRankUpConfig = v
end
end
local isUpStarMaterialsHero=true
for i = 1, #upStarMaterialIsAll do
if upStarMaterialIsAll[i]==2 then
isUpStarMaterialsHero=false
end
end
if isUpStarMaterialsHero then
NetManager.HeroUpStarEvent(curSelectHero.dynamicId,upStarConsumeMaterial ,function (msg)
UIManager.OpenPanel(UIName.RoleUpStarSuccessPanel,curSelectHero,upStarRankUpConfig.Id,upStarRankUpConfig.OpenLevel,function ()
local dropItemTabs = BagManager.GetTableByBackDropData(msg)
if #dropItemTabs > 0 then
UIManager.OpenPanel(UIName.RewardItemPopup, msg, 1, function ()
this.DeleteUpStarMaterials()
end)
else
this.DeleteUpStarMaterials()
end
end)
end)
-- 进阶音效
PlaySoundWithoutClick(SoundConfig.Sound_Recruit3)
else
PopupTipPanel.ShowTip(Language[11852])
end
end
--扣除升星 消耗的材料 更新英雄数据
function this.DeleteUpStarMaterials()
HeroManager.UpdateSingleHeroDatas(curSelectHero.dynamicId,curSelectHero.lv,curSelectHero.star+1,curSelectHero.breakId,upStarRankUpConfig.Id,true)
HeroManager.UpdateSingleHeroSkillData(curSelectHero.dynamicId)
--本地数据删除材料英雄
for i = 1, #upStarConsumeMaterial do
HeroManager.DeleteHeroDatas(upStarConsumeMaterial[i])
end
--刷新界面
this.ShowCurrPosHeroCompound()
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
tabImage:GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status])
tabImage:GetComponent("Image"):SetNativeSize()
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
tabImage.transform.localPosition = Vector3.New( tabImage.transform.localPosition.x, _TabImagePos[status], 0);
end
--切换视图
function this.SwitchView(index)
this.OnClickTabBtn(index)
end
function this:OnClose()
curNeedHero = {}
curSelectHero = {}
curSelectHeroConfig = {}
curSelectGO = nil
end
function this:OnDestroy()
end
local heroRankupGroup = ConfigManager.GetConfig(ConfigName.HeroRankupGroup)
local upSortHeroList,downSoryHeroList
local allCompoundHeroConFigData = {}
--获取英雄可合成数据(所有可以英雄四星生五星 五星生六星)
function this.GetAllHeroCompoundData(index)
upSortHeroList,downSoryHeroList = HeroManager.ByCompoundHeroGetAllHeros()
allCompoundHeroConFigData = {}
for _, configInfo in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroConfig)) do
if (configInfo.Star == 4 or configInfo.Star == 5) and (index == 0 or configInfo.PropertyName == index)then
local curHeroCompoundData = {}
curHeroCompoundData.star = configInfo.Star + 1
curHeroCompoundData.config = configInfo
curHeroCompoundData.haveHeroList = {}--可以选择的英雄数量 [1][2][3] 无重数据
curHeroCompoundData.haveHeroList2 = {}--可以选择的英雄数量 记数量去重用 did = didData
curHeroCompoundData.haveHeroList3 = {}--可以选择的英雄数量 [1][2][3] 重数据
curHeroCompoundData.needNum = 1--需要英雄数量 第一位先加上
curHeroCompoundData.haveHeroList[1] = {}
curHeroCompoundData.haveHeroList3[1] = {}
curHeroCompoundData.upStarData = {}
curHeroCompoundData.upStarMaterialsData = {}
--其后几位加数量
if configInfo.RankupConsumeMaterial then
for i = 1, #configInfo.RankupConsumeMaterial do
if configInfo.RankupConsumeMaterial[i][1] == curHeroCompoundData.star then
curHeroCompoundData.needNum = curHeroCompoundData.needNum + configInfo.RankupConsumeMaterial[i][4]
curHeroCompoundData.haveHeroList[configInfo.RankupConsumeMaterial[i][2] + 1] = {}
curHeroCompoundData.haveHeroList3[configInfo.RankupConsumeMaterial[i][2] + 1] = {}
curHeroCompoundData.upStarData[i] = configInfo.RankupConsumeMaterial[i]
table.insert(curHeroCompoundData.upStarData,configInfo.RankupConsumeMaterial[i])
table.insert(curHeroCompoundData.upStarMaterialsData,heroRankupGroup[configInfo.RankupConsumeMaterial[i][3]])
end
end
end
for key, bagHeroValue in pairs(downSoryHeroList) do
--第一位
-- if LengthOfTable(curHeroCompoundData.haveHeroList2) >= curHeroCompoundData.needNum then return end
if bagHeroValue.heroConfig.Id == configInfo.Id and ((bagHeroValue.heroConfig.Star == 4 and bagHeroValue.star == 4) or (bagHeroValue.heroConfig.Star == 5 and bagHeroValue.star == 5)) then
if #curHeroCompoundData.haveHeroList[1] < 1 then
table.insert(curHeroCompoundData.haveHeroList[1],bagHeroValue)
curHeroCompoundData.haveHeroList2[bagHeroValue.dynamicId] = bagHeroValue
end
table.insert(curHeroCompoundData.haveHeroList3[1],bagHeroValue)
end
end
this.GetAllHeroCompoundData2(configInfo,curHeroCompoundData)
table.insert(allCompoundHeroConFigData,curHeroCompoundData)
end
end
return allCompoundHeroConFigData
end
function this.GetAllHeroCompoundData2(configInfo,curHeroCompoundData,isGet)
if isGet then
for i = 2, #curHeroCompoundData.haveHeroList do
curHeroCompoundData.haveHeroList[i] = {}
curHeroCompoundData.haveHeroList3[i] = {}
end
curHeroCompoundData.haveHeroList2[curHeroCompoundData.haveHeroList[1][1].dynamicId] = curHeroCompoundData.haveHeroList[1][1]
end
for key, bagHeroValue in pairs(upSortHeroList) do
--其后几位
if configInfo.RankupConsumeMaterial then
for i = 1, #configInfo.RankupConsumeMaterial do
if configInfo.RankupConsumeMaterial[i][1] == curHeroCompoundData.star then
local curNeedHeroData = nil
local heroRankUpGroup = heroRankupGroup[configInfo.RankupConsumeMaterial[i][3]]
if heroRankUpGroup.Issame == 1 then --需要同名卡
if bagHeroValue.id == configInfo.Id then
if bagHeroValue.star == heroRankUpGroup.StarLimit then
if heroRankUpGroup.IsSameClan == 1 then
if bagHeroValue.property == configInfo.PropertyName then
if heroRankUpGroup.IsId > 0 then
if bagHeroValue.id == heroRankUpGroup.IsId then
curNeedHeroData = bagHeroValue
end
else
curNeedHeroData = bagHeroValue
end
end
else
if heroRankUpGroup.IsId > 0 then
if bagHeroValue.id == heroRankUpGroup.IsId then
curNeedHeroData = bagHeroValue
end
else
curNeedHeroData = bagHeroValue
end
end
end
end
else
if bagHeroValue.star == heroRankUpGroup.StarLimit then
if heroRankUpGroup.IsSameClan == 1 then
if bagHeroValue.property == configInfo.PropertyName then
if heroRankUpGroup.IsId > 0 then
if bagHeroValue.id == heroRankUpGroup.IsId then
curNeedHeroData = bagHeroValue
end
else
curNeedHeroData = bagHeroValue
end
end
else
if heroRankUpGroup.IsId > 0 then
if bagHeroValue.id == heroRankUpGroup.IsId then
curNeedHeroData = bagHeroValue
end
else
curNeedHeroData = bagHeroValue
end
end
end
end
if #curHeroCompoundData.haveHeroList[configInfo.RankupConsumeMaterial[i][2] + 1] < configInfo.RankupConsumeMaterial[i][4] then
if curNeedHeroData and not curHeroCompoundData.haveHeroList2[curNeedHeroData.dynamicId] then
-- LogGreen("SID "..curHeroCompoundData.config.Id.." pos "..configInfo.RankupConsumeMaterial[i][2] + 1 .." curNeedHeroData.dynamicId "..curNeedHeroData.dynamicId)
table.insert(curHeroCompoundData.haveHeroList[configInfo.RankupConsumeMaterial[i][2] + 1],curNeedHeroData)
curHeroCompoundData.haveHeroList2[curNeedHeroData.dynamicId] = curNeedHeroData
end
end
if curNeedHeroData then
table.insert(curHeroCompoundData.haveHeroList3[configInfo.RankupConsumeMaterial[i][2] + 1],curNeedHeroData)
end
end
end
end
end
if isGet then
return curHeroCompoundData
end
end
--点击获取数据
function this.SelectHeroShow(curHeroCompoundData)
if curHeroCompoundData then
curSelectHero = curHeroCompoundData.haveHeroList[1][1]
this.ShowTitleData(curHeroCompoundData)
this.UpdateFirstHeroUpStarData(curHeroCompoundData)
this.UpdateHeroUpStarData(curHeroCompoundData)
else
curSelectHero = nil
this.ShowTitleData(nil)
this.UpdateFirstHeroUpStarData(nil)
this.UpdateHeroUpStarData(nil)
end
end
return this