357 lines
17 KiB
Lua
357 lines
17 KiB
Lua
----- 神将合成 -----
|
|
local this = {}
|
|
local sortingOrder=0
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local curIndex = 0
|
|
local curNeedHero = {}
|
|
local curSelectHero = {}
|
|
local curSelectGO
|
|
local materidaIsCan = false
|
|
local tabs={}
|
|
local needHeros={}
|
|
function this:InitComponent(gameObject)
|
|
this.compoundBtn = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/compoundBtn")
|
|
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 = "请选择需要合成的神将"
|
|
for i = 1, 4 do
|
|
needHeros[i] = Util.GetGameObject(gameObject, "CompoundHeroPanel_Compound/Tabs/grid/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
|
|
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)
|
|
curSelectHero = nil
|
|
this.ShowTitleData(curSelectHero)
|
|
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(_heroData,_star)
|
|
if _heroData then
|
|
LogGreen("_heroData ".._heroData.icon)
|
|
this.compoundHero:SetActive(true)
|
|
this.compoundHeroTipText:SetActive(false)
|
|
local heroData=_heroData
|
|
local o = this.compoundHero
|
|
local bg=Util.GetGameObject(o,"Bg1"):GetComponent("Image")
|
|
local lv=Util.GetGameObject(o,"lv/Text"):GetComponent("Text")
|
|
local hp = Util.GetGameObject(o,"hpProgress/hp"):GetComponent("Image")
|
|
local hpPass = Util.GetGameObject(o,"hpProgress/hpPass"):GetComponent("Image")
|
|
local rage = Util.GetGameObject(o,"rageProgress/rage"):GetComponent("Image")
|
|
bg.sprite = Util.LoadSprite(GetHeroCardStarBg[_star])
|
|
Util.GetGameObject(o,"hpProgress").gameObject:SetActive(false)
|
|
Util.GetGameObject(o,"rageProgress").gameObject:SetActive(false)
|
|
local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
|
|
local pro=Util.GetGameObject(o,"Pro/Image"):GetComponent("Image")
|
|
local starGrid=Util.GetGameObject(o,"StarGrid")
|
|
local name=Util.GetGameObject(o,"Name/Text"):GetComponent("Text")
|
|
local yuanImage=Util.GetGameObject(o,"yuanImage")
|
|
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
|
|
local liveName = GetResourcePath(heroData.heroConfig.Live)
|
|
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroData.heroConfig.Id)
|
|
local scale = roleConfig.play_liveScale
|
|
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
|
|
live.texture = CardRendererManager.GetSpineTexture(1, liveName, Vector3.one * scale, livePos, true)
|
|
live.transform.localScale = Vector3.one
|
|
live.transform.localPosition = Vector3.zero
|
|
local zs = Util.GetGameObject(o, "zs")
|
|
local zsName = GetHeroCardStarZs[_star]
|
|
if zsName == "" then
|
|
zs:SetActive(false)
|
|
else
|
|
zs:SetActive(true)
|
|
zs:GetComponent("Image").sprite = Util.LoadSprite(zsName)
|
|
end
|
|
yuanImage:SetActive(heroData.createtype == 1)
|
|
lv.text=heroData.lv
|
|
fg.sprite = Util.LoadSprite(GetHeroCardStarFg[_star])
|
|
pro.sprite=Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
|
|
SetCardStars(starGrid,_star)
|
|
Util.GetGameObject(o,"UI_Effect_jinkuang_KaPai").gameObject:SetActive(false)
|
|
name.text=heroData.heroConfig.ReadingName
|
|
local curHeroHpVal = FormationManager.GetFormationHeroHp(this.curFormationIndex,_heroData.dynamicId)
|
|
hp.fillAmount = curHeroHpVal or 1
|
|
hpPass.fillAmount = curHeroHpVal or 1
|
|
rage.fillAmount = 0.5
|
|
else
|
|
LogGreen("_data nil ")
|
|
this.compoundHero:SetActive(false)
|
|
this.compoundHeroTipText:SetActive(true)
|
|
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 curSelectHero and curSelectHero.config.Id == _heroData.config.Id then
|
|
choosed:SetActive(true)
|
|
curSelectGO = choosed
|
|
end
|
|
Util.AddOnceClick(cardBtn, function()
|
|
if curSelectHero and curSelectHero.config.Id == _heroData.config.Id then
|
|
choosed:SetActive(false)
|
|
curSelectHero = nil
|
|
curSelectGO = nil
|
|
this.SelectHeroShow(nil)
|
|
return
|
|
else
|
|
curSelectHero = heroData
|
|
choosed:SetActive(true)
|
|
if curSelectGO then
|
|
curSelectGO:SetActive(false)
|
|
end
|
|
curSelectGO = choosed
|
|
this.SelectHeroShow(curSelectHero)
|
|
end
|
|
end)
|
|
end
|
|
function this.Compound()
|
|
if compoundNum <= 0 then
|
|
PopupTipPanel.ShowTip(Language[10431])
|
|
return
|
|
end
|
|
if not materidaIsCan then
|
|
PopupTipPanel.ShowTip(Language[12193])
|
|
return
|
|
end
|
|
NetManager.ComplexTreasureRequest(curSelectEquip.equipType,curIndex,curSelectEquip.quantity,compoundNum,function(msg)
|
|
for i = 1, #msg.equipIds do
|
|
EquipTreasureManager.RemoveTreasureByIdDyn(msg.equipIds[i])
|
|
end
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
this.ShowCurrPosTreasures()
|
|
end)
|
|
end)
|
|
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()
|
|
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] = {}
|
|
--其后几位加数量
|
|
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] = {}
|
|
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[curNeedHeroData.dynamicId] then
|
|
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)
|
|
this.ShowTitleData(curHeroCompoundData.haveHeroList[1][1],curHeroCompoundData.star)
|
|
end
|
|
return this |