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

178 lines
8.6 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)
function RoleGodSoulLayout:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = RoleGodSoulLayout })
return b
end
--初始化组件(用于子类重写)
function RoleGodSoulLayout:InitComponent()
self.spLoader = SpriteLoader.New()
self.help = Util.GetGameObject(self.gameObject,"bgdi/help")
self.helpPosition = self.help:GetComponent("RectTransform").localPosition
self.godPre = Util.GetGameObject(self.gameObject,"bgdi/godPre")
self.costPre = Util.GetGameObject(self.gameObject,"bgdi/costPre")
self.singlePre = Util.GetGameObject(self.gameObject,"bgdi/singlePre")
self.grid = Util.GetGameObject(self.gameObject,"bgdi/scroll/grid")
self.gridList = {}
end
--绑定事件(用于子类重写)
function RoleGodSoulLayout:BindEvent()
Util.AddClick(self.help, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.shenhun,self.helpPosition.x,self.helpPosition.y - 500)
end)
end
--添加事件监听(用于子类重写)
function RoleGodSoulLayout:AddListener()
end
--移除事件监听(用于子类重写)
function RoleGodSoulLayout:RemoveListener()
end
function RoleGodSoulLayout:OnShow()
self.gameObject:SetActive(true)
end
function RoleGodSoulLayout:SetData(_sortinglayer,_parent,_curHerodata,_isUpZhen,_heroDatas)
self.sortingOrder = _sortinglayer
self.curHeroData = _curHerodata
self.parent = _parent
self.isUpZhen = _isUpZhen
self.herodatas = _heroDatas
self:UpdateGodList()
end
function RoleGodSoulLayout:UpdateGodList()
self.lv = GodSoulManager.GetGodSoulLv(self.curHeroData.dynamicId)
self.godDatas = GodSoulManager.GetGodSoulDataByLv(self.curHeroData.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].tip = Util.GetGameObject(self.gridList[i].go,"middle/Text"):GetComponent("Text")
self.gridList[i].godGrid = Util.GetGameObject(self.gridList[i].go,"middle/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].des = Util.GetGameObject(self.gridList[i].go,"bottom/des"):GetComponent("Text")
end
self.gridList[i].go.gameObject:SetActive(true)
self:UpdataSingleGod(i)
end
end
end
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].des.text = self.godDatas[index].skill --神魂效果 绿色 未激活时置灰
if index <= self.lv + 1 then
self.gridList[index].tip.text = "<color=#B5AA95>需要:</color>" --未解锁红色
self.gridList[index].costGrid.gameObject:SetActive(true)
for i = 1,math.max(#self.gridList[index].costList,#self.godDatas[index]) do
if not self.godDatas[index][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 self.godDatas[index][i].id > 0 then
if self.godDatas[index][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[self.godDatas[index][i].id].Icon))
elseif self.godDatas[index][i].property > 0 then
self.gridList[index].costList[i].icon.gameObject:SetActive(false)
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite(PropertySmallIcon[self.godDatas[index][i].star][self.godDatas[index][i].property])
elseif self.godDatas[index][i].profession > 0 then
self.gridList[index].costList[i].icon.gameObject:SetActive(false)
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite(GodSoulProfession[self.godDatas[index][i].star][self.godDatas[index][i].profession])
else
self.gridList[index].costList[i].icon.gameObject:SetActive(false)
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite(StarImage[self.godDatas[index][i].star])
end
if index == self.lv + 1 then --未激活时红色,图标置灰
self.gridList[index].costList[i].num.text = string.format("<color=#FF0000>×%s</color>",self.godDatas[index][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>",self.godDatas[index][i].num)
Util.SetGray(self.gridList[index].costList[i].frame.gameObject,false)
end
end
end
self.gridList[index].add.gameObject:SetActive(true)
if index == self.lv + 1 then
Util.SetGray(self.gridList[index].godGrid,true) --勾魂图标 未激活时置灰
--Util.SetGray(self.gridList[index].tip.gameObject,true)
Util.SetGray(self.gridList[index].des.gameObject,true)
else
Util.SetGray(self.gridList[index].godGrid,false)
--Util.SetGray(self.gridList[index].tip.gameObject,false)
Util.SetGray(self.gridList[index].des.gameObject,false)
end
else
self.gridList[index].costGrid.gameObject:SetActive(false)
self.gridList[index].add.gameObject:SetActive(true)
--红色
self.gridList[index].tip.text = string.format("<color=#FF0000>激活%s级神魂后解锁:</color>",index - 1)
Util.SetGray(self.gridList[index].godGrid,true)
Util.SetGray(self.gridList[index].tip.gameObject,false)
Util.SetGray(self.gridList[index].des.gameObject,true)
end
Util.AddOnceClick(self.gridList[index].add,function()
if index <= self.lv + 1 then
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:OnClose()
self.gridList = {}
end
return RoleGodSoulLayout