2021-10-18 10:36:32 +08:00
|
|
|
|
require("Base/BasePanel")
|
2021-10-20 18:02:09 +08:00
|
|
|
|
RoleGodSoulLayout = Inherit(BasePanel)
|
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
function RoleGodSoulLayout:New(gameObject)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
2021-10-20 18:02:09 +08:00
|
|
|
|
setmetatable(b, { __index = RoleGodSoulLayout })
|
2021-10-18 10:36:32 +08:00
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
self.help = Util.GetGameObject(self.gameObject,"bgdi/help")
|
|
|
|
|
self.helpPosition = self.help:GetComponent("RectTransform").localPosition
|
2021-10-18 10:36:32 +08:00
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
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 = {}
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:BindEvent()
|
|
|
|
|
Util.AddClick(self.help, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.QingLongSerectTreasure,self.helpPosition.x,self.helpPosition.y)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:AddListener()
|
|
|
|
|
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
--移除事件监听(用于子类重写)
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:RemoveListener()
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:OnShow()
|
2021-10-18 10:36:32 +08:00
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
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()
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:UpdateGodList()
|
|
|
|
|
self.godDatas = GodSoulManager.GetGodSoulDataByLv(self.curHeroData.id,0)
|
|
|
|
|
for i = 1,math.max(#self.gridList,LengthOfTable(self.godDatas)) do
|
|
|
|
|
if not self.godDatas[i] then
|
|
|
|
|
self.gridList[i].go.gameObject:SetActive(false)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
if not self.gridList[i] then
|
|
|
|
|
self.gridList[i] = {}
|
|
|
|
|
self.gridList[i].go = newObjToParent(self.singlePre,self.grid)
|
|
|
|
|
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 = {}
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
self.gridList[i].go.gameObject:SetActive(true)
|
|
|
|
|
self:UpdataSingleGod(i)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
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)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
else
|
2021-10-20 18:02:09 +08:00
|
|
|
|
if not self.gridList[index].godLvList[i] then
|
|
|
|
|
self.gridList[index].godLvList[i] = newObjToParent(self.godPre,self.gridList[index].costGrid)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
self.gridList[index].godLvList[i].gameObject:SetActive(true)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
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)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
else
|
2021-10-20 18:02:09 +08:00
|
|
|
|
if not self.gridList[index].costList[i] then
|
|
|
|
|
self.gridList[index].costList[i] = {}
|
|
|
|
|
self.gridList[index].costList[i].go = newObjToParent(self.godPre,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,"frame"):GetComponent("Text")
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
self.gridList[index].godLvList[i].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(PropertyIcon[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])
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:OnHide()
|
2021-10-18 10:36:32 +08:00
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function RoleGodSoulLayout:OnClose()
|
|
|
|
|
self.gridList = {}
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
|
|
|
|
|
return RoleGodSoulLayout
|