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

391 lines
19 KiB
Lua
Raw Normal View History

2020-11-09 11:13:53 +08:00
require("Base/BasePanel")
this = Inherit(BasePanel)
local this = this
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
--初始化组件(用于子类重写)
function this:InitComponent(gameObject)
this.gameObject = gameObject
2020-11-09 15:04:48 +08:00
Util.GetGameObject(this.gameObject,"Image/Text"):GetComponent("Text").text = "神将觉醒"
Util.GetGameObject(this.gameObject,"Image (3)/Text"):GetComponent("Text").text = "觉醒要求"
Util.GetGameObject(this.gameObject,"tip"):GetComponent("Text").text = "觉醒后神将天赋会发生变化"
Util.GetGameObject(this.gameObject,"upStarBtn/Text"):GetComponent("Text").text = "觉 醒"
Util.GetGameObject(this.gameObject,"lvUp/Text"):GetComponent("Text").text = "等级上限:"
--天赋
this.talent1Image = Util.GetGameObject(this.gameObject,"talent/talent (1)"):GetComponent("Image")
this.talent1Progress = Util.GetGameObject(this.gameObject,"talent/talent (1)/progress"):GetComponent("Text")
this.talent2Image = Util.GetGameObject(this.gameObject,"talent/talent (2)"):GetComponent("Image")
this.talent2Progress = Util.GetGameObject(this.gameObject,"talent/talent (2)/progress"):GetComponent("Text")
2020-11-09 20:05:51 +08:00
this.talentBtn = Util.GetGameObject(this.gameObject,"talent/talentBtn")
2020-11-09 15:04:48 +08:00
this.curLvEnd = Util.GetGameObject(this.gameObject,"lvUp/curLvEnd"):GetComponent("Text")
this.nextLvEnd = Util.GetGameObject(this.gameObject,"lvUp/nextLvEnd"):GetComponent("Text")
--升星觉醒
this.upStarPre=Util.GetGameObject(this.gameObject,"upStarPre")
this.upStarGrid=Util.GetGameObject(this.gameObject,"grid")
this.upStarBtnRedPoint=Util.GetGameObject(this.gameObject,"upStarBtn/redPoint")
this.goldBtn=Util.GetGameObject(this.gameObject,"goldGrid/gold")
this.goldText=Util.GetGameObject(this.gameObject,"goldGrid/gold/Text"):GetComponent("Text")
this.goldImage=Util.GetGameObject(this.gameObject,"goldGrid/gold")
this.gold2Btn=Util.GetGameObject(this.gameObject,"goldGrid/gold2")
this.gold2Text=Util.GetGameObject(this.gameObject,"goldGrid/gold2/Text"):GetComponent("Text")
this.gold2Image=Util.GetGameObject(this.gameObject,"goldGrid/gold2")
this.upStarBtn=Util.GetGameObject(this.gameObject,"upStarBtn")
2020-11-09 11:13:53 +08:00
return this
end
--绑定事件(用于子类重写)
function this:BindEvent()
--升星
Util.AddClick(this.upStarBtn, function()
2020-11-09 15:04:48 +08:00
this.StarUpClick()
2020-11-09 11:13:53 +08:00
end)
end
--添加事件监听(用于子类重写)
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.UpdateHeroUpStarMaterialShow)
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,this.UpdateHeroUpStarMaterialShow)
end
function this:OnShow(_sortinglayer,_parent,_curHerodata,_isUpZhen,_heroDatas)
this.gameObject:SetActive(true)
this.sortingOrder = _sortinglayer
curHeroData = _curHerodata
parent = _parent
heroDatas = _heroDatas
isUpZhen = _isUpZhen
2020-11-09 15:04:48 +08:00
this.GetCurHeroUpLvOrUpStarSData()
this.UpdateHeroUpStarData()--进阶
2020-11-09 11:13:53 +08:00
end
--更新英雄进阶数据
2020-11-09 15:04:48 +08:00
function this.UpdateHeroUpStarData()
2020-11-09 11:13:53 +08:00
--进阶材料
2020-11-09 15:04:48 +08:00
this.UpdateHeroUpStarMaterialShow()
2020-11-09 11:13:53 +08:00
--进阶属性提升
2020-11-09 15:04:48 +08:00
this.curLvEnd.text= HeroManager.GetCurHeroStarLvEnd(1,curHeroData)
this.nextLvEnd.text= HeroManager.GetCurHeroStarLvEnd(2,curHeroData,curHeroData.breakId,upStarRankUpConfig.Id)
2020-11-09 20:05:51 +08:00
Util.AddOnceClick(this.talentBtn, function()
UIManager.OpenPanel(UIName.RoleAwakeTalentPopup,curHeroData.heroConfig)
end)
2020-11-09 11:13:53 +08:00
--进阶吞英雄条件
Util.ClearChild(this.upStarGrid.transform)
local curUpStarData= HeroManager.GetHeroCurUpStarInfo(curHeroData.dynamicId)
if curUpStarData and #curUpStarData>0 then
upStarConsumeMaterial={}
upStarMaterialIsAll = {}
upStarPreList = {}
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)
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
if curUpStarData[i].upStarMaterialsData.Issame==1 then
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(curHeroData.heroConfig.Icon))
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(curHeroData.heroConfig.Quality, curUpStarData[i].upStarMaterialsData.StarLimit))
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
elseif curUpStarData[i].upStarMaterialsData.IsId>0 then
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, curUpStarData[i].upStarMaterialsData.IsId)
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(heroConfig.Icon))
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroConfig.Quality, curUpStarData[i].upStarMaterialsData.StarLimit))
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
end
else
if curUpStarData[i].upStarMaterialsData.IsSameClan ==1 then
Util.GetGameObject(go.transform, "iconbg/proImage"):SetActive(true)
Util.GetGameObject(go.transform, "iconbg/proImage"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
end
Util.GetGameObject(go.transform,"iconDefault"):SetActive(true)
Util.GetGameObject(go.transform,"icon"):SetActive(false)
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(nil,curUpStarData[i].upStarMaterialsData.StarLimit))
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])
SetHeroStars(Util.GetGameObject(go.transform, "iconbg/starGrid"), curUpStarData[i].upStarMaterialsData.StarLimit,1,nil,-15.3)
local addBtn=Util.GetGameObject(go.transform,"add")
Util.AddOnceClick(addBtn, function()
curSelectUpStarData=curUpStarData[i]
curSelectUpStarGo=go
2020-11-09 15:04:48 +08:00
local curShowHeroListData=this.SetShowHeroListData(upStarConsumeMaterial,upStarHeroListData.heroList)
2020-11-09 11:13:53 +08:00
--参数1 显示的herolist 2 3 升当前星的规则 4 打开RoleUpStarListPanel的界面
UIManager.OpenPanel(UIName.RoleUpStarListPanel,curShowHeroListData,curUpStarData[i].upStarMaterialsData,curUpStarData[i].upStarData,this,upStarConsumeMaterial[i],curHeroData)
end)
end
end
2020-11-09 15:04:48 +08:00
this.AutoSelectUpStarHeroList(curUpStarData)
2020-11-09 11:13:53 +08:00
end
--获取当前英雄的下一突破 和 升星 静态数据
2020-11-09 15:04:48 +08:00
function this.GetCurHeroUpLvOrUpStarSData()
2020-11-09 11:13:53 +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
--更新英雄进阶材料显示
2020-11-09 15:04:48 +08:00
function this.UpdateHeroUpStarMaterialShow()
2020-11-09 11:13:53 +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)
this.goldImage:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(itemConfig[ConsumeMaterial[1][1]].ResourceID))
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)
this.gold2Image:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(itemConfig[ConsumeMaterial[2][1]].ResourceID))
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
--升星选择祭品后刷新界面
2020-11-09 15:04:48 +08:00
function this.AutoSelectUpStarHeroList(_curUpStarData)
2020-11-09 11:13:53 +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
if upStarHeroListData.heroList[i].lockState == 0 and upStarHeroListData.heroList[i].isFormation == "" then
table.insert(curSelectHeroList,upStarHeroListData.heroList[i])
end
end
2020-11-09 20:05:51 +08:00
this:UpdateUpStarPosHeroData(curSelectHeroList)
2020-11-09 11:13:53 +08:00
end
end
end
end
--进阶红点
local upStarRedPointState = HeroManager.IsShowUpStarRedPoint(curHeroData)
this.upStarBtnRedPoint:SetActive(upStarRedPointState)
parent:CheckRedPointType(2,upStarRedPointState)
end
--刷新当前升星坑位英雄的信息
2020-11-09 20:05:51 +08:00
function this:UpdateUpStarPosHeroData(curSelectHeroList)
2020-11-09 11:13:53 +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
table.insert(curUpStarConsumeMaterial,v.dynamicId)
end
upStarConsumeMaterial[curSelectUpStarData.upStarData[2]]=curUpStarConsumeMaterial
for i = 1, #upStarConsumeMaterial do
--Log("选择升星位置的英雄数量 "..#upStarConsumeMaterial[i])
if #upStarConsumeMaterial[i]>0 then
for j = 1, #upStarConsumeMaterial[i] do
--Log("选择升星位置的英雄都有谁 "..upStarConsumeMaterial[i][j])
end
end
end
end
--分析设置升星界面显示的英雄list数据 如果当前升星材料的坑位的英雄数据与 以其他坑位有重合并且选择上的英雄不显示 如果是当前坑位显示的英雄显示对勾
2020-11-09 15:04:48 +08:00
function this.SetShowHeroListData(upStarConsumeMaterial,curHeroList)--1 消耗的总消耗组 2 当前坑位可选择的所有英雄
2020-11-09 11:13:53 +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
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
table.insert(curList,v)
end
return curList
end
--进阶按钮点击事件处理
2020-11-09 15:04:48 +08:00
function this.StarUpClick()
2020-11-09 11:13:53 +08:00
if curHeroData.lv>=HeroManager.heroLvEnd[curHeroData.heroConfig.Id] then
PopupTipPanel.ShowTip(Language[11846])
return
end
if curHeroData.lv<upStarRankUpConfig.LimitLevel then
PopupTipPanel.ShowTip(Language[11851]..upStarRankUpConfig.LimitLevel)
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)
2020-11-09 20:05:51 +08:00
UIManager.OpenPanel(UIName.RoleAwakeSuccessPanel,curHeroData,upStarRankUpConfig.Id,upStarRankUpConfig.OpenLevel,function ()
2020-11-09 11:13:53 +08:00
local dropItemTabs = BagManager.GetTableByBackDropData(msg)
if #dropItemTabs > 0 then
BagManager.SetDropIsSHowEquipPrint(false)
UIManager.OpenPanel(UIName.RewardItemPopup, msg, 1, function ()
2020-11-09 15:04:48 +08:00
this.DeleteUpStarMaterials()
2020-11-09 11:13:53 +08:00
end)
else
2020-11-09 15:04:48 +08:00
this.DeleteUpStarMaterials()
2020-11-09 11:13:53 +08:00
end
end)
end)
-- 进阶音效
PlaySoundWithoutClick(SoundConfig.Sound_Recruit3)
else
2020-11-09 20:05:51 +08:00
PopupTipPanel.ShowTip("材料不足无法觉醒!")
2020-11-09 11:13:53 +08:00
end
end
--扣除升星 消耗的材料 更新英雄数据
2020-11-09 15:04:48 +08:00
function this.DeleteUpStarMaterials()
2020-11-09 11:13:53 +08:00
HeroManager.UpdateSingleHeroDatas(curHeroData.dynamicId,curHeroData.lv,curHeroData.star+1,curHeroData.breakId,upStarRankUpConfig.Id,true)
HeroManager.UpdateSingleHeroSkillData(curHeroData.dynamicId)
for i, v in pairs(heroDatas) do
if curHeroData == v then
curHeroData=HeroManager.GetSingleHeroData(curHeroData.dynamicId)
v=curHeroData
end
end
--本地数据删除材料英雄
for i = 1, #upStarConsumeMaterial do
HeroManager.DeleteHeroDatas(upStarConsumeMaterial[i])
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 this:OnSortingOrderChange()
end
function this:OnHide()
this.gameObject:SetActive(false)
end
function this:OnClose()
end
function this:OnDestroy()
upStarPreList = {}
end
return this