Files
StellaSora_DataLua/lua/game/ui/activity/reengagement/reengagementtaskctrl.lua
T
SL1900 7363298dc1 Update - 1.15.0.134
EN: 1.15.0.134
CN: 1.15.0.133
JP: 1.15.0.137
KR: 1.15.0.139
2026-09-08 12:00:00 +09:00

331 lines
12 KiB
Lua

local ReengagementTaskCtrl = class("ReengagementTaskCtrl", BaseCtrl)
local TimerManager = require("GameCore.Timer.TimerManager")
ReengagementTaskCtrl._mapNodeConfig = {
txtActName = {
sComponentName = "TMP_Text",
sLanguageId = "Reengagement_Task_Title"
},
loopSv = {
sNodeName = "srGuideQuest",
sComponentName = "LoopScrollView"
},
rtDays = {},
PerActGroupItem = {
nCount = 7,
sCtrlName = "Game.UI.Activity.Reengagement.ReengagementTaskGroupCtrl"
},
btnGroup = {
sNodeName = "PerActGroupItem",
nCount = 7,
sComponentName = "UIButton",
callback = "OnBtnClick_Group"
},
btnGroupLock = {
sNodeName = "btnGroupLock",
nCount = 7,
sComponentName = "UIButton",
callback = "OnBtnClick_GroupLock"
},
btnActDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_Detail"
},
txtBtnActDetail = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_Btn_Detail"
},
btnQuickRec = {
sComponentName = "UIButton",
callback = "OnBtnClick_QuickRec"
},
txtBtnQuickRec = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_Btn_Quick_Receive"
},
goActTime = {},
txtActivityTime = {sComponentName = "TMP_Text"},
txtActValue = {sComponentName = "TMP_Text"},
rtActProgressFill = {
sComponentName = "RectTransform"
},
btnNodeItem = {
nCount = 7,
sComponentName = "UIButton",
callback = "OnBtnClick_NodeItem"
}
}
ReengagementTaskCtrl._mapEventConfig = {}
function ReengagementTaskCtrl:Refresh(nCurTog)
if nCurTog ~= AllEnum.ReengagementTog.Task then
return
end
self:RefreshQuestList()
end
function ReengagementTaskCtrl:RefreshRemainTime()
local endTime = self.actData:GetActEndTime()
local curTime = CS.ClientManager.Instance.serverTimeStamp
local remainTime = endTime - curTime
if remainTime < 0 then
TimerManager.Remove(self.remainTimer)
self.remainTimer = nil
EventManager.Hit(EventId.OpenMessageBox, {
nType = AllEnum.MessageBox.Alert,
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
callbackConfirm = function()
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
end
})
return
end
local sTimeStr = ""
if remainTime <= 60 then
local sec = math.floor(remainTime)
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
elseif 60 < remainTime and remainTime <= 3600 then
local min = math.floor(remainTime / 60)
local sec = math.floor(remainTime - min * 60)
if sec == 0 then
min = min - 1
sec = 60
end
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
elseif 3600 < remainTime and remainTime <= 86400 then
local hour = math.floor(remainTime / 3600)
local min = math.floor((remainTime - hour * 3600) / 60)
if min == 0 then
hour = hour - 1
min = 60
end
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
elseif 86400 < remainTime then
local day = math.floor(remainTime / 86400)
local hour = math.floor((remainTime - day * 86400) / 3600)
if hour == 0 then
day = day - 1
hour = 24
end
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
end
NovaAPI.SetTMPText(self._mapNode.txtActivityTime, orderedFormat(ConfigTable.GetUIText("PerActivity_Remain_Time") or "", sTimeStr))
end
function ReengagementTaskCtrl:RefreshQuestList()
self.tbAllQuestList = self.actData:GetQuestListByGroup()
if nil == self.tbAllQuestList[self._panel.nSelectGroup] then
printLog(string.format("任务列表为空!!!actId = %s, group = %s", self.nActId, self._panel.nSelectGroup))
return
end
self.tbQuestList = self.tbAllQuestList[self._panel.nSelectGroup]
table.sort(self.tbQuestList, function(a, b)
if a.nStatus == b.nStatus then
return a.Id < b.Id
end
return a.nStatus < b.nStatus
end)
for k, v in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(v)
self.tbGridCtrl[k] = nil
end
if nil ~= self.tbQuestList then
self.nPageCount = 0
self._mapNode.loopSv:SetAnim(0.06)
self._mapNode.loopSv:Init(#self.tbQuestList, self, self.OnGridRefresh, nil, false, self.GetGridPageCount)
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
end
local _, _, canReceive = self.actData:GetQuestProgress()
self._mapNode.btnQuickRec.gameObject:SetActive(0 < canReceive)
for k, v in ipairs(self._mapNode.PerActGroupItem) do
local nAllQuest, nReceivedQuest = self.actData:GetDayQuestStatus(k)
v:RefreshStatus(nAllQuest <= nReceivedQuest and 0 < nReceivedQuest)
end
end
function ReengagementTaskCtrl:GetGridPageCount(pageCount)
self.nPageCount = pageCount > #self.tbQuestList and #self.tbQuestList or pageCount
end
function ReengagementTaskCtrl:InitGroupList()
local nCurDay = self.actData:GetCurOpenDay()
self.nMaxOpenGroup = 0
local tbNextOpenGroupList = {}
if nil ~= CacheTable.GetData("_PeriodicQuestGroup", self.nActId) then
local tbGroup = CacheTable.GetData("_PeriodicQuestGroup", self.nActId)[nCurDay]
if nil ~= tbGroup then
for _, v in ipairs(tbGroup) do
if v > self.nMaxOpenGroup then
self.nMaxOpenGroup = v
end
end
end
if nil ~= CacheTable.GetData("_PeriodicQuestGroup", self.nActId)[nCurDay + 1] then
for _, v in ipairs(CacheTable.GetData("_PeriodicQuestGroup", self.nActId)[nCurDay + 1]) do
tbNextOpenGroupList[v] = 1
end
end
end
local nSelectGroup = self.actData:GetCanReceiveRewardGroup()
if 0 == nSelectGroup then
nSelectGroup = self.nMaxOpenGroup
end
for k, v in ipairs(self._mapNode.PerActGroupItem) do
v:Init(self.nActId, k, self.nMaxOpenGroup)
if nil ~= tbNextOpenGroupList[k] then
local nHour = self.actData:GetNextDayOpenTime()
if nHour < 1 then
v:SetTime(orderedFormat(ConfigTable.GetUIText("PerActivity_Quest_Open_Time_2") or "", 1))
else
v:SetTime(orderedFormat(ConfigTable.GetUIText("PerActivity_Quest_Open_Time_1") or "", nHour))
end
end
end
if nil == self._panel.nSelectGroup then
self._panel.nSelectGroup = nSelectGroup
end
self._mapNode.PerActGroupItem[self._panel.nSelectGroup]:SetSelect(true)
end
function ReengagementTaskCtrl:OnGridRefresh(goGrid, gridIndex)
local nIndex = gridIndex + 1
local nInstanceId = goGrid:GetInstanceID()
if not self.tbGridCtrl[nInstanceId] then
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.Activity.PeriodicQuest.PeriodicQuestItemCtrl")
end
self.tbGridCtrl[nInstanceId]:SetData(self.nActId, self.tbQuestList[nIndex])
end
local totalLength = 816
local totalNodeLength = 136
local actNodeItemHeight = 152
local totalHeight = 20
function ReengagementTaskCtrl:RefreshActivityNode()
NovaAPI.SetTMPText(self._mapNode.txtActValue, self.nActiveCount)
local bAllComplete = self.nActiveCount >= self.nTotalActiveCount
self.tbQuestActive = {}
local ForeachActivity = function(mapData)
table.insert(self.tbQuestActive, mapData)
end
ForEachTableLine(ConfigTable.Get("DailyQuestActive"), ForeachActivity)
table.sort(self.tbQuestActive, function(a, b)
return a.Active < b.Active
end)
local nMaxAct = self.tbQuestActive[#self.tbQuestActive].Active
self.tbCanReceiveAct = {}
for k, v in ipairs(self.tbQuestActive) do
if self._mapNode.btnNodeItem[k] ~= nil then
local node = self._mapNode.btnNodeItem[k]
local nPosX = math.min(k / #self.tbQuestActive * totalNodeLength, totalNodeLength)
node.transform:GetComponent("RectTransform").anchoredPosition = Vector2(nPosX, actNodeItemHeight)
node.gameObject:SetActive(true)
local txtNodeAct = node.transform:Find("AnimRoot/goNodeItem/txtNodeAct"):GetComponent("TMP_Text")
NovaAPI.SetTMPText(txtNodeAct, v.Active)
local anim = node.transform:Find("AnimRoot"):GetComponent("Animator")
local imgGift = node.transform:Find("AnimRoot/goNodeItem/imgGift")
local imgComplete = node.transform:Find("AnimRoot/goNodeItem/imgComplete")
local goParticle1 = node.transform:Find("AnimRoot/goNodeItem/UIParticle1")
local goParticle2 = node.transform:Find("AnimRoot/goNodeItem/UIParticle2")
local bReceived = PlayerData.Quest:CheckDailyActiveReceive(v.Id)
local bComplete = v.Active <= self.nActiveCount
imgGift.gameObject:SetActive(not bReceived)
imgComplete.gameObject:SetActive(bReceived)
goParticle1.gameObject:SetActive(not bReceived and bComplete)
goParticle2.gameObject:SetActive(not bReceived and bComplete)
if bComplete and not bReceived then
table.insert(self.tbCanReceiveAct, k)
end
if not bReceived and bComplete then
anim:Play("Quest_btnNodeComplete_loop", 0, 0)
else
anim:Play("Empty")
end
end
end
self._mapNode.btnActReceive.gameObject:SetActive(#self.tbCanReceiveAct > 0)
self._mapNode.txtActComplete.gameObject:SetActive(bAllComplete and not (#self.tbCanReceiveAct > 0))
self._mapNode.btnActReceiveGray.gameObject:SetActive(not bAllComplete and not (#self.tbCanReceiveAct > 0))
local nWidth = math.min(self.nActiveCount / nMaxAct * totalLength, totalLength)
self._mapNode.rtActProgressFill.sizeDelta = Vector2(nWidth, totalHeight)
end
function ReengagementTaskCtrl:InitActData(actData, bResetGroup)
self.actData = actData
if bResetGroup then
self._panel.nSelectGroup = nil
end
self.nActId = actData:GetActId()
self.bQuestAnim = false
self:InitGroupList()
local tbAllQuestList = self.actData:GetQuestListByGroup()
if nil == tbAllQuestList[self._panel.nSelectGroup] then
EventManager.Hit(EventId.OpenMessageBox, {
nType = AllEnum.MessageBox.Tips,
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1")
})
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
return
end
local actCfg = self.actData:GetActCfgData()
if actCfg.EndType == GameEnum.activityEndType.NoLimit then
self._mapNode.goActTime.gameObject:SetActive(false)
else
self._mapNode.goActTime.gameObject:SetActive(true)
self:RefreshRemainTime()
if nil == self.remainTimer then
self.remainTimer = self:AddTimer(0, 1, "RefreshRemainTime", true, true, false)
end
end
end
function ReengagementTaskCtrl:Awake()
self.tbGridCtrl = {}
self.tbSequences = {}
end
function ReengagementTaskCtrl:FadeIn()
end
function ReengagementTaskCtrl:FadeOut()
end
function ReengagementTaskCtrl:OnEnable()
end
function ReengagementTaskCtrl:OnDisable()
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
end
self.tbGridCtrl = {}
end
function ReengagementTaskCtrl:OnDestroy()
end
function ReengagementTaskCtrl:OnRelease()
end
function ReengagementTaskCtrl:OnBtnClick_Group(_, nIndex)
if self._panel.nSelectGroup == nIndex then
return
end
if nIndex > self.nMaxOpenGroup then
return
end
if nil == self.tbAllQuestList[nIndex] or nil == next(self.tbAllQuestList[nIndex]) then
printError(string.format("当前任务组下没有任务!!! 活动id = %d, 任务组 = %s", self.nActId, nIndex))
return
end
self._mapNode.PerActGroupItem[self._panel.nSelectGroup]:SetSelect(false)
if nil ~= self._mapNode.PerActGroupItem[nIndex] then
self._mapNode.PerActGroupItem[nIndex]:SetSelect(true)
end
self._panel.nSelectGroup = nIndex
self.bQuestAnim = true
self:RefreshQuestList()
end
function ReengagementTaskCtrl:OnBtnClick_GroupLock()
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PerActivity_Not_Open"))
end
function ReengagementTaskCtrl:OnBtnClick_Detail()
local perQuestActCfg = self.actData:GetPerQuestCfg()
local msg = {
nType = AllEnum.MessageBox.Desc,
sContent = perQuestActCfg.DesText,
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
}
EventManager.Hit(EventId.OpenMessageBox, msg)
end
function ReengagementTaskCtrl:OnBtnClick_QuickRec()
local callback = function()
EventManager.Hit("RefreshPeriodicAct", self.nActId)
PlayerData.Base:TryOpenWorldClassUpgrade()
end
PlayerData.Activity:SendReceivePerQuest(self.nActId, 0, callback)
end
return ReengagementTaskCtrl