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

462 lines
24 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
RoleGodSoulLayout = Inherit(BasePanel)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
--初始化组件(用于子类重写)
function RoleGodSoulLayout:InitComponent()
self.spLoader = SpriteLoader.New()
self.closeBtn = Util.GetGameObject(self.gameObject,"mask")
self.help = Util.GetGameObject(self.gameObject,"bgdi/topLayout/help")
self.helpPosition = self.help:GetComponent("RectTransform").localPosition
self.curHeroName = Util.GetGameObject(self.gameObject,"bgdi/topLayout/name"):GetComponent("Text")
self.curHeroGo = Util.GetGameObject(self.gameObject,"bgdi/topLayout/itemPre/HeroPre")
self.godPre = Util.GetGameObject(self.gameObject,"godPre")
self.costPre = Util.GetGameObject(self.gameObject,"costPre")
self.heroPre = Util.GetGameObject(self.gameObject,"HeroPre")
self.singlePre = Util.GetGameObject(self.gameObject,"singlePre")
self.scroll = Util.GetGameObject(self.gameObject,"bgdi/scroll")
self.scrollPos = self.scroll:GetComponent("RectTransform").sizeDelta
self.effectMask = self.scroll:GetComponent("Image")
self.bgdi = Util.GetGameObject(self.gameObject,"bgdi")
self.bgdiPos = self.bgdi:GetComponent("RectTransform").sizeDelta
self.grid = Util.GetGameObject(self.gameObject,"bgdi/scroll/grid")
self.gridPos = self.grid:GetComponent("RectTransform").anchoredPosition
self.gridList = {}
self.effectbaijin = Util.GetGameObject(self.gameObject,"bgdi/topLayout/fx_zhuangbeijiemian2")
end
function RoleGodSoulLayout:OnSortingOrderChange()
Util.SetParticleSortLayer(self.bgdi,self.sortingOrder + 1)
end
--绑定事件(用于子类重写)
function RoleGodSoulLayout:BindEvent()
Util.AddClick(self.help, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.shenhun,self.helpPosition.x,self.helpPosition.y - 500)
end)
Util.AddClick(self.closeBtn, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function RoleGodSoulLayout:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Role.UpdateSodSoulLayout, self.SetData,self)
Game.GlobalEvent:AddEvent(GameEvent.Role.RefreshSodSoulLayoutEffectMask,self.RefreshSodSoulLayoutEffectMaskCallBack,self)
end
--移除事件监听(用于子类重写)
function RoleGodSoulLayout:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Role.UpdateSodSoulLayout, self.SetData,self)
Game.GlobalEvent:RemoveEvent(GameEvent.Role.RefreshSodSoulLayoutEffectMask,self.RefreshSodSoulLayoutEffectMaskCallBack,self)
end
function RoleGodSoulLayout:RefreshSodSoulLayoutEffectMaskCallBack()
self:SetMaskActive(true)
end
--界面打开时调用(用于子类重写)
function RoleGodSoulLayout:OnOpen(_curHerodata,_star)
self.curHeroData = _curHerodata
if self.curHeroData.dynamicId then
self.level = self.curHeroData.lv
self.star = self.curHeroData.star
self.addShow = true
self.heroConfig = self.curHeroData.heroConfig
else
if _star == 6 then
self.level = 145
elseif _star == 10 then
self.level = 255
elseif _star == 11 then
self.level = 330
else
self.level = 1
end
self.star = _star
self.lv = 0
self.addShow = false
self.heroConfig = self.curHeroData
end
end
function RoleGodSoulLayout:OnShow()
self.gameObject:SetActive(true)
self:SetData()
Util.SetParticleSortLayer(self.bgdi,self.sortingOrder + 1)
Util.SetParticleSortLayer(self.effectbaijin,self.sortingOrder + 1)
end
function RoleGodSoulLayout:SetData()
self:UpdateGodList()
self:SetHeroData(self.curHeroGo,self.curHeroData,true)
self.curHeroName.text = self.heroConfig.ReadingName
local scrollPos1 = 0
local bgdiPos1 = 175
for i = 1,#self.gridList do
scrollPos1 = scrollPos1 + GetPreferredHeight(self.gridList[i].go.transform)
end
bgdiPos1 = bgdiPos1 + scrollPos1
if bgdiPos1 > 1334 then
self.bgdiPos.y = 1334
self.scrollPos.y = 1334 - 180
else
self.bgdiPos.y = bgdiPos1
self.scrollPos.y = bgdiPos1 - 180
end
self.bgdi:GetComponent("RectTransform").sizeDelta = self.bgdiPos
self.scroll:GetComponent("RectTransform").sizeDelta = self.scrollPos
local pos = Vector3.New(self.gridPos.x,self.gridPos.y,self.gridPos.z)
for i = 1,self.lv - 1 do
pos.y = pos.y + GetPreferredHeight(self.gridList[i].go.transform)
end
local pos1 = self.grid:GetComponent("RectTransform").anchoredPosition
if pos1.y ~= pos.y then
self.grid:GetComponent("RectTransform").anchoredPosition = pos
end
end
function RoleGodSoulLayout:SetHeroData(heroGo,heroData,isCur)
local frame = Util.GetGameObject(heroGo,"frame"):GetComponent("Image")
local icon = Util.GetGameObject(heroGo,"icon"):GetComponent("Image")
local proIcon = Util.GetGameObject(heroGo,"proIcon"):GetComponent("Image")
local starGrid = Util.GetGameObject(heroGo,"star")
if self.addShow then
local star,starType = heroData.GetStar(1)
local starSize = Vector2.New(19.69,19.69)
local starScale = -8
if isCur then
local lv = Util.GetGameObject(heroGo,"lv/Text"):GetComponent("Text")
lv.text = heroData.lv
if starType == 3 then
starSize = Vector2.New(1,-16.28)
starScale = -13.77
elseif starType == 2 then
starSize = Vector2.New(60,60)
end
frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,self.star))
SetHeroFlyEffect(heroGo,self.spLoader,heroData.star,self.sortingOrder + 1,1,2)
else
if starType == 3 then
starSize = Vector2.New(0.65,-29.2)
starScale = -24.72
elseif starType == 2 then
starSize = Vector2.New(34.492,32.767)
end
frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
SetHeroFlyEffect(heroGo,self.spLoader,heroData.star,self.sortingOrder + 1,0.65,2)
end
proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
SetHeroIcon(self.spLoader,heroData,icon,heroData.heroConfig)
SetHeroStars(self.spLoader, starGrid, star,starType,starSize,starScale)
else
local lv = Util.GetGameObject(heroGo,"lv/Text"):GetComponent("Text")
lv.text = self.level
frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.Quality,self.star))
proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
SetHeroIcon(self.spLoader,heroData,icon,heroData)
SetHeroStars(self.spLoader, starGrid, self.star,1)
end
if not isCur then
local posIcon = Util.GetGameObject(heroGo,"posIcon"):GetComponent("Image")
posIcon.sprite = self.spLoader:LoadSprite(heroData.professionIcon)
end
end
function RoleGodSoulLayout:UpdateGodList()
if self.curHeroData.dynamicId then
self.lv = GodSoulManager.GetGodSoulLv(self.curHeroData.dynamicId)
else
self.lv = 0
end
self.godDatas = GodSoulManager.GetGodSoulDataByLv(self.heroConfig.Id,0)
if not self.gridList then
self.gridList = {}
end
for i = 1,math.max(#self.gridList,#self.godDatas) do
if not self.godDatas[i] then
self.gridList[i].go.gameObject:SetActive(false)
else
if not self.gridList[i] then
self.gridList[i] = {}
self.gridList[i].go = newObjToParent(self.singlePre,self.grid)
self.gridList[i].middle = Util.GetGameObject(self.gridList[i].go,"middle")
self.gridList[i].tip = Util.GetGameObject(self.gridList[i].go,"middle/Text"):GetComponent("Text")
self.gridList[i].godGrid = Util.GetGameObject(self.gridList[i].go,"bottom/godGrid")
self.gridList[i].godLvList = {}
self.gridList[i].costGrid = Util.GetGameObject(self.gridList[i].go,"middle/costGrid")
self.gridList[i].costList = {}
self.gridList[i].add = Util.GetGameObject(self.gridList[i].go,"add")
self.gridList[i].addImage = Util.GetGameObject(self.gridList[i].go,"icon")
self.gridList[i].red = Util.GetGameObject(self.gridList[i].add,"icon/red")
self.gridList[i].red.gameObject:SetActive(false)
self.gridList[i].bottom = Util.GetGameObject(self.gridList[i].go,"bottom")
self.gridList[i].des = Util.GetGameObject(self.gridList[i].go,"bottom/des"):GetComponent("Text")
self.gridList[i].upHero = Util.GetGameObject(self.gridList[i].go,"upHero")
self.gridList[i].upHeroList = {}
end
if self.addShow then
self.gridList[i].upHeroDataList = GodSoulManager.GetBindHeroDatasByLevel(self.curHeroData.dynamicId,i)
else
self.gridList[i].upHeroDataList = {}
end
self.gridList[i].go.gameObject:SetActive(true)
self:UpdataSingleGod2(i)
end
end
end
--index 等级
function RoleGodSoulLayout:UpdataSingleGod2(index)
self.gridList[index].middle.gameObject:SetActive(false)
for i = 1,math.max(#self.gridList[index].godLvList,index) do
if index < i then
self.gridList[index].godLvList[i].gameObject:SetActive(false)
else
if not self.gridList[index].godLvList[i] then
self.gridList[index].godLvList[i] = newObjToParent(self.godPre,self.gridList[index].godGrid)
end
self.gridList[index].godLvList[i].gameObject:SetActive(true)
local shenhun = Util.GetGameObject(self.gridList[index].godLvList[i],"fx_shenhun")
local shenhunImage = Util.GetGameObject(self.gridList[index].godLvList[i],"godItem")
if index <= self.lv then
shenhun.gameObject:SetActive(true)
shenhunImage.gameObject:SetActive(false)
else
shenhun.gameObject:SetActive(false)
shenhunImage.gameObject:SetActive(true)
end
end
end
self.gridList[index].add.gameObject:SetActive(true)
self.gridList[index].addImage.gameObject:SetActive(true)
Util.SetGray(self.gridList[index].addImage,false)
if not self.addShow then
self.gridList[index].des.text = string.format("<color=#B5AA95>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
self.gridList[index].add.gameObject:SetActive(false)
elseif index <= self.lv + 1 then
if index == self.lv + 1 then
self.gridList[index].des.text = string.format("<color=#B5AA95>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
else
self.gridList[index].addImage.gameObject:SetActive(false)
self.gridList[index].des.text = string.format("<color=#00FF00>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
end
else
Util.SetGray(self.gridList[index].addImage,true)
self.gridList[index].des.text = string.format("<color=#B5AA95>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
end
for i = 1,math.max(#self.gridList[index].upHeroList,#self.godDatas[index]) do
if not self.godDatas[index][i] then
self.gridList[index].upHeroList[i].go.gameObject:SetActive(false)
else
if not self.gridList[index].upHeroList[i] then
self.gridList[index].upHeroList[i] = {}
self.gridList[index].upHeroList[i].go = newObjToParent(self.heroPre,self.gridList[index].upHero)
self.gridList[index].upHeroList[i].frame = Util.GetGameObject(self.gridList[index].upHeroList[i].go,"frame"):GetComponent("Image")
self.gridList[index].upHeroList[i].icon = Util.GetGameObject(self.gridList[index].upHeroList[i].go,"icon"):GetComponent("Image")
self.gridList[index].upHeroList[i].proIcon = Util.GetGameObject(self.gridList[index].upHeroList[i].go,"proIcon"):GetComponent("Image")
self.gridList[index].upHeroList[i].star = Util.GetGameObject(self.gridList[index].upHeroList[i].go,"star")
self.gridList[index].upHeroList[i].posIcon = Util.GetGameObject(self.gridList[index].upHeroList[i].go,"posIcon"):GetComponent("Image")
end
self.gridList[index].upHeroList[i].go.gameObject:SetActive(true)
if self.gridList[index].upHeroDataList[i] then
self.gridList[index].upHeroList[i].posIcon.gameObject:SetActive(true)
self.gridList[index].upHeroList[i].proIcon.gameObject:SetActive(true)
local tempHeroData = HeroManager.GetSingleHeroData(self.gridList[index].upHeroDataList[i])
self:SetHeroData(self.gridList[index].upHeroList[i].go,tempHeroData,false)
Util.SetGray(self.gridList[index].upHeroList[i].icon.gameObject,false)
else
self.gridList[index].upHeroList[i].frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(self.godDatas[index][i].star,self.godDatas[index][i].star))
SetHeroStars(self.spLoader,self.gridList[index].upHeroList[i].star,self.godDatas[index][i].star,1,Vector2.New(43.081,40.927))
self.gridList[index].upHeroList[i].posIcon.gameObject:SetActive(false)
self.gridList[index].upHeroList[i].proIcon.gameObject:SetActive(false)
if self.godDatas[index][i].id > 0 then
self.gridList[index].upHeroList[i].icon.sprite = self.spLoader:LoadSprite(GetResourcePath(heroConfig[self.godDatas[index][i].id].Icon))
Util.SetGray(self.gridList[index].upHeroList[i].icon.gameObject,true)
else
self.gridList[index].upHeroList[i].icon.sprite = self.spLoader:LoadSprite("r_hero_jinjie-touxiang2")
if self.godDatas[index][i].property > 0 then
self.gridList[index].upHeroList[i].proIcon.gameObject:SetActive(true)
self.gridList[index].upHeroList[i].proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(self.godDatas[index][i].property))
elseif self.godDatas[index][i].profession > 0 then
self.gridList[index].upHeroList[i].posIcon.gameObject:SetActive(true)
self.gridList[index].upHeroList[i].posIcon.sprite = self.spLoader:LoadSprite(GetHeroPosStr(self.godDatas[index][i].profession))
else
end
Util.SetGray(self.gridList[index].upHeroList[i].icon.gameObject,false)
end
end
Util.AddOnceClick(self.gridList[index].upHeroList[i].go,function()
if self.addShow then
self:SetMaskActive(false)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.ShenHun,self.godDatas[index],self.curHeroData,index,i)
end
end)
end
end
Util.AddOnceClick(self.gridList[index].add,function()
if self.addShow then
self:SetMaskActive(false)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.ShenHun,self.godDatas[index],self.curHeroData,index,1)
end
end)
end
--index 等级
function RoleGodSoulLayout:UpdataSingleGod(index)
for i = 1,math.max(#self.gridList[index].godLvList,index) do
if index < i then
self.gridList[index].godLvList[i].gameObject:SetActive(false)
else
if not self.gridList[index].godLvList[i] then
self.gridList[index].godLvList[i] = newObjToParent(self.godPre,self.gridList[index].godGrid)
end
self.gridList[index].godLvList[i].gameObject:SetActive(true)
end
end
--绿色
self.gridList[index].tip.text = string.format("<color=#B5AA95>需要:</color>")
local godDatasByLv = GodSoulManager.MergeGodSoulDataByLv(self.heroConfig.Id,index)
for i = 1,math.max(#self.gridList[index].costList,#godDatasByLv) do
if not godDatasByLv[i] then
self.gridList[index].costList[i].go.gameObject:SetActive(false)
else
if not self.gridList[index].costList[i] then
self.gridList[index].costList[i] = {}
self.gridList[index].costList[i].go = newObjToParent(self.costPre,self.gridList[index].costGrid)
self.gridList[index].costList[i].frame = Util.GetGameObject(self.gridList[index].costList[i].go,"frame"):GetComponent("Image")
self.gridList[index].costList[i].icon = Util.GetGameObject(self.gridList[index].costList[i].frame.transform,"icon"):GetComponent("Image")
self.gridList[index].costList[i].num = Util.GetGameObject(self.gridList[index].costList[i].go,"num"):GetComponent("Text")
end
self.gridList[index].costList[i].go.gameObject:SetActive(true)
if godDatasByLv[i].id > 0 then
if godDatasByLv[i].star > 10 then
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite("s_shenhunxitong_zuanshitouxiangkuang")
else
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite("s_shenhunxitong_hong")
end
self.gridList[index].costList[i].icon.gameObject:SetActive(true)
self.gridList[index].costList[i].icon.sprite = self.spLoader:LoadSprite(GetResourcePath(heroConfig[godDatasByLv[i].id].Icon))
elseif godDatasByLv[i].property > 0 then
self.gridList[index].costList[i].icon.gameObject:SetActive(false)
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite(PropertySmallIcon[godDatasByLv[i].star][godDatasByLv[i].property])
elseif godDatasByLv[i].profession > 0 then
self.gridList[index].costList[i].icon.gameObject:SetActive(false)
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite(GodSoulProfession[godDatasByLv[i].star][godDatasByLv[i].profession])
else
self.gridList[index].costList[i].icon.gameObject:SetActive(false)
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite(StarImage[godDatasByLv[i].star])
end
if not self.addShow then
self.gridList[index].costList[i].num.text = string.format("<color=#B5AA95>×%s</color>",godDatasByLv[i].num)
Util.SetGray(self.gridList[index].costList[i].frame.gameObject,false)
elseif index >= self.lv + 1 then --未激活时红色,图标置灰
self.gridList[index].costList[i].num.text = string.format("<color=#FF0000>×%s</color>",godDatasByLv[i].num)
Util.SetGray(self.gridList[index].costList[i].frame.gameObject,true)
else --激活时绿色,图标不置灰
self.gridList[index].costList[i].num.text = string.format("<color=#00FF00>×%s</color>",godDatasByLv[i].num)
Util.SetGray(self.gridList[index].costList[i].frame.gameObject,false)
end
end
end
if self.addShow then
if #self.gridList[index].upHeroDataList < 1 then
self.gridList[index].upHero.gameObject:SetActive(false)
else
self.gridList[index].upHero.gameObject:SetActive(true)
for i = 1,math.max(#self.gridList[index].upHeroList,#self.gridList[index].upHeroDataList) do
if not self.gridList[index].upHeroDataList[i] then
self.gridList[index].upHeroList[i].gameObject:SetActive(false)
else
if not self.gridList[index].upHeroList[i] then
self.gridList[index].upHeroList[i] = newObjToParent(self.heroPre,self.gridList[index].upHero)
end
self.gridList[index].upHeroList[i].gameObject:SetActive(true)
local tempHeroData = HeroManager.GetSingleHeroData(self.gridList[index].upHeroDataList[i])
self:SetHeroData(self.gridList[index].upHeroList[i],tempHeroData,false)
Util.AddOnceClick(self.gridList[index].upHeroList[i],function()
self:SetMaskActive(false)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.ShenHun,self.godDatas[index],self.curHeroData,index,i)
end)
end
end
end
else
self.gridList[index].upHero.gameObject:SetActive(false)
end
self.gridList[index].red.gameObject:SetActive(false)
if not self.addShow then
self.gridList[index].add.gameObject:SetActive(false)
Util.SetGray(self.gridList[index].godGrid,false)
--Util.SetGray(self.gridList[index].des.gameObject,false)
self.gridList[index].des.text = string.format("<color=#B5AA95>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
elseif index <= self.lv + 1 then
if index == self.lv + 1 then
self.gridList[index].add.gameObject:SetActive(true)
self.gridList[index].addImage.gameObject:SetActive(true)
Util.SetGray(self.gridList[index].godGrid,true) --勾魂图标 未激活时置灰
--Util.SetGray(self.gridList[index].des.gameObject,true)
self.gridList[index].des.text = string.format("<color=#B5AA95>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
local isShow = GodSoulManager.CheckRedPointGodSoul(self.curHeroData) or false
self.gridList[index].red.gameObject:SetActive(isShow)
else
self.gridList[index].add.gameObject:SetActive(true)
self.gridList[index].addImage.gameObject:SetActive(false)
Util.SetGray(self.gridList[index].godGrid,false)
--Util.SetGray(self.gridList[index].des.gameObject,false)
self.gridList[index].des.text = string.format("<color=#00FF00>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
end
Util.SetGray(self.gridList[index].add,false)
else
self.gridList[index].add.gameObject:SetActive(true)
self.gridList[index].addImage.gameObject:SetActive(true)
--红色
Util.SetGray(self.gridList[index].godGrid,true)
--Util.SetGray(self.gridList[index].des.gameObject,true)
self.gridList[index].des.text = string.format("<color=#B5AA95>%s</color>",self.godDatas[index].skill) --神魂效果 绿色 未激活时置灰
Util.SetGray(self.gridList[index].add,true)
end
self.gridList[index].middle.gameObject:SetActive(false)
Util.AddOnceClick(self.gridList[index].add,function()
if index <= self.lv + 1 then
self:SetMaskActive(false)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.ShenHun,self.godDatas[index],self.curHeroData,index)
else
PopupTipPanel.ShowTip("需要激活上一个神魂才可解锁!")
end
end)
end
function RoleGodSoulLayout:OnHide()
self.gameObject:SetActive(false)
end
function RoleGodSoulLayout:OnDestroy()
self.gridList = {}
end
function RoleGodSoulLayout:OnClose()
self.gameObject:SetActive(false)
end
function RoleGodSoulLayout:SetMaskActive(isShow)
self.effectMask.enabled = isShow
end
return RoleGodSoulLayout