163 lines
6.2 KiB
Lua
163 lines
6.2 KiB
Lua
require("Base/BasePanel")
|
|
EastSeaFindGodPanel = Inherit(BasePanel)
|
|
local this = EastSeaFindGodPanel
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "1",colorDefault = Color.New(243 / 255, 235 / 255, 202 / 255, 1),colorSelect = Color.New(130 / 255, 128 / 255, 120 / 255, 1),type = 4,redpointType = RedPointType.eastSeaFindGod1, },
|
|
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "2" ,olorDefault = Color.New(243 / 255, 235 / 255, 202 / 255, 1),colorSelect = Color.New(130 / 255, 128 / 255, 120 / 255, 1),type = 5,redpointType = RedPointType.eastSeaFindGod2, },
|
|
[3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "3" ,olorDefault = Color.New(243 / 255, 235 / 255, 202 / 255, 1),colorSelect = Color.New(130 / 255, 128 / 255, 120 / 255, 1),type = 6,redpointType = RedPointType.eastSeaFindGod3,},
|
|
[4] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "4",olorDefault = Color.New(243 / 255, 235 / 255, 202 / 255, 1),colorSelect = Color.New(130 / 255, 128 / 255, 120 / 255, 1),type = 7,redpointType = RedPointType.eastSeaFindGod4,},
|
|
}
|
|
local colorTab = {default = Color.New(243 / 255, 235 / 255, 202 / 255, 1),select = Color.New(130 / 255, 128 / 255, 120 / 255, 1)}
|
|
--打开弹窗索引
|
|
local index=0
|
|
local redPointList
|
|
local istop ,isAnim
|
|
--初始化组件(用于子类重写)
|
|
function EastSeaFindGodPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.tabBox = Util.GetGameObject(self.gameObject, "TabBox")
|
|
this.closeBtn = Util.GetGameObject(self.transform, "closeBtn")
|
|
this.scroll = Util.GetGameObject(self.transform, "scroll")
|
|
local v = this.scroll:GetComponent("RectTransform").rect
|
|
this.item = Util.GetGameObject(self.transform, "item")
|
|
this.root = Util.GetGameObject(self.transform, "bg/root"):GetComponent("Image")
|
|
this.scrollCycleView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform, this.item, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0, 0))
|
|
redPointList = {}
|
|
this.ItemList = {}
|
|
this.timeText = Util.GetGameObject(self.transform, "timeText"):GetComponent("Text")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function EastSeaFindGodPanel:BindEvent()
|
|
Util.AddClick(this.closeBtn, function()
|
|
index = 0
|
|
self:ClosePanel()
|
|
end)
|
|
this.TabCtrl = TabBox.New()
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function EastSeaFindGodPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.EastSeaFindGod.OnMissionChange,this.RefreshData)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function EastSeaFindGodPanel:RemoveListener()
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.EastSeaFindGod.OnMissionChange,this.RefreshData)
|
|
end
|
|
|
|
function this.RefreshData()
|
|
this.SwitchView(index)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function EastSeaFindGodPanel:OnOpen(popupType,...)
|
|
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function EastSeaFindGodPanel:OnShow()
|
|
istop ,isAnim = false,false
|
|
if index == 0 then
|
|
index = 1
|
|
for k,v in ipairs(_TabData) do
|
|
if RedpotManager.GetRedPointStatus(v.redpointType) == 1 then
|
|
index = k
|
|
break
|
|
end
|
|
end
|
|
this.TabCtrl:Init(this.tabBox, _TabData, index)
|
|
end
|
|
this:SetTime()
|
|
end
|
|
|
|
function EastSeaFindGodPanel:SetTime()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
local remainTime = ActivityGiftManager.GetTaskRemainTime(ActivityTypeDef.EastSeaFindGod)
|
|
local s = function()
|
|
this.timeText.text = "剩余时间:"..TimeToDHMS(remainTime)
|
|
remainTime = remainTime - 1
|
|
if remainTime < 0 then
|
|
index = 0
|
|
self:ClosePanel()
|
|
end
|
|
end
|
|
s()
|
|
self.timer = Timer.New(s,1,-1,false)
|
|
self.timer:Start()
|
|
end
|
|
|
|
function EastSeaFindGodPanel:OnSortingOrderChange()
|
|
|
|
end
|
|
|
|
-- tab节点显示自定义
|
|
function this.TabAdapter(tab, index, status)
|
|
local tabLab = Util.GetGameObject(tab, "Text")
|
|
tab:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
|
|
tabLab:GetComponent("Text").text = _TabData[index].name
|
|
tabLab:GetComponent("Text").color = colorTab[status]
|
|
local red = Util.GetGameObject(tab,"red")
|
|
BindRedPointObject(_TabData[index].redpointType,red )
|
|
redPointList[_TabData[index].redpointType] = red
|
|
end
|
|
--切换视图
|
|
function this.SwitchView(_index)
|
|
index = _index
|
|
this.data = CommonActPageManager.GetData(ActivityTypeDef.EastSeaFindGod,_TabData[_index].type)
|
|
this.scrollCycleView:ForeachItemGO(function(index, go)
|
|
go.gameObject:SetActive(false)
|
|
end)
|
|
this.scrollCycleView:SetData(this.data.rewards,function(index,item)
|
|
this:RefreshSingleItem(index,item,this.data.rewards[index])
|
|
end,istop,isAnim)
|
|
-- istop = true
|
|
-- isAnim = true
|
|
end
|
|
|
|
function EastSeaFindGodPanel:RefreshSingleItem(index,item,data)
|
|
if not this.ItemList then
|
|
this.ItemList = {}
|
|
end
|
|
if not this.ItemList[item] then
|
|
local subConfig = SubUIConfig[12]
|
|
this.ItemList[item] = SubUIManager.Open(subConfig,item.transform)
|
|
end
|
|
if not data then
|
|
item.gameObject:SetActive(false)
|
|
return
|
|
end
|
|
item.gameObject:SetActive(true)
|
|
self.ItemList[item]:SetData(data,this,this.sortingOrder,this.data)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function EastSeaFindGodPanel:OnClose()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function EastSeaFindGodPanel:OnDestroy()
|
|
for k,v in pairs(redPointList) do
|
|
ClearRedPointObject(k,v)
|
|
end
|
|
for k,v in pairs(this.ItemList) do
|
|
SubUIManager.Close(v)
|
|
end
|
|
this.ItemList = {}
|
|
if this.scrollCycleView then
|
|
SubUIManager.Close( this.scrollCycleView)
|
|
end
|
|
this.scrollCycleView = nil
|
|
this.spLoader:Destroy()
|
|
end
|
|
|
|
return EastSeaFindGodPanel |