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

776 lines
41 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.spLoader = SpriteLoader.New()
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, 6 do
tabs[i] = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/Tabs/grid/Btn" .. i)
tabs[i]:SetActive(true)
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(35,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/tipText")
this.compoundHeroTipText:GetComponent("Text").text = Language[10414]
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")
this.compoundHeroframe = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/titleGo/compoundHero/frame")
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(...)
HeroManager.GetAllHeroCompoundRedPoint()
curIndex = 0
sortingOrder =0
for i = 0,#tabs - 1 do
local index=i
Util.GetGameObject(tabs[i + 1], "Image"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(index))
Util.GetGameObject(tabs[i + 1], "Image/Text"):GetComponent("Text").text=PropertyType[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)
curSelectHeroConfig = nil
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,false,false)
-- this.ScrollView:ForeachItemGO(function(index, go)
-- Timer.New(function()
-- go.gameObject:SetActive(true)
-- PlayUIAnim(go.gameObject)
-- end, 0.001 * (index - 1)):Start()
-- end)
end
--显示当前阵营的英雄
function this.ShowCurrPosHeroCompound2()
local heroDatas = this.GetAllHeroCompoundData(curIndex)
this.ScrollView:SetData(heroDatas, function (index, go)
this.SingleHeroDataShow(go, heroDatas[index])
end,true,true)
this.SelectHeroShow(curSelectHeroConfig)
end
--设置按钮选中
function this.SetBtnSelect(_parObj)
this.selectBtn.transform:SetParent(_parObj.transform)
this.selectBtn.transform:SetAsFirstSibling()
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.compoundHeroframe:SetActive(false)
local upStarRankUpConfig
for k, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroRankupConfig)) do
if v.Star == heroConfig.Star and v.LimitStar == heroConfig.Star and v.OpenStar == heroConfig.Star + 1 then
upStarRankUpConfig = v
end
end
if HarmonyManager.GetSingleAdditions(HarmonyAddType.AddLv) < upStarRankUpConfig.LimitHongmengLevel then -- 鸿蒙阵神将共鸣等级
this.compoundHeroTipText:SetActive(true)
this.compoundHeroTipText:GetComponent("Text").text = string.format("<color=#ff0000>进阶需求鸿蒙阵等级:%s</color>",upStarRankUpConfig.LimitHongmengLevel)
else
this.compoundHeroTipText:SetActive(false)
end
-- this.compoundHerobg.sprite = this.spLoader:LoadSprite(GetHeroCardStarBg[_star])
local zsName = GetHeroCardStarZs[_star]
-- this.compoundHerofg.sprite = this.spLoader: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 = ""
local roleConfig = {}
local scale = {}
local livePos = {}
if curSelectHero and curSelectHero.heroConfig then
liveName = curSelectHero.live
if curSelectHero.skinId == 0 then
roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroConfig.Id)
else
roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, curSelectHero.skinId)
end
else
liveName = GetResourcePath(heroConfig.Painting)
roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroConfig.Id)
end
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
SetHEeroLiveToward(this.compoundHerolive,heroConfig.Toward)
this.compoundHeropro.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
this.compoundHeroname.text=GetLanguageStrById(heroConfig.ReadingName)
if zsName == "" then
this.compoundHerozs:SetActive(false)
else
this.compoundHerozs:SetActive(true)
this.compoundHerozs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName)
end
if heroData then--第一位是否有英雄
this.compoundHerolv.text=heroData.lv
else
this.compoundHerolv.text=1
end
else
this.compoundHero:SetActive(false)
this.compoundHeroframe:SetActive(true)
this.compoundHeroTipText:SetActive(true)
this.compoundHeroTipText:GetComponent("Text").text = Language[10414]
end
end
local upStarConsumeMaterial = {}
local upStarMaterialIsAll = {}
local curSelectUpStarData
local curSelectUpStarGo
local upStarRankUpConfig
--更新英雄进阶数据
function this.UpdateHeroUpStarData(_curUpStarData)
--进阶吞英雄条件
if _curUpStarData then
upStarConsumeMaterial={}
upStarMaterialIsAll = {}
for i = 2, #needHeros do
needHeros[i]:SetActive(false)
end
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]=2
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,"lv/num")
local starGrid = Util.GetGameObject(go.transform, "iconbg/starGrid")
Util.GetGameObject(go.transform, "nameText"):GetComponent("Text").text = this.GetNeedHeroName(upStarMaterialsData)
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=this.spLoader:LoadSprite(GetResourcePath(_curUpStarData.config.Icon))
frame:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(_curUpStarData.config.Quality, upStarMaterialsData.StarLimit))
proImage:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(_curUpStarData.config.PropertyName))
elseif upStarMaterialsData.IsId>0 then
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, upStarMaterialsData.IsId)
icon:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon))
frame:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroConfig.Quality, upStarMaterialsData.StarLimit))
proImage:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
end
else
if upStarMaterialsData.IsSameClan ==1 then
proImage:SetActive(true)
proImage:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(_curUpStarData.config.PropertyName))
end
iconDefault:SetActive(true)
icon:SetActive(false)
frame:GetComponent("Image").sprite=this.spLoader: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])
SetHeroStars(this.spLoader, starGrid, upStarMaterialsData.StarLimit,1,nil,-15.3)
Util.AddOnceClick(addBtn, function()
if not curSelectHero then return end
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.heroConfig or 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,isFirstPos)--1 消耗的总消耗组 2 当前坑位可选择的所有英雄
local curEndShowHeroListData={}
for i = 1, #curHeroList do
if curHeroList[i].dynamicId ~= curSelectHero.dynamicId then
curHeroList[i].isSelect=2
table.insert(curEndShowHeroListData,curHeroList[i])
elseif isFirstPos then
curHeroList[i].isSelect=1
table.insert(curEndShowHeroListData,curHeroList[i])
end
end
if isFirstPos then
return curEndShowHeroListData
else
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
end
local curList={}
for _, v in pairs(curEndShowHeroListData) do
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
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 and curSelectHero.heroConfig.Qualiy ~= 3) or (not curSelectHero.heroConfig and curSelectHero.Qualiy ~= 3))) then
if LengthOfTable(upStarHeroListData) >= _curUpStarData.upStarData[i][4] then
-- curSelectUpStarGo = needHeros[i + 1]
for j = 1, LengthOfTable(upStarHeroListData) do
if #curSelectHeroList < _curUpStarData.upStarData[i][4] then
if upStarHeroListData[j] and upStarHeroListData[j].dynamicId and upStarHeroListData[j].lockState == 0 and (curSelectHero.heroConfig and upStarHeroListData[j].dynamicId ~= curSelectHero.dynamicId) and upStarHeroListData[j].isFormation == ""
and not HarmonyManager.IsChangeColor(upStarHeroListData[j].dynamicId) and not HarmonyManager:IsEnvoy(upStarHeroListData[j].dynamicId) then
table.insert(curSelectHeroList,upStarHeroListData[j])
end
end
end
this.UpdateUpStarPosHeroData(curSelectHeroList, _curUpStarData.upStarData[i],needHeros[i + 1])
end
end
end
end
end
--刷新当前升星坑位英雄的信息
function this.UpdateUpStarPosHeroData(curSelectHeroList,_upStarData,go)
local upStarData = _upStarData or curSelectUpStarData
local curGo = go or curSelectUpStarGo
if LengthOfTable(curSelectHeroList) < upStarData[4] then
upStarMaterialIsAll[upStarData[2]]=2
Util.GetGameObject(curGo.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(curGo.transform,"num"):GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>", LengthOfTable(curSelectHeroList),upStarData[4])
else
upStarMaterialIsAll[upStarData[2]]=1
Util.GetGameObject(curGo.transform,"add/add"):SetActive(false)
Util.GetGameObject(curGo.transform,"num"):GetComponent("Text").text=string.format("<color=#00FF06>%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.UpdateUpStarPosHeroData2(curSelectHeroList)
-- --LogGreen("LengthOfTable(curSelectHeroList) "..LengthOfTable(curSelectHeroList))
if LengthOfTable(curSelectHeroList) < 1 then
Util.GetGameObject(curSelectUpStarGo.transform,"add/add"):SetActive(true)
curSelectHero = nil
-- 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),1)
else
for key, value in pairs(curSelectHeroList) do
curSelectHero = value
--自动选择进阶妖灵师材料
this.compoundHerolv.text=curSelectHero.lv
end
local _curUpStarData = this.GetAllHeroCompoundData2(curSelectHeroConfig.config,curSelectHeroConfig,true)
if curSelectHero then this.UpdateHeroUpStarData(_curUpStarData) end
Util.GetGameObject(curSelectUpStarGo.transform,"add/add"):SetActive(false)
Util.GetGameObject(curSelectUpStarGo.transform,"num"):GetComponent("Text").text=string.format("<color=#00FF06>%s/%s</color>", LengthOfTable(curSelectHeroList),1)
this.ShowTitleData(curSelectHeroConfig)
this.UpdateFirstHeroUpStarData(curSelectHeroConfig)
end
end
--更新英雄进阶数据 ((not HarmonyManager:IsEnvoy(curSelectHero.dynamicId) )and (not HarmonyManager.IsInfo(curSelectHero.dynamicId)) )
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,"lv/num")
local starGrid = Util.GetGameObject(go.transform, "iconbg/starGrid")
if curSelectHero or curHeroCompoundData then
local heroConfig = curSelectHero and curSelectHero.heroConfig or curHeroCompoundData.config
Util.GetGameObject(go.transform, "nameText"):GetComponent("Text").text = GetLanguageStrById(heroConfig.ReadingName)
go:SetActive(true)
proImage:SetActive(true)
iconDefault:SetActive(false)
addBtnImage:SetActive(false)
frame:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroConfig.Quality, heroConfig.Star))
proImage:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
SetHeroStars(this.spLoader, starGrid, heroConfig.Star,1,nil,-15.3)
if curSelectHero and curSelectHero.heroConfig then
num:GetComponent("Text").text=string.format("<color=#00FF06>%s/%s</color>",1,1)
--LogGreen("curSelectHero.icon:"..curSelectHero.icon)
icon:GetComponent("Image").sprite=this.spLoader:LoadSprite(curSelectHero.icon)
else
icon:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon))
num:GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>",0,1)
end
Util.AddOnceClick(addBtn, function()
if not curSelectHero then return end
curSelectUpStarData=nil
curSelectUpStarGo=go
local curShowHeroListData=this.SetShowHeroListData(upStarConsumeMaterial,curHeroCompoundData.haveHeroList3[1],true)
--参数1 显示的herolist 2 3 升当前星的规则 4 打开RoleUpStarListPanel的界面
UIManager.OpenPanel(UIName.CompoundHeroFirstUpStarListPanel,curShowHeroListData,this,curSelectHero)
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 = this.spLoader: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 = this.spLoader:LoadSprite(GetResourcePath(heroData.config.Icon))
Util.GetGameObject(go.transform, "posIcon"):SetActive(false)--:GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.professionIcon)
Util.GetGameObject(go.transform, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.config.PropertyName))
local formationMask = Util.GetGameObject(go.transform, "formationMask")
formationMask:SetActive(false)--(heroData.isFormation ~= "" and heroData.isFormation ~= Language[10410]) or heroData.lockState == 1)
local starGrid = Util.GetGameObject(go.transform, "star")
SetHeroStars(this.spLoader, 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")
Util.GetGameObject(go.transform, "Text"):GetComponent("Text").text = SubString2(GetLanguageStrById(heroData.config.ReadingName),8)
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
local isShowRed = true
for k, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroRankupConfig)) do
if v.Star == heroData.config.Star and v.LimitStar == heroData.config.Star and v.OpenStar == heroData.config.Star + 1 then
upStarRankUpConfig = v
break
end
end
if upStarRankUpConfig and HarmonyManager.GetSingleAdditions(HarmonyAddType.AddLv) < upStarRankUpConfig.LimitHongmengLevel then -- 鸿蒙阵神将共鸣等级
isShowRed = false
end
Util.GetGameObject(go.transform, "redPoint"):SetActive(LengthOfTable(heroData.haveHeroList2) >= heroData.needNum and isShowRed)
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)
Util.AddLongPressClick(cardBtn, function()
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroData.config.Id, heroData.star)
end, 0.5)
end
function this.Compound()
if not curSelectHero or (curSelectHero and not curSelectHero.heroConfig) then
PopupTipPanel.ShowTip(Language[10415])
return
end
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
if HarmonyManager.GetSingleAdditions(HarmonyAddType.AddLv) < upStarRankUpConfig.LimitHongmengLevel then -- 鸿蒙阵神将共鸣等级
PopupTipPanel.ShowTip("鸿蒙阵等级需达到"..upStarRankUpConfig.LimitHongmengLevel)
return
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
BagManager.SetDropIsSHowEquipPrint(false)
UIManager.OpenPanel(UIName.RewardItemPopup, msg, 1, function ()
this.DeleteUpStarMaterials()
end)
else
this.DeleteUpStarMaterials()
end
end)
end)
-- 进阶音效
PlaySoundWithoutClick(SoundConfig.Sound_Recruit3)
else
PopupTipPanel.ShowTip(Language[10415])
end
end
--扣除升星 消耗的材料 更新英雄数据
function this.DeleteUpStarMaterials()
HeroManager.UpdateSingleHeroDatas(curSelectHero.dynamicId,nil,curSelectHero.star+1,nil,upStarRankUpConfig.Id,true)
HeroManager.UpdateSingleHeroSkillData(curSelectHero.dynamicId)
--本地数据删除材料英雄
for i = 1, #upStarConsumeMaterial do
--LogGreen("DeleteHeroDatas "..#upStarConsumeMaterial[i])
for j = 1, #upStarConsumeMaterial[i] do
--LogGreen("DeleteHeroDatas "..upStarConsumeMaterial[i][j])
end
HeroManager.DeleteHeroDatas(upStarConsumeMaterial[i])
end
--刷新界面
this.ShowCurrPosHeroCompound2()
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
tabImage:GetComponent("Image").sprite = this.spLoader: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()
this.spLoader:Destroy()
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) and configInfo.Hide == 0 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)
if curSelectHeroConfig and curSelectHeroConfig.config and curSelectHeroConfig.config.Id == curHeroCompoundData.config.Id then
curSelectHeroConfig = curHeroCompoundData
end
-- --LogGreen("curHeroCompoundData.needNum "..curHeroCompoundData.needNum.." "..LengthOfTable(curHeroCompoundData.haveHeroList2))
table.insert(allCompoundHeroConFigData,curHeroCompoundData)
end
end
table.sort(allCompoundHeroConFigData, function(a,b)
local lengthA = LengthOfTable(a.haveHeroList2)
local lengthB = LengthOfTable(b.haveHeroList2)
if ((a.needNum == lengthA) and (b.needNum == lengthB)) or ((a.needNum ~= lengthA) and (b.needNum ~= lengthB)) then
if a.config.Star == b.config.Star then
return a.config.Id < b.config.Id
else
return a.config.Star < b.config.Star
end
else
return a.needNum == lengthA and not b.needNum ~= lengthB
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] or curHeroCompoundData.config
this.ShowTitleData(curHeroCompoundData)
this.UpdateFirstHeroUpStarData(curHeroCompoundData)
this.UpdateHeroUpStarData(curHeroCompoundData)
else
curSelectHero = nil
this.ShowTitleData(nil)
this.UpdateFirstHeroUpStarData(nil)
this.UpdateHeroUpStarData(nil)
end
end
function this.GetNeedHeroName(heroRankUpGroup)
if curSelectHero then
local curConFig = curSelectHero.heroConfig and curSelectHero.heroConfig or curSelectHero
if heroRankUpGroup.Issame == 1 then --需要同名卡
return GetLanguageStrById(curConFig.ReadingName)
end
if heroRankUpGroup.IsId > 0 then --需要指定id
return GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.HeroConfig,heroRankUpGroup.IsId).ReadingName)
end
if heroRankUpGroup.IsSameClan == 1 then --需要是否同系
return string.format(Language[10416],heroRankUpGroup.StarLimit)
end
else
return ""
end
end
return this