miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/RoleUpStarLayout.lua

517 lines
27 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
RoleUpStarLayout = Inherit(BasePanel)
local this = RoleUpStarLayout
2020-11-03 15:17:48 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local heroSkinConfig = ConfigManager.GetConfig(ConfigName.HeroSkin)
local isUpStarMaterials=true--升星 材料是否充足
local curSelectUpStarData--当前选择升星坑位的数据
local curSelectUpStarGo--当前选择升星坑位的预设
local upStarConsumeMaterial={}--升星消耗的英雄组 {{1坑位英雄信息}{2坑位英雄信息}{}}
local upStarMaterialIsAll={}--升星消耗的英雄组是否满足 {{1满足}{2不满足}{}}
local isHeroUpStar=false--是否可升星
local upStarRankUpConfig={}--即将要升星的数据
local curStarRankUpConfig={}--当前升星的数据
local curHeroData--当前英雄信息
local parent = {}
local upStarPreList = {}
local heroDatas = {}
local isUpZhen = false
local allAddProVal = {}
local allHeroTeamAddProVal = {}
function RoleUpStarLayout:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = RoleUpStarLayout })
return b
end
2020-11-03 15:17:48 +08:00
--初始化组件(用于子类重写)
function RoleUpStarLayout:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
this.upStar=Util.GetGameObject(self.gameObject,"upStar")
this.noUpStarText=Util.GetGameObject(self.gameObject,"noUpStarText")
2020-11-03 15:17:48 +08:00
this.upStarPre=Util.GetGameObject(this.upStar,"upStarPre")
this.upStarGrid=Util.GetGameObject(this.upStar,"grid")
this.upStarBtn=Util.GetGameObject(this.upStar,"btns/upStarBtn")
this.upStarBtnRedPoint=Util.GetGameObject(this.upStar,"btns/upStarBtn/redPoint")
this.goldBtn=Util.GetGameObject(this.upStar,"goldGrid/gold")
this.goldText=Util.GetGameObject(this.upStar,"goldGrid/gold/Text"):GetComponent("Text")
this.goldImage=Util.GetGameObject(this.upStar,"goldGrid/gold")
this.gold2Btn=Util.GetGameObject(this.upStar,"goldGrid/gold2")
this.gold2Text=Util.GetGameObject(this.upStar,"goldGrid/gold2/Text"):GetComponent("Text")
this.gold2Image=Util.GetGameObject(this.upStar,"goldGrid/gold2")
this.roleUpStarLayoutTip=Util.GetGameObject(this.upStar,"tip"):GetComponent("Text")
this.roleUpStarRedPoint=Util.GetGameObject(self.gameObject,"rolePanel/btnList/btnUpStar/redPoint")
2020-11-03 15:17:48 +08:00
this.goCompoundHero=Util.GetGameObject(this.upStar.transform, "goCompoundHero")
2021-03-02 16:53:12 +08:00
Util.GetGameObject(this.upStar.transform, "goCompoundHero/Text"):GetComponent("Text").text = Language[11837]
2020-11-03 15:17:48 +08:00
--升星属性
this.curStarGrid = Util.GetGameObject(this.upStar.transform, "upStarProInfo/curStarGrid")
this.nextStarGrid = Util.GetGameObject(this.upStar.transform, "upStarProInfo/nextStarGrid")
this.skillInfoGrid = Util.GetGameObject(this.upStar.transform, "upStarProInfo/skillInfo")
this.skillInfoGrid:SetActive(false)
this.atkPro_UpStar=Util.GetGameObject(self.gameObject,"upStar/upStarProInfo/pro/atk")
this.hpPro_UpStar=Util.GetGameObject(self.gameObject,"upStar/upStarProInfo/pro/hp")
this.phyDef_UpStar=Util.GetGameObject(self.gameObject,"upStar/upStarProInfo/pro/phyDef")
this.magDef_UpStar=Util.GetGameObject(self.gameObject,"upStar/upStarProInfo/pro/magDef")
this.lv_UpStar=Util.GetGameObject(self.gameObject,"upStar/upStarProInfo/pro/lv/proValue"):GetComponent("Text")
this.nextlv_UpStar=Util.GetGameObject(self.gameObject,"upStar/upStarProInfo/pro/lv/nextproValue"):GetComponent("Text")
this.help=Util.GetGameObject(self.gameObject,"upStar/btns/help")
this.heroSource = Util.GetGameObject(self.gameObject,"upStar/btns/heroSource")
2020-11-03 15:17:48 +08:00
end
--绑定事件用于子类重写s
function RoleUpStarLayout:BindEvent()
Util.AddOnceClick(this.heroSource, function()
PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout = true
2021-07-01 18:12:20 +08:00
PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout2 = true
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,curHeroData.heroConfig.Id)
end)
2020-11-03 15:17:48 +08:00
--升星
2021-04-19 18:05:15 +08:00
Util.AddOnceClick(this.upStarBtn, function()
2020-11-03 15:17:48 +08:00
self:StarUpClick()
end)
--前往化虚坛
Util.AddClick(this.goCompoundHero, function()
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.COMPOUND_HERO) then
2021-04-25 14:20:07 +08:00
JumpManager.GoJump(750000)
2020-11-03 15:17:48 +08:00
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.COMPOUND_HERO))
end
end)
Util.AddClick(this.help, function()
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.JinJieYuLan,curHeroData)
end)
2020-11-03 15:17:48 +08:00
end
--添加事件监听(用于子类重写)
function RoleUpStarLayout:AddListener()
2021-04-20 20:59:43 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.UpdateHeroUpStarMaterialShow,self)
2020-11-03 15:17:48 +08:00
end
--移除事件监听(用于子类重写)
function RoleUpStarLayout:RemoveListener()
2021-04-20 20:59:43 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,this.UpdateHeroUpStarMaterialShow,self)
2020-11-03 15:17:48 +08:00
end
function RoleUpStarLayout:OnShow()
self.gameObject:SetActive(true)
2021-07-01 18:12:20 +08:00
if PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout2 then
PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout = true
PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout2 = true
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,curHeroData.heroConfig.Id)
end
end
function RoleUpStarLayout:SetData(_sortinglayer,_parent,_curHerodata,_isUpZhen,_heroDatas)
self.gameObject:SetActive(true)
2020-11-03 15:17:48 +08:00
this.sortingOrder = _sortinglayer
curHeroData = _curHerodata
if curHeroData.heroConfig.MaxRank > 5 then
this.help.gameObject:SetActive(true)
this.heroSource.gameObject:SetActive(true)
else
this.help.gameObject:SetActive(false)
this.heroSource.gameObject:SetActive(false)
end
2020-11-03 15:17:48 +08:00
parent = _parent
heroDatas = _heroDatas
isUpZhen = _isUpZhen
this:GetCurHeroUpLvOrUpStarSData()
this:UpdateHeroUpStarData()--进阶
end
--更新英雄进阶数据
function RoleUpStarLayout:UpdateHeroUpStarData()
2020-11-03 15:17:48 +08:00
--进阶材料
this:UpdateHeroUpStarMaterialShow()
allHeroTeamAddProVal = {}
2020-11-03 15:17:48 +08:00
--计算面板属性
if isUpZhen then
local formationList = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(formationList.teamHeroInfos,curHeroData.dynamicId)
2020-11-03 15:17:48 +08:00
allAddProVal = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false,nil,nil,true,allHeroTeamAddProVal)
else
allAddProVal = HeroManager.CalculateHeroAllProValList(1,curHeroData.dynamicId,false)
end
--进阶属性提升
if upStarRankUpConfig and upStarRankUpConfig.Id then
this:UpdateHeroUpStarProUpShow()
end
--进阶吞英雄条件
Util.ClearChild(this.upStarGrid.transform)
local curUpStarData= HeroManager.GetHeroCurUpStarInfo(curHeroData.dynamicId)
if curUpStarData and #curUpStarData>0 then
this.upStar:SetActive(true)
this.noUpStarText:SetActive(false)
parent.talentTipStrGo:SetActive(true)
upStarConsumeMaterial={}
upStarMaterialIsAll = {}
upStarPreList = {}
this.goCompoundHero:SetActive(curHeroData.star == 4 or curHeroData.star == 5)
for i = 1, #curUpStarData do
local go=newObject(this.upStarPre)
go.transform:SetParent(this.upStarGrid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition=Vector3.zero;
go:SetActive(true)
go.transform.name = "upStarPre"..i
upStarPreList[i] = go
upStarConsumeMaterial[i]={}
upStarMaterialIsAll[i]=2
Util.GetGameObject(go.transform, "iconbg/proImage"):SetActive(false)
if curUpStarData[i].upStarMaterialsData.Issame==1 or curUpStarData[i].upStarMaterialsData.IsId>0 then
Util.GetGameObject(go.transform,"iconDefault"):SetActive(false)
Util.GetGameObject(go.transform,"icon"):SetActive(true)
Util.GetGameObject(go.transform, "iconbg/proImage"):SetActive(true)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
2020-11-03 15:17:48 +08:00
if curUpStarData[i].upStarMaterialsData.Issame==1 then
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(curHeroData.heroConfig.Icon))
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(curHeroData.heroConfig.Quality, curUpStarData[i].upStarMaterialsData.StarLimit))
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
2020-11-03 15:17:48 +08:00
elseif curUpStarData[i].upStarMaterialsData.IsId>0 then
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, curUpStarData[i].upStarMaterialsData.IsId)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon))
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroConfig.Quality, curUpStarData[i].upStarMaterialsData.StarLimit))
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
2020-11-03 15:17:48 +08:00
end
else
if curUpStarData[i].upStarMaterialsData.IsSameClan ==1 then
Util.GetGameObject(go.transform, "iconbg/proImage"):SetActive(true)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
2020-11-03 15:17:48 +08:00
end
Util.GetGameObject(go.transform,"iconDefault"):SetActive(true)
Util.GetGameObject(go.transform,"icon"):SetActive(false)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(nil,curUpStarData[i].upStarMaterialsData.StarLimit))
2020-11-03 15:17:48 +08:00
--
end
local upStarHeroListData=HeroManager.GetUpStarHeroListData(curUpStarData[i].upStarMaterialsData.Id,curHeroData)
if upStarHeroListData.state>0 then
Util.GetGameObject(go.transform,"add/add"):SetActive(true)
else
Util.GetGameObject(go.transform,"add/add"):SetActive(false)
end
Util.GetGameObject(go.transform,"num"):GetComponent("Text").text=string.format("<color=#FF0000FF>%s/%s</color>",0,curUpStarData[i].upStarData[4])
2021-04-21 13:12:04 +08:00
SetHeroStars(this.spLoader, Util.GetGameObject(go.transform, "iconbg/starGrid"), curUpStarData[i].upStarMaterialsData.StarLimit,1,nil,-15.3)
2020-11-03 15:17:48 +08:00
local addBtn=Util.GetGameObject(go.transform,"add")
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,curUpStarData[i].upStarMaterialsData,curUpStarData[i].upStarData,this,upStarConsumeMaterial[i],curHeroData)
end)
end
else
this.upStar:SetActive(false)
this.noUpStarText:SetActive(true)
parent.talentTipStrGo:SetActive(false)
end
self:AutoSelectUpStarHeroList(curUpStarData)
end
--获取当前英雄的下一突破 和 升星 静态数据
function RoleUpStarLayout:GetCurHeroUpLvOrUpStarSData()
2020-11-03 15:17:48 +08:00
isHeroUpStar = false
upStarRankUpConfig = {}
local heroRankUpConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
for i, v in ConfigPairs(heroRankUpConfig) do
if v.Star==curHeroData.heroConfig.Star then--初始星级相等
if v.Show==2 then -- 2 升星
if v.Id ~= curHeroData.upStarId and curHeroData.star == v.LimitStar then
--Log("升星 "..v.Id)
upStarRankUpConfig=v
isHeroUpStar = true
end
end
end
end
end
--更新英雄进阶材料显示
function RoleUpStarLayout:UpdateHeroUpStarMaterialShow()
2020-11-03 15:17:48 +08:00
--进阶金币 妖壶条件
if upStarRankUpConfig then
isUpStarMaterials=true
local ConsumeMaterial=upStarRankUpConfig.ConsumeMaterial
if ConsumeMaterial and #ConsumeMaterial>=2 then
if ConsumeMaterial[1][2]>0 then
this.goldImage:SetActive(true)
2021-04-21 13:12:04 +08:00
this.goldImage:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[ConsumeMaterial[1][1]].ResourceID))
2020-11-03 15:17:48 +08:00
if BagManager.GetItemCountById(ConsumeMaterial[1][1])<ConsumeMaterial[1][2] then
isUpStarMaterials=false
this.goldText.text=string.format("<color=#FF0000FF>%s</color>",ConsumeMaterial[1][2])
else
this.goldText.text=string.format("<color=#FFFFFFFF>%s</color>",ConsumeMaterial[1][2])
end
Util.AddOnceClick(this.goldBtn,function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,ConsumeMaterial[1][1])
end)
else
this.goldImage:SetActive(false)
end
if ConsumeMaterial[2][2]>0 then
this.gold2Image:SetActive(true)
2021-04-21 13:12:04 +08:00
this.gold2Image:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[ConsumeMaterial[2][1]].ResourceID))
2020-11-03 15:17:48 +08:00
if BagManager.GetItemCountById(ConsumeMaterial[2][1])<ConsumeMaterial[2][2] then
isUpStarMaterials=false
this.gold2Text.text=string.format("<color=#FF0000FF>%s</color>",ConsumeMaterial[2][2])
else
this.gold2Text.text=string.format("<color=#FFFFFFFF>%s</color>",ConsumeMaterial[2][2])
end
Util.AddOnceClick(this.gold2Btn,function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,ConsumeMaterial[2][1])
end)
else
this.gold2Image:SetActive(false)
end
end
end
end
--进阶属性提升
function RoleUpStarLayout:UpdateHeroUpStarProUpShow()
2020-11-03 15:17:48 +08:00
if upStarRankUpConfig and upStarRankUpConfig.Id then
local size = Vector2.New (45,45)
2021-04-21 13:12:04 +08:00
SetHeroStars(this.spLoader, this.curStarGrid, curHeroData.star,2,size,-9)
local nextStarPos = Vector3.New(0,0,0)
if curHeroData.star + 1 == 10 then nextStarPos = Vector3.New(0,-18.65,0) end
2021-04-21 13:12:04 +08:00
SetHeroStars(this.spLoader, this.nextStarGrid, curHeroData.star + 1,2,size,-9)
local nextStarGridGo = Util.GetGameObject(this.nextStarGrid,"starGrid(Clone)")
if nextStarGridGo then
nextStarGridGo.transform.localPosition = nextStarPos
end
2020-11-03 15:17:48 +08:00
--this.curLvEnd.text = HeroManager.GetCurHeroStarLvEnd(1,curHeroData)
--this.nextLvEnd.text = HeroManager.GetCurHeroStarLvEnd(2,curHeroData,curHeroData.breakId,upStarRankUpConfig.Id)
local nextUpStarConFig = ConfigManager.GetConfigData(ConfigName.HeroRankupConfig,upStarRankUpConfig.Id)
local nextProUpVal = 0
if nextUpStarConFig then nextProUpVal = nextUpStarConFig.PropertiesDisplay end
--this.proUpVal.text = GetPropertyFormatStr(2, nextProUpVal)
--this.UpdateHeroUpStarProUpSkillShow(this.skillInfoGrid,self:NextStarUpSkillTabs())
local nextallAddProVal={}
if isUpZhen then
local formationList = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
-- local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(formationList.teamHeroInfos,curHeroData.dynamicId)
nextallAddProVal = HeroManager.CalculateHeroAllProValList(2,curHeroData.dynamicId,false,curHeroData.breakId,upStarRankUpConfig.Id,true,allHeroTeamAddProVal)
else
nextallAddProVal = HeroManager.CalculateHeroAllProValList(2,curHeroData.dynamicId,false,curHeroData.breakId,upStarRankUpConfig.Id)
end
2020-11-03 15:17:48 +08:00
this:ProShow(this.atkPro_UpStar,allAddProVal,HeroProType.Attack,nextallAddProVal)
this:ProShow(this.hpPro_UpStar,allAddProVal,HeroProType.Hp,nextallAddProVal)
this:ProShow(this.phyDef_UpStar,allAddProVal,HeroProType.PhysicalDefence,nextallAddProVal)
this:ProShow(this.magDef_UpStar,allAddProVal,HeroProType.MagicDefence,nextallAddProVal)
this.lv_UpStar.text= HeroManager.GetCurHeroStarLvEnd(1,curHeroData)
this.nextlv_UpStar.text= HeroManager.GetCurHeroStarLvEnd(2,curHeroData,curHeroData.breakId,upStarRankUpConfig.Id)
end
end
function RoleUpStarLayout:ProShow(go,allAddProVal,HeroProType,nextallAddProVal)
2020-11-03 15:17:48 +08:00
local curProSConFig = ConfigManager.GetConfigData(ConfigName.PropertyConfig,HeroProType)
2021-01-26 17:08:39 +08:00
Util.GetGameObject(go,"proName"):GetComponent("Text").text = GetLanguageStrById(curProSConFig.Info)..""
2020-11-03 15:17:48 +08:00
Util.GetGameObject(go,"proValue"):GetComponent("Text").text = allAddProVal[HeroProType]
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(PropertyTypeIconDef[HeroProType])
2020-11-03 15:17:48 +08:00
if nextallAddProVal then
Util.GetGameObject(go,"nextproValue"):GetComponent("Text").text = nextallAddProVal[HeroProType]
end
end
--升星选择祭品后刷新界面
function RoleUpStarLayout:AutoSelectUpStarHeroList(_curUpStarData)
2020-11-03 15:17:48 +08:00
local curUpStarData= _curUpStarData
if curUpStarData and #curUpStarData>0 then
for i = 1, #curUpStarData do
curSelectUpStarData=curUpStarData[i]
curSelectUpStarGo=upStarPreList[i]
local upStarHeroListData=HeroManager.GetUpStarHeroListData(curUpStarData[i].upStarMaterialsData.Id,curHeroData)
local curSelectHeroList = {}
if curUpStarData[i].upStarMaterialsData.Issame ==1
or curUpStarData[i].upStarMaterialsData.IsId > 0
or (curUpStarData[i].upStarMaterialsData.IsSameClan == 1
and curUpStarData[i].upStarMaterialsData.StarLimit == 3
and curHeroData.heroConfig.Qualiy ~= 3) then
if LengthOfTable(upStarHeroListData.heroList) >= curUpStarData[i].upStarData[4] then
for i = 1, curUpStarData[i].upStarData[4] do
2021-04-19 13:46:24 +08:00
if upStarHeroListData.heroList[i].type == RoleUpStarMatType.item or upStarHeroListData.heroList[i].type == RoleUpStarMatType.hero and upStarHeroListData.heroList[i].lockState == 0 and upStarHeroListData.heroList[i].isFormation == ""
2021-01-26 14:47:01 +08:00
and (not HarmonyManager.IsChangeColor(upStarHeroListData.heroList[i].dynamicId)) and (not HarmonyManager:IsEnvoy(upStarHeroListData.heroList[i].dynamicId)) then
2020-11-03 15:17:48 +08:00
table.insert(curSelectHeroList,upStarHeroListData.heroList[i])
end
end
self:UpdateUpStarPosHeroData(curSelectHeroList)
end
end
end
end
--进阶红点
local upStarRedPointState = HeroManager.IsShowUpStarRedPoint(curHeroData)
2020-11-07 16:41:25 +08:00
this.upStarBtnRedPoint:SetActive(upStarRedPointState)
parent:CheckRedPointType(2,upStarRedPointState)
2020-11-03 15:17:48 +08:00
end
--刷新当前升星坑位英雄的信息
function RoleUpStarLayout:UpdateUpStarPosHeroData(curSelectHeroList)
2020-11-03 15:17:48 +08:00
if LengthOfTable(curSelectHeroList)<curSelectUpStarData.upStarData[4] then
upStarMaterialIsAll[curSelectUpStarData.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),curSelectUpStarData.upStarData[4])
else
upStarMaterialIsAll[curSelectUpStarData.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),curSelectUpStarData.upStarData[4])
end
local curUpStarConsumeMaterial={}
for i, v in pairs(curSelectHeroList) do
2021-04-19 13:46:24 +08:00
table.insert(curUpStarConsumeMaterial,v)
2020-11-03 15:17:48 +08:00
end
upStarConsumeMaterial[curSelectUpStarData.upStarData[2]]=curUpStarConsumeMaterial
end
--分析设置升星界面显示的英雄list数据 如果当前升星材料的坑位的英雄数据与 以其他坑位有重合并且选择上的英雄不显示 如果是当前坑位显示的英雄显示对勾
function RoleUpStarLayout:SetShowHeroListData(upStarConsumeMaterial,curHeroList)--1 消耗的总消耗组 2 当前坑位可选择的所有英雄
2020-11-03 15:17:48 +08:00
--Log("#curHeroList "..#curHeroList)
local curEndShowHeroListData2={}
for i = 1, #curHeroList do
table.insert(curEndShowHeroListData2,curHeroList[i])
end
local curEndShowHeroListData={}
for i, v in pairs(curEndShowHeroListData2) do
v.isSelect=2
table.insert(curEndShowHeroListData,v)
end
for j = 1, #upStarConsumeMaterial do
if upStarConsumeMaterial[j] and #upStarConsumeMaterial[j]>0 then
for k = 1, #upStarConsumeMaterial[j] do
if j==curSelectUpStarData.upStarData[2] then--curSelectUpStarData 当前坑位选择的英雄信息
for _, v in pairs(curEndShowHeroListData) do
2021-04-19 13:46:24 +08:00
if v.type == RoleUpStarMatType.hero and v.dynamicId==upStarConsumeMaterial[j][k].dynamicId then
v.isSelect=1
2021-04-20 19:58:07 +08:00
elseif v.type == RoleUpStarMatType.item and v.id==upStarConsumeMaterial[j][k].id and v.index==upStarConsumeMaterial[j][k].index then
2020-11-03 15:17:48 +08:00
v.isSelect=1
end
end
else
for i, v in pairs(curEndShowHeroListData) do
2021-04-19 13:46:24 +08:00
if v.type == RoleUpStarMatType.hero and v.dynamicId==upStarConsumeMaterial[j][k].dynamicId then
curEndShowHeroListData[i] = nil
2021-04-20 19:58:07 +08:00
elseif v.type == RoleUpStarMatType.item and v.id==upStarConsumeMaterial[j][k].id and v.index==upStarConsumeMaterial[j][k].index then
2020-11-03 15:17:48 +08:00
curEndShowHeroListData[i] = nil
end
end
end
end
end
end
local curList={}
for _, v in pairs(curEndShowHeroListData) do
table.insert(curList,v)
end
return curList
end
--进阶按钮点击事件处理
function RoleUpStarLayout:StarUpClick()
2021-01-14 21:11:53 +08:00
if (not HarmonyManager.IsInfo(curHeroData.dynamicId)) and (not HarmonyManager:IsEnvoy(curHeroData.dynamicId)) then
-- body curHeroData
-- print("1111111111",1111111111,tostring(HarmonyManager.IsInfo(curHeroData.dynamicId)),tostring(HarmonyManager:IsEnvoy(curHeroData.dynamicId)))
2021-01-26 10:33:08 +08:00
if curHeroData.oriLv>=HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11788])
2021-01-14 21:11:53 +08:00
return
end
-- elseif then
-- -- body
-- print("2222222",1111111111)
-- if curHeroData.lv>=HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then
2021-02-20 16:55:28 +08:00
-- PopupTipPanel.ShowTip("当前培养已满")
2021-01-14 21:11:53 +08:00
-- return
-- end
2020-11-03 15:17:48 +08:00
end
2021-01-14 21:11:53 +08:00
2020-11-03 15:17:48 +08:00
if curHeroData.lv<upStarRankUpConfig.LimitLevel then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11789]..upStarRankUpConfig.LimitLevel)
2020-11-03 15:17:48 +08:00
return
end
local isUpStarMaterialsHero=true
for i = 1, #upStarMaterialIsAll do
if upStarMaterialIsAll[i]==2 then
isUpStarMaterialsHero=false
end
end
if isUpStarMaterials and isUpStarMaterialsHero then
NetManager.HeroUpStarEvent(curHeroData.dynamicId,upStarConsumeMaterial ,function (msg)
UIManager.OpenPanel(UIName.RoleUpStarSuccessPanel,curHeroData,upStarRankUpConfig.Id,upStarRankUpConfig.OpenLevel,function ()
local dropItemTabs = BagManager.GetTableByBackDropData(msg)
if #dropItemTabs > 0 then
BagManager.SetDropIsSHowEquipPrint(false)
UIManager.OpenPanel(UIName.RewardItemPopup, msg, 1, function ()
self:DeleteUpStarMaterials()
end)
else
self:DeleteUpStarMaterials()
end
2020-12-21 15:41:31 +08:00
CheckRedPointStatus(RedPointType.ShengXingYouLi)
2020-11-03 15:17:48 +08:00
end)
end)
-- 进阶音效
PlaySoundWithoutClick(SoundConfig.Sound_Recruit3)
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10415])
2020-11-03 15:17:48 +08:00
end
end
--扣除升星 消耗的材料 更新英雄数据
function RoleUpStarLayout:DeleteUpStarMaterials()
HeroManager.UpdateSingleHeroDatas(curHeroData.dynamicId,curHeroData.oriLv,curHeroData.star+1,nil,upStarRankUpConfig.Id,true)
2020-11-03 15:17:48 +08:00
HeroManager.UpdateSingleHeroSkillData(curHeroData.dynamicId)
for i, v in pairs(heroDatas) do
if curHeroData == v then
curHeroData=HeroManager.GetSingleHeroData(curHeroData.dynamicId)
v=curHeroData
end
end
--本地数据删除材料英雄
2021-04-19 13:46:24 +08:00
local curDelHeroDids = {}
2020-11-03 15:17:48 +08:00
for i = 1, #upStarConsumeMaterial do
2021-04-19 13:46:24 +08:00
for j = 1, #upStarConsumeMaterial[i] do
if upStarConsumeMaterial[i][j].type == RoleUpStarMatType.hero then
table.insert(curDelHeroDids,upStarConsumeMaterial[i][j].dynamicId)
end
end
end
if curDelHeroDids and #curDelHeroDids > 0 then
HeroManager.DeleteHeroDatas(curDelHeroDids)
2020-11-03 15:17:48 +08:00
end
if HeroManager.heroListPanelProID ~= ProIdConst.All then
heroDatas = HeroManager.GetHeroDataByProperty(HeroManager.heroListPanelProID)
else
heroDatas = HeroManager.GetAllHeroDatas()
end
if UIManager.IsOpen(UIName.RoleInfoPanel) then--当界面存在时需要刷新当前界面
HeroManager.SortHeroDatas(heroDatas)
parent:OnOpen(curHeroData, heroDatas,isUpZhen)
parent:OnShow()
end
end
function RoleUpStarLayout:OnSortingOrderChange()
2020-11-03 15:17:48 +08:00
end
function RoleUpStarLayout:OnHide()
self.gameObject:SetActive(false)
2020-11-03 15:17:48 +08:00
end
function RoleUpStarLayout:OnClose()
upStarPreList = {}
2020-11-03 15:17:48 +08:00
end
function RoleUpStarLayout:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-11-03 15:17:48 +08:00
upStarPreList = {}
end
2021-04-21 13:12:04 +08:00
return this