PGRData/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskActivity.lua
2022-12-26 14:06:01 +05:30

68 lines
No EOL
2.2 KiB
Lua

local XUiPassportPanelTaskActivity = XClass(nil, "XUiPassportPanelTaskActivity")
--活动任务
function XUiPassportPanelTaskActivity:Ctor(ui, rootUi)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.RootUi = rootUi
XTool.InitUiObject(self)
XUiHelper.RegisterClickEvent(self, self.BtnTongBlack, self.OnBtnTongBlackClick)
self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.transform)
self.DynamicTable:SetProxy(XDynamicGridTask)
self.DynamicTable:SetDelegate(self)
self.GridTask.gameObject:SetActive(false)
XRedPointManager.AddRedPointEvent(self.BtnTongBlack, self.OnCheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_ACTIVITY_RED })
end
function XUiPassportPanelTaskActivity:Refresh()
if not self:IsShow() then
return
end
self.Tasks = XDataCenter.PassportManager.GetPassportTask(XPassportConfigs.TaskType.Activity)
self.DynamicTable:SetDataSource(self.Tasks)
self.DynamicTable:ReloadDataSync()
local clearTaskCount = XDataCenter.PassportManager.GetClearTaskCount(XPassportConfigs.TaskType.Activity)
local taskTotalCount = XPassportConfigs.GetPassportBPTaskTotalCount()
self.TxtDailyNumber.text = string.format("%s/%s", clearTaskCount, taskTotalCount)
end
function XUiPassportPanelTaskActivity:OnDynamicTableEvent(event, index, grid)
if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then
local data = self.Tasks[index]
grid.RootUi = self.RootUi
grid:ResetData(data)
end
end
--一键领取
function XUiPassportPanelTaskActivity:OnBtnTongBlackClick()
XDataCenter.PassportManager.FinishMultiTaskRequest(XPassportConfigs.TaskType.Activity)
end
function XUiPassportPanelTaskActivity:OnCheckTaskRedPoint(count)
self.BtnTongBlack:ShowReddot(count >= 0)
end
function XUiPassportPanelTaskActivity:Show()
self.GameObject:SetActiveEx(true)
self:Refresh()
end
function XUiPassportPanelTaskActivity:Hide()
self.GameObject:SetActiveEx(false)
end
function XUiPassportPanelTaskActivity:IsShow()
if XTool.UObjIsNil(self.GameObject) then
return false
end
return self.GameObject.activeSelf
end
return XUiPassportPanelTaskActivity