Update - 1.13.0.124
EN: 1.13.0.124 CN: 1.13.0.124 JP: 1.13.0.128 KR: 1.13.0.130
This commit is contained in:
@@ -1,73 +1,192 @@
|
||||
local MiningGameQuestCtrl = class("MiningGameQuestCtrl", BaseCtrl)
|
||||
local totalLength = 520
|
||||
local totalHeight = 37
|
||||
local barMinX = -622
|
||||
local barMaxX = 0
|
||||
MiningGameQuestCtrl._mapNodeConfig = {
|
||||
loopSv = {
|
||||
sNodeName = "questList",
|
||||
blur = {
|
||||
sNodeName = "t_fullscreen_blur_blue"
|
||||
},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_QuestPanelTitle"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
btnAllClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
btn_GetReward = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GetAllReward"
|
||||
},
|
||||
btn_GetReward_None = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GetAllReward_None"
|
||||
},
|
||||
txt_getAllReward = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_Quest_GetAllReward"
|
||||
},
|
||||
Group_loop_sv = {
|
||||
sNodeName = "sv_group",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
rtBarFill = {
|
||||
Quest_loop_sv = {
|
||||
sNodeName = "sv_quest",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
title_process = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_QuestPanel_CurProcess"
|
||||
},
|
||||
txt_GroupProcess = {sComponentName = "TMP_Text"},
|
||||
imgGroupProcessBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
btn_AllReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_AllReceive"
|
||||
},
|
||||
txt_AllReceive = {
|
||||
ComponentName = "TMP_Text",
|
||||
"Mining_Quest_AllReceive"
|
||||
}
|
||||
animator = {sNodeName = "Quest", sComponentName = "Animator"}
|
||||
}
|
||||
MiningGameQuestCtrl._mapEventConfig = {
|
||||
MiningQuestUpdate = "InitQuestData"
|
||||
MiningQuestUpdate = "OnEvent_QuestUpdate"
|
||||
}
|
||||
function MiningGameQuestCtrl:Awake(...)
|
||||
MiningGameQuestCtrl._mapRedDotConfig = {}
|
||||
function MiningGameQuestCtrl:Awake()
|
||||
self.tbQuestGridCtrl = {}
|
||||
local param = self:GetPanelParam()
|
||||
local actId
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
actId = param[1]
|
||||
end
|
||||
self:InitData()
|
||||
self:SetData(actId)
|
||||
end
|
||||
function MiningGameQuestCtrl:OnEnable()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
self:PlayAnim_In()
|
||||
end
|
||||
function MiningGameQuestCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function MiningGameQuestCtrl:InitData()
|
||||
self.actData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self.tbQuestList = {}
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function MiningGameQuestCtrl:InitQuestData()
|
||||
self.tbQuestList = self.actData:GetAllQuestData()
|
||||
table.sort(self.tbQuestList, function(a, b)
|
||||
if a.nStatus == b.nStatus then
|
||||
return a.Id < b.Id
|
||||
if self.tbQuestGridCtrl ~= nil then
|
||||
for _, ctrl in pairs(self.tbQuestGridCtrl) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
return a.nStatus < b.nStatus
|
||||
end
|
||||
self.tbQuestGridCtrl = {}
|
||||
end
|
||||
function MiningGameQuestCtrl:OnDestroy()
|
||||
end
|
||||
function MiningGameQuestCtrl:PlayAnim_In()
|
||||
self._mapNode.animator:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
end
|
||||
function MiningGameQuestCtrl:SetData(nActId)
|
||||
self.nActId = nActId
|
||||
self.MiningGameData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self.nSelectedGroupId = 0
|
||||
self.tbGroup = self.MiningGameData:GetAllGroupId()
|
||||
table.sort(self.tbGroup, function(a, b)
|
||||
return a < b
|
||||
end)
|
||||
if nil ~= self.tbQuestList then
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
local nSelectIndex = 1
|
||||
for i, v in ipairs(self.tbGroup) do
|
||||
local bRed = RedDotManager.GetValid(RedDotDefine.Activity_Mining_QuestGroup, {v})
|
||||
if bRed then
|
||||
nSelectIndex = i
|
||||
break
|
||||
end
|
||||
self._mapNode.loopSv:SetAnim(0.1)
|
||||
self._mapNode.loopSv:Init(#self.tbQuestList, self, self.OnGridRefresh)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.5)
|
||||
end
|
||||
self._mapNode.rtBarFill.sizeDelta = Vector2(self.actData:GetCompleteCount() / #self.tbQuestList * totalLength, totalHeight)
|
||||
self.nSelectedGroupId = self.tbGroup[nSelectIndex]
|
||||
self._mapNode.Group_loop_sv:Init(#self.tbGroup, self, self.OnRefreshGroupGrid)
|
||||
self:UpdateQuestList(self.nSelectedGroupId)
|
||||
end
|
||||
function MiningGameQuestCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
function MiningGameQuestCtrl:UpdateQuestList(nGroupId)
|
||||
self.questList = self.MiningGameData:GetQuestbyGroupId(nGroupId)
|
||||
if self.questList == nil then
|
||||
return
|
||||
end
|
||||
local sortFunc = function(a, b)
|
||||
if a.nStatus ~= b.nStatus then
|
||||
return a.nStatus < b.nStatus
|
||||
end
|
||||
return a.nId < b.nId
|
||||
end
|
||||
table.sort(self.questList, sortFunc)
|
||||
local nFinishCount = self.MiningGameData:GetGroupQuestReceiveCount(nGroupId)
|
||||
self._mapNode.Quest_loop_sv:Init(#self.questList, self, self.OnRefreshQuestGrid)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_GroupProcess, string.format("%d/%d", nFinishCount, #self.questList))
|
||||
self._mapNode.imgGroupProcessBarFill.anchoredPosition = Vector2(barMinX + (barMaxX - barMinX) * (nFinishCount / #self.questList), self._mapNode.imgGroupProcessBarFill.anchoredPosition.y)
|
||||
local bHasFinish = false
|
||||
for _, questData in ipairs(self.questList) do
|
||||
if questData.nStatus == AllEnum.ActQuestStatus.Complete then
|
||||
bHasFinish = true
|
||||
break
|
||||
end
|
||||
end
|
||||
self._mapNode.btn_GetReward.gameObject:SetActive(bHasFinish)
|
||||
self._mapNode.btn_GetReward_None.gameObject:SetActive(not bHasFinish)
|
||||
end
|
||||
function MiningGameQuestCtrl:OnRefreshGroupGrid(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local txtName = goGrid.transform:Find("btnGrid/AnimRoot/txt_Name")
|
||||
local config = ConfigTable.GetData("MiningQuestGroup", self.tbGroup[nIndex])
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(txtName:GetComponent("TMP_Text"), config.GroupName)
|
||||
local nFinishCount = self.MiningGameData:GetGroupQuestReceiveCount(self.tbGroup[nIndex])
|
||||
local nAllCount = 0
|
||||
for _, value in pairs(self.MiningGameData:GetQuestbyGroupId(self.tbGroup[nIndex])) do
|
||||
nAllCount = nAllCount + 1
|
||||
end
|
||||
local txtCount = goGrid.transform:Find("btnGrid/AnimRoot/txt_Process")
|
||||
NovaAPI.SetTMPText(txtCount:GetComponent("TMP_Text"), string.format("%d/%d", nFinishCount, nAllCount))
|
||||
local goSelected = goGrid.transform:Find("btnGrid/AnimRoot/img_selected")
|
||||
goSelected.gameObject:SetActive(self.tbGroup[nIndex] == self.nSelectedGroupId)
|
||||
if self.tbGroup[nIndex] == self.nSelectedGroupId then
|
||||
self.selectedGrid = goGrid
|
||||
end
|
||||
local reddot = goGrid.transform:Find("btnGrid/AnimRoot/reddot")
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_Mining_QuestGroup, {
|
||||
self.tbGroup[nIndex]
|
||||
}, reddot, nil, nil, true)
|
||||
local go_Button = goGrid.transform:Find("btnGrid")
|
||||
local btn_Select = go_Button:GetComponent("UIButton")
|
||||
btn_Select.onClick:RemoveAllListeners()
|
||||
local nGroupId = self.tbGroup[nIndex]
|
||||
btn_Select.onClick:AddListener(function()
|
||||
if self.selectedGrid ~= nil then
|
||||
local oldGoSelected = self.selectedGrid.transform:Find("btnGrid/AnimRoot/img_selected")
|
||||
oldGoSelected.gameObject:SetActive(false)
|
||||
end
|
||||
self.nSelectedGroupId = nGroupId
|
||||
self.selectedGrid = goGrid
|
||||
goSelected.gameObject:SetActive(true)
|
||||
self:UpdateQuestList(self.nSelectedGroupId)
|
||||
end)
|
||||
end
|
||||
function MiningGameQuestCtrl:OnRefreshQuestGrid(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.Mining.MiningQuestCellCtrl")
|
||||
if not self.tbQuestGridCtrl[nInstanceId] then
|
||||
self.tbQuestGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.Activity.Mining.MiningQuestCellCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceId]:SetData(self.nActId, self.tbQuestList[nIndex])
|
||||
self.tbQuestGridCtrl[nInstanceId]:SetData(self.nActId, self.questList[nIndex])
|
||||
end
|
||||
function MiningGameQuestCtrl:OnBtnClick_AllReceive()
|
||||
PlayerData.Activity:SendReceivePerQuest(self.nActId, 0, nil)
|
||||
function MiningGameQuestCtrl:OnBtnClick_GetAllReward()
|
||||
self.MiningGameData:SendQuestReceive(0, self.nSelectedGroupId)
|
||||
end
|
||||
function MiningGameQuestCtrl:OnBtnClick_GetAllReward_None()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("TowerDefense_Quest_ReceiveNone"))
|
||||
end
|
||||
function MiningGameQuestCtrl:OnBtnClick_Close()
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
self._mapNode.animator:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, function()
|
||||
EventManager.Hit(EventId.ClosePanel, self._panel._nPanelId)
|
||||
end, true, true, true)
|
||||
end
|
||||
function MiningGameQuestCtrl:OnEvent_QuestUpdate()
|
||||
self._mapNode.Group_loop_sv:Init(#self.tbGroup, self, self.OnRefreshGroupGrid)
|
||||
self:UpdateQuestList(self.nSelectedGroupId)
|
||||
end
|
||||
return MiningGameQuestCtrl
|
||||
|
||||
Reference in New Issue
Block a user