2021-03-22 15:16:29 +08:00
|
|
|
|
|
2021-03-19 14:37:24 +08:00
|
|
|
|
require("Base/BasePanel")
|
2021-03-16 17:37:32 +08:00
|
|
|
|
local TianShuMiJuanMainPanel = Inherit(BasePanel)
|
|
|
|
|
local this = TianShuMiJuanMainPanel
|
2021-03-19 14:37:24 +08:00
|
|
|
|
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
|
|
|
|
|
local redPointList = {}
|
2021-03-16 17:37:32 +08:00
|
|
|
|
-- Tab管理器
|
|
|
|
|
local TabBox = require("Modules/Common/TabBox")
|
2021-03-19 14:37:24 +08:00
|
|
|
|
local tabs = {
|
|
|
|
|
[1] = { --神将
|
|
|
|
|
default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",tabName = "神将篇",
|
|
|
|
|
rpType = 0,funcType = -1,bg = "t_tianshumijuan_shengjiangditu",zi = "t_tianshumijuan_shenjiangpian_zi_zh",
|
|
|
|
|
},
|
|
|
|
|
[2] = { --魂印
|
|
|
|
|
default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",tabName = "魂印篇",
|
|
|
|
|
rpType = 0,funcType = FUNCTION_OPEN_TYPE.hunyin,bg = "t_tianshumijuan_hunyinditu",zi = "t_tianshumijuan_hunyingpian_zi_zh", --gamesetting.EquipSignUnlock
|
|
|
|
|
},
|
|
|
|
|
[3] = { --灵兽
|
|
|
|
|
default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",tabName = "灵兽篇",
|
|
|
|
|
rpType = 0,funcType = FUNCTION_OPEN_TYPE.POKEMON,bg = "t_tianshumijuan_lingshouditu",zi = "t_tianshumijuan_lingshoupian_zi_zh",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
local curPage = 1
|
|
|
|
|
local data = 1
|
2021-03-16 17:37:32 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function TianShuMiJuanMainPanel:InitComponent()
|
2021-03-19 14:37:24 +08:00
|
|
|
|
self.itemPreList = {}
|
|
|
|
|
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.tabbox = Util.GetGameObject(self.gameObject,"bg/tabbox")
|
2021-03-19 14:37:24 +08:00
|
|
|
|
self.bg = Util.GetGameObject(self.gameObject,"bg/Bg"):GetComponent("Image")
|
|
|
|
|
self.selectKuang = Util.GetGameObject(self.gameObject,"bg/select")
|
|
|
|
|
self.title = Util.GetGameObject(self.gameObject,"bg/title"):GetComponent("Image")
|
|
|
|
|
self.btnBack = Util.GetGameObject(self.gameObject,"bg/btnBack")
|
|
|
|
|
self.shai = Util.GetGameObject(self.gameObject,"bg/shai")
|
|
|
|
|
self.shaiText = Util.GetGameObject(self.shai,"Text"):GetComponent("Text")
|
|
|
|
|
self.fetterItem = Util.GetGameObject(self.gameObject,"fetterItem")
|
|
|
|
|
local grid = Util.GetGameObject(self.gameObject,"bg/fetterGrid")
|
|
|
|
|
local v21 = grid.transform.rect
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.scroll = SubUIManager.Open(SubUIConfig.ScrollCycleView,grid.transform,self.fetterItem,nil,Vector2.New(v21.width, v21.height), 1, 1, Vector2.New(0,0))
|
2021-03-19 14:37:24 +08:00
|
|
|
|
self.empty = Util.GetGameObject(self.gameObject,"bg/NoneImage")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TianShuMiJuanMainPanel.SetTabAdapter(newTab, index, status)
|
|
|
|
|
local img = Util.GetGameObject(newTab.gameObject,"img"):GetComponent("Image")
|
|
|
|
|
local redpot = Util.GetGameObject(newTab.gameObject,"redpot")
|
|
|
|
|
local tabName = Util.GetGameObject(newTab.gameObject,"Text"):GetComponent("Text")
|
|
|
|
|
if tabs[index].rpType > 0 then
|
|
|
|
|
if redPointList[tabs[index].rpType] then
|
|
|
|
|
ClearRedPointObject(tabs[index].rpType,redPointList[tabs[index].rpType])
|
|
|
|
|
end
|
|
|
|
|
BindRedPointObject(tabs[index].rpType,redpot)
|
|
|
|
|
redPointList[tabs[index].rpType] = redpot
|
|
|
|
|
end
|
|
|
|
|
img.sprite = Util.LoadSprite(tabs[index][status])
|
|
|
|
|
tabName.text = tabs[index].tabName
|
2021-03-16 17:37:32 +08:00
|
|
|
|
|
2021-03-19 14:37:24 +08:00
|
|
|
|
if tabs[index].funcType == 1 then
|
|
|
|
|
if gameSetting.EquipSignUnlock[1][2] > PlayerManager.level then
|
|
|
|
|
newTab.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
newTab.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
elseif tabs[index].funcType == FUNCTION_OPEN_TYPE.POKEMON then
|
|
|
|
|
if ActTimeCtrlManager.SingleFuncState(tabs[index].funcType) then
|
|
|
|
|
newTab.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
newTab.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
2021-03-19 14:37:24 +08:00
|
|
|
|
|
|
|
|
|
function TianShuMiJuanMainPanel.TabIsLockCheck(index)
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
function TianShuMiJuanMainPanel.SetChangeTabCallBack(index)
|
|
|
|
|
if curPage == index then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
curPage = index
|
2021-03-22 15:16:29 +08:00
|
|
|
|
this:OnShow(self)
|
2021-03-19 14:37:24 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-16 17:37:32 +08:00
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function TianShuMiJuanMainPanel:BindEvent()
|
2021-03-19 14:37:24 +08:00
|
|
|
|
Util.AddClick(self.btnBack, function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.shai, function()
|
|
|
|
|
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end)
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.tabBox = TabBox.New()
|
|
|
|
|
self.tabBox:SetTabAdapter(self.SetTabAdapter)
|
|
|
|
|
self.tabBox:SetTabIsLockCheck(self.TabIsLockCheck)
|
|
|
|
|
self.tabBox:SetChangeTabCallBack(self.SetChangeTabCallBack)
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function TianShuMiJuanMainPanel:AddListener()
|
2021-03-19 14:37:24 +08:00
|
|
|
|
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function TianShuMiJuanMainPanel:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
2021-03-19 14:37:24 +08:00
|
|
|
|
function TianShuMiJuanMainPanel:OnOpen(...)
|
|
|
|
|
local args = {...}
|
|
|
|
|
curPage = args[1] or 1
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.tabBox:Init(self.tabbox.gameObject, tabs, curPage)
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 打开,重新打开时回调
|
2021-03-19 14:37:24 +08:00
|
|
|
|
function TianShuMiJuanMainPanel:OnShow()
|
|
|
|
|
self.bg.sprite = Util.LoadSprite(tabs[curPage].bg)
|
|
|
|
|
self.title.sprite = Util.LoadSprite(tabs[curPage].zi)
|
|
|
|
|
self.scroll:ForeachItemGO(function(index,go)
|
|
|
|
|
go.gameObject:SetActive(false)
|
|
|
|
|
end)
|
|
|
|
|
data = TianShuMiJuanManger.GetFetterDataByFetterType(curPage)
|
|
|
|
|
if not data or #data < 1 then
|
|
|
|
|
self.empty.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
self.empty.gameObject:SetActive(false)
|
|
|
|
|
self.scroll:SetData(data,function(index,go)
|
|
|
|
|
self:SetSingleData(go,data[index],index)
|
|
|
|
|
end)
|
|
|
|
|
self.scroll:SetIndex(1)
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-03-22 15:16:29 +08:00
|
|
|
|
function TianShuMiJuanMainPanel:SetSingleData(go,item,index)
|
2021-03-19 14:37:24 +08:00
|
|
|
|
if not self.itemPreList[go] then
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.itemPreList[go] = SubUIManager.Open(SubUIConfig.FetterItem,go.transform)
|
2021-03-19 14:37:24 +08:00
|
|
|
|
end
|
2021-03-22 15:16:29 +08:00
|
|
|
|
if not item then
|
2021-03-19 14:37:24 +08:00
|
|
|
|
go.gameObject:SetActive(false)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
go.gameObject:SetActive(true)
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.itemPreList[go]:SetData(item)
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function TianShuMiJuanMainPanel:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function TianShuMiJuanMainPanel:OnDestroy()
|
2021-03-19 14:37:24 +08:00
|
|
|
|
for k,v in pairs(redPointList) do
|
|
|
|
|
ClearRedPointObject(k,v)
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(self.itemPreList) do
|
|
|
|
|
SubUIManager.Close(v)
|
|
|
|
|
end
|
2021-03-22 15:16:29 +08:00
|
|
|
|
self.itemPreList = {}
|
2021-03-19 14:37:24 +08:00
|
|
|
|
redPointList = {}
|
2021-03-16 17:37:32 +08:00
|
|
|
|
end
|
|
|
|
|
return this
|