2021-11-15 18:24:39 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
TailsManSouPanel = Inherit(BasePanel)
|
|
|
|
|
local this = TailsManSouPanel
|
|
|
|
|
local redPointList = {}
|
|
|
|
|
-- Tab管理器
|
|
|
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
|
|
|
local tabs = {
|
|
|
|
|
[1] = { --金色
|
|
|
|
|
default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",tabName = "金色",
|
|
|
|
|
rpType = -1,bg = "t_tianshumijuan_shengjiangditu",quality = 5
|
|
|
|
|
},
|
|
|
|
|
[2] = { --红色
|
|
|
|
|
default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",tabName = "红色",
|
|
|
|
|
rpType = -1,bg = "t_tianshumijuan_hunyinditu",quality = 6
|
|
|
|
|
},
|
|
|
|
|
[3] = { --白金
|
|
|
|
|
default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",tabName = "白金",
|
|
|
|
|
rpType = -1,bg = "t_tianshumijuan_lingshouditu",quality = 7
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
local curData = {}
|
|
|
|
|
local curPage = 1
|
2021-11-11 16:48:15 +08:00
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:InitComponent()
|
2021-11-15 18:24:39 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
|
|
|
|
self.itemPreList = {}
|
|
|
|
|
self.bg = Util.GetGameObject(self.gameObject,"bg/Bg"):GetComponent("Image")
|
|
|
|
|
self.tabbox = Util.GetGameObject(self.gameObject,"bg/tabbox")
|
|
|
|
|
self.btnBack = Util.GetGameObject(self.gameObject,"bg/btnBack")
|
|
|
|
|
self.fetterItem = Util.GetGameObject(self.gameObject,"fetterItem")
|
|
|
|
|
local grid = Util.GetGameObject(self.gameObject,"bg/fetterGrid")
|
|
|
|
|
local v21 = grid.transform.rect
|
|
|
|
|
self.scroll = SubUIManager.Open(SubUIConfig.ScrollCycleView,grid.transform,self.fetterItem,nil,Vector2.New(v21.width, v21.height), 1, 1, Vector2.New(0,25))
|
|
|
|
|
self.empty = Util.GetGameObject(self.gameObject,"bg/NoneImage")
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:BindEvent()
|
2021-11-15 18:24:39 +08:00
|
|
|
|
Util.AddClick(self.btnBack, function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
self.tabBox = TabBox.New()
|
|
|
|
|
self.tabBox:SetTabAdapter(self.SetTabAdapter)
|
|
|
|
|
self.tabBox:SetTabIsLockCheck(self.TabIsLockCheck)
|
|
|
|
|
self.tabBox:SetChangeTabCallBack(self.SetChangeTabCallBack)
|
|
|
|
|
end
|
|
|
|
|
function TailsManSouPanel.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")
|
|
|
|
|
local lock = Util.GetGameObject(newTab.gameObject,"lock")
|
|
|
|
|
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 = this.spLoader:LoadSprite(tabs[index][status])
|
|
|
|
|
tabName.text = tabs[index].tabName
|
|
|
|
|
if status == "lock" then
|
|
|
|
|
lock.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
lock.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
newTab.gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TailsManSouPanel.TabIsLockCheck(index)
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TailsManSouPanel.SetChangeTabCallBack(index)
|
|
|
|
|
if curPage == index then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
curPage = index
|
|
|
|
|
this:OnShow(self)
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:OnOpen(...)
|
2021-11-15 18:24:39 +08:00
|
|
|
|
local args = {...}
|
|
|
|
|
curPage = args[1] or 1
|
|
|
|
|
LogGreen("curPage:"..tostring(curPage))
|
|
|
|
|
self.tabBox:Init(self.tabbox.gameObject, tabs, curPage)
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:OnShow(...)
|
2021-11-15 18:24:39 +08:00
|
|
|
|
self.bg.sprite = this.spLoader:LoadSprite(tabs[curPage].bg)
|
|
|
|
|
curData = TailsManSoulManager.GetTailsmanSoulDatas(tabs[curPage].quality)
|
|
|
|
|
self:RefreshData()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function TailsManSouPanel:RefreshData()
|
|
|
|
|
self:SortData()
|
|
|
|
|
self.scroll:ForeachItemGO(function(index,go)
|
|
|
|
|
go.gameObject:SetActive(false)
|
|
|
|
|
end)
|
|
|
|
|
if not curData or #curData < 1 then
|
|
|
|
|
self.empty.gameObject:SetActive(true)
|
|
|
|
|
self.scroll.gameObject:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
self.empty.gameObject:SetActive(false)
|
|
|
|
|
self.scroll.gameObject:SetActive(true)
|
|
|
|
|
self.scroll:SetData(curData,function(index,go)
|
|
|
|
|
self:SetSingleData(go,curData[index],index)
|
|
|
|
|
end)
|
|
|
|
|
self.scroll:SetIndex(1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TailsManSouPanel:SortData()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TailsManSouPanel:SetSingleData(go,data,index)
|
|
|
|
|
if not self.itemPreList[go] then
|
|
|
|
|
self.itemPreList[go] = {}
|
|
|
|
|
self.itemPreList[go].obj = Util.GetGameObject(go,"go")
|
|
|
|
|
self.itemPreList[go].bg = Util.GetGameObject(self.itemPreList[go].obj,"bg"):GetComponent("Image")
|
|
|
|
|
self.nameText = Util.GetGameObject(self.itemPreList[go].obj,"bg/nameDi/nameText"):GetComponent("Text")
|
|
|
|
|
self.slider = Util.GetGameObject(self.itemPreList[go].obj,"slider"):GetComponent("Slider")
|
|
|
|
|
self.tip = Util.GetGameObject(self.slider.transform,"tip"):GetComponent("Text")
|
|
|
|
|
self.progress = Util.GetGameObject(self.slider.transform,"progress"):GetComponent("Text")
|
|
|
|
|
self.red = Util.GetGameObject(self.itemPreList[go].bg.transform,"red")
|
|
|
|
|
end
|
|
|
|
|
self.itemPreList[go].data = data
|
|
|
|
|
if not data then
|
|
|
|
|
go.gameObject:SetActive(false)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
self.red.gameObject:SetActive(self:CheckRedPoint(self.itemPreList[go].data.trumpList))
|
|
|
|
|
go.gameObject:SetActive(true)
|
|
|
|
|
self.itemPreList[go].bg.sprite = this.spLoader:LoadSprite(self.itemPreList[go].data.icon)
|
|
|
|
|
self.nameText.text = self.itemPreList[go].data.name
|
|
|
|
|
self.slider.value = self.itemPreList[go].data.lv/self.itemPreList[go].data.maxLv
|
|
|
|
|
self.progress.text = self.itemPreList[go].data.lv.."/"..self.itemPreList[go].data.maxLv
|
|
|
|
|
Util.AddOnceClick(go,function()
|
|
|
|
|
UIManager.OpenPanel(UIName.TailsmanSoulMainPanel,self.itemPreList[go].data.id)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TailsManSouPanel:CheckRedPoint(data)
|
|
|
|
|
for k,v in pairs(data) do
|
|
|
|
|
local costId,num = TailsManSoulManager.GetTailsmanCost(v.id,v.lv)
|
|
|
|
|
if num and num > 0 then
|
|
|
|
|
if BagManager.GetItemCountById(costId) >= num then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面层级发生改变(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:OnSortingOrderChange()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:OnClose()
|
2021-11-15 18:24:39 +08:00
|
|
|
|
curPage = 1
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function TailsManSouPanel:OnDestroy()
|
2021-11-15 18:24:39 +08:00
|
|
|
|
this.spLoader:Destroy()
|
|
|
|
|
for k,v in pairs(redPointList) do
|
|
|
|
|
ClearRedPointObject(k,v)
|
|
|
|
|
end
|
|
|
|
|
SubUIManager.Close(self.scroll)
|
|
|
|
|
self.itemPreList = {}
|
|
|
|
|
redPointList = {}
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return TailsManSouPanel
|