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

170 lines
7.7 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.QingLongSerectTreasure,self.helpPosition.x,self.helpPosition.y)
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)
end
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
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
self.gridList[index].costList[i].frame.sprite = self.spLoader:LoadSprite("s_shenhunxitong_zuanshitouxiangkuang")
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].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].profession])
end
if index == self.lv + 1 then
--红色
self.gridList[index].costList[i].num.text = string.format("<color=#B5AA95>×%s</color>",self.godDatas[index][i].num)
else
--绿色
self.gridList[index].costList[i].num.text = string.format("<color=#B5AA95>×%s</color>",self.godDatas[index][i].num)
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].costGrid,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].costGrid,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=#B5AA95>激活%s级神魂后解锁:</color>",index - 1)
Util.SetGray(self.gridList[index].godGrid,true)
Util.SetGray(self.gridList[index].costGrid,false)
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)
end
end)
end
function RoleGodSoulLayout:OnHide()
self.gameObject:SetActive(false)
end
function RoleGodSoulLayout:OnClose()
self.gridList = {}
end
return RoleGodSoulLayout