Major Update - 2.0.0.143
EN: 2.0.0.143 CN: 2.0.0.142 JP: 2.0.0.145 KR: 2.0.0.150
This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
local DormQuestCtrl = class("DormQuestCtrl", BaseCtrl)
|
||||
local DormGuideUI = require("Game.UI.Dorm.DormGuideUI")
|
||||
DormQuestCtrl._mapNodeConfig = {
|
||||
imgChapter = {sComponentName = "Image"},
|
||||
txtChapter = {sComponentName = "TMP_Text"},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dorm_Quest_GroupTitle"
|
||||
},
|
||||
txtNum = {sComponentName = "TMP_Text"},
|
||||
txtActComplete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_undone"
|
||||
},
|
||||
txtBtnReceiveChapter = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Receive_Btn_Text"
|
||||
},
|
||||
txtBtnFastReceiveGray = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Fast_Receive_Btn_Text"
|
||||
},
|
||||
txtBtnFastReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Fast_Receive_Btn_Text"
|
||||
},
|
||||
imgComplete = {},
|
||||
rewardItem = {
|
||||
nCount = 5,
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
btnRewardItem = {
|
||||
sComponentName = "UIButton",
|
||||
nCount = 5,
|
||||
callback = "OnBtnClick_GroupReward"
|
||||
},
|
||||
imgEmpty = {nCount = 5},
|
||||
btnReceiveChapter = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GroupReceive"
|
||||
},
|
||||
guideQuestLSV = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnFastReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_FastReceive"
|
||||
},
|
||||
btnFastReceiveGray = {sComponentName = "UIButton"},
|
||||
btnCloseQuest = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
snapshot = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
rtQuest = {sComponentName = "Animator"}
|
||||
}
|
||||
DormQuestCtrl._mapEventConfig = {
|
||||
DormQuestGridReceive = "OnEvent_GridRecieveClick"
|
||||
}
|
||||
DormQuestCtrl._mapRedDotConfig = {}
|
||||
function DormQuestCtrl:Awake()
|
||||
self._mapCtrl = {}
|
||||
end
|
||||
function DormQuestCtrl:FadeIn()
|
||||
end
|
||||
function DormQuestCtrl:FadeOut()
|
||||
end
|
||||
function DormQuestCtrl:OnEnable()
|
||||
self.bNeedBlockOperate = false
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.bNeedBlockOperate = tbParam[1] == true
|
||||
end
|
||||
if self.bNeedBlockOperate then
|
||||
NovaAPI.DispatchEventWithData("DORM_LUA_SET_UI_HIDDEN", nil, {61})
|
||||
end
|
||||
local wait = function()
|
||||
self._mapNode.rtQuest.gameObject:SetActive(false)
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
NovaAPI.UIEffectSnapShotCapture(self._mapNode.snapshot.gameObject)
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.rtQuest.gameObject:SetActive(true)
|
||||
self._mapNode.rtQuest:Play("rtQuest_in")
|
||||
DormGuideUI.BindOverlay("quest", self)
|
||||
self:RefreshPanel()
|
||||
if DormGuideUI._bQuestLock then
|
||||
self:SetGuideOperateLock(true)
|
||||
end
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function DormQuestCtrl:RefreshPanel()
|
||||
self.tbGroupRewardId = {}
|
||||
local nCurGroup, nGroupState, tbQuest = PlayerData.PlayerDormData:GetDormQuestDataWithGroup()
|
||||
self.nCurGroup = nCurGroup
|
||||
self.nGroupState = nGroupState
|
||||
local bFastReceive = false
|
||||
if self.nCurGroup ~= 0 then
|
||||
if tbQuest == nil then
|
||||
tbQuest = {}
|
||||
end
|
||||
else
|
||||
tbQuest = {}
|
||||
local nCurGroup = 0
|
||||
local forEachGroup = function(mapData)
|
||||
nCurGroup = math.max(nCurGroup, mapData.Id)
|
||||
end
|
||||
ForEachTableLine(DataTable.DormQuestGroup, forEachGroup)
|
||||
if nCurGroup ~= 0 then
|
||||
self.nCurGroup = nCurGroup
|
||||
self.nGroupState = 1
|
||||
do
|
||||
local forEachQuest = function(mapData)
|
||||
if mapData.DormQuestGroup == nCurGroup then
|
||||
table.insert(tbQuest, {
|
||||
nTid = mapData.Id,
|
||||
nGoal = 0,
|
||||
nCurProgress = 0,
|
||||
nStatus = 2,
|
||||
nExpire = -1
|
||||
})
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.DormQuest, forEachQuest)
|
||||
end
|
||||
end
|
||||
end
|
||||
local statusOrder = {
|
||||
[0] = 1,
|
||||
[1] = 2,
|
||||
[2] = 0
|
||||
}
|
||||
local sort = function(a, b)
|
||||
if a.nStatus ~= b.nStatus then
|
||||
return statusOrder[a.nStatus] > statusOrder[b.nStatus]
|
||||
end
|
||||
return a.nTid < b.nTid
|
||||
end
|
||||
table.sort(tbQuest, sort)
|
||||
self.tbQuest = tbQuest
|
||||
local DormGuideUI = require("Game.UI.Dorm.DormGuideUI")
|
||||
if DormGuideUI.IsLeaveLocked() then
|
||||
self._mapNode.guideQuestLSV:SetAnim(0)
|
||||
else
|
||||
self._mapNode.guideQuestLSV:SetAnim(0.08)
|
||||
end
|
||||
self._mapNode.guideQuestLSV:Init(#tbQuest, self, self.OnGridRefresh)
|
||||
self:RefreshGroup()
|
||||
end
|
||||
function DormQuestCtrl:RefreshGroup()
|
||||
local bFastReceive = false
|
||||
local mapGroupCfgData = ConfigTable.GetData("DormQuestGroup", self.nCurGroup)
|
||||
if mapGroupCfgData == nil then
|
||||
return
|
||||
end
|
||||
self.tbGroupRewardId = {
|
||||
mapGroupCfgData.Item1,
|
||||
mapGroupCfgData.Item2,
|
||||
mapGroupCfgData.Item3
|
||||
}
|
||||
for i = 1, 3 do
|
||||
self._mapNode.rewardItem[i].gameObject:SetActive(mapGroupCfgData["Item" .. i] ~= 0)
|
||||
self._mapNode.imgEmpty[i].gameObject:SetActive(mapGroupCfgData["Item" .. i] == 0)
|
||||
if mapGroupCfgData["Item" .. i] ~= 0 then
|
||||
self._mapNode.rewardItem[i]:SetItem(mapGroupCfgData["Item" .. i], nil, mapGroupCfgData["Qty" .. i], nil, self.nGroupState == 1, nil, nil, true)
|
||||
end
|
||||
end
|
||||
local nTotalCount = 0
|
||||
local nCurCount = 0
|
||||
if self.tbQuest ~= nil then
|
||||
for _, v in ipairs(self.tbQuest) do
|
||||
nTotalCount = nTotalCount + 1
|
||||
if v.nStatus == 2 then
|
||||
nCurCount = nCurCount + 1
|
||||
end
|
||||
if v.nStatus == 1 then
|
||||
bFastReceive = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if nTotalCount <= nCurCount and self.nGroupState == 0 then
|
||||
bFastReceive = true
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtChapter, mapGroupCfgData.Title)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtNum, string.format("%d/%d", nCurCount, nTotalCount))
|
||||
self._mapNode.imgComplete:SetActive(self.nGroupState == 1)
|
||||
self._mapNode.txtActComplete.gameObject:SetActive(nTotalCount > nCurCount and self.nGroupState == 0)
|
||||
self._mapNode.btnReceiveChapter.gameObject:SetActive(nTotalCount <= nCurCount and self.nGroupState == 0)
|
||||
self._mapNode.btnFastReceiveGray.gameObject:SetActive(not bFastReceive)
|
||||
self._mapNode.btnFastReceive.gameObject:SetActive(bFastReceive)
|
||||
end
|
||||
function DormQuestCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
if self._mapCtrl[goGrid] == nil then
|
||||
self._mapCtrl[goGrid] = self:BindCtrlByNode(goGrid, "Game.UI.Dorm.DormQuest.DormQuestGridCtrl")
|
||||
end
|
||||
local nIdx = gridIndex + 1
|
||||
self._mapCtrl[goGrid]:Refresh(self.tbQuest[nIdx])
|
||||
if DormGuideUI._bQuestLock then
|
||||
self:SetGuideOperateLock(true)
|
||||
end
|
||||
end
|
||||
function DormQuestCtrl:OnDisable()
|
||||
if self.bNeedBlockOperate then
|
||||
NovaAPI.DispatchEventWithData("DORM_LUA_SET_UI_HIDDEN", nil, {0})
|
||||
end
|
||||
DormGuideUI.UnbindOverlay("quest", self)
|
||||
for nInstanceId, objCtrl in pairs(self._mapCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
end
|
||||
self._mapCtrl = nil
|
||||
end
|
||||
function DormQuestCtrl:OnDestroy()
|
||||
end
|
||||
function DormQuestCtrl:OnRelease()
|
||||
end
|
||||
function DormQuestCtrl:OnBtnClick_Close()
|
||||
self._mapNode.rtQuest:Play("rtQuest_out")
|
||||
self:AddTimer(1, 0.25, function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.DormQuestPanel)
|
||||
end, true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.25)
|
||||
end
|
||||
function DormQuestCtrl:OnBtnClick_FastReceive()
|
||||
local callback = function()
|
||||
self:RefreshPanel()
|
||||
end
|
||||
PlayerData.Quest:ReceiveDormQuest(0, 0, callback)
|
||||
end
|
||||
function DormQuestCtrl:OnBtnClick_GroupReceive()
|
||||
local callback = function()
|
||||
self:RefreshPanel()
|
||||
end
|
||||
PlayerData.Quest:ReceiveDormQuest(1, self.nCurGroup, callback)
|
||||
end
|
||||
function DormQuestCtrl:OnBtnClick_GroupReward(btn, nIdx)
|
||||
local nItemId = self.tbGroupRewardId[nIdx]
|
||||
if nItemId ~= nil then
|
||||
UTILS.ClickItemGridWithTips(nItemId, btn.transform, true, true, false)
|
||||
end
|
||||
end
|
||||
function DormQuestCtrl:SetGuideOperateLock(bLock)
|
||||
local SetBtn = function(btn, bOn)
|
||||
if btn ~= nil then
|
||||
btn.interactable = bOn
|
||||
end
|
||||
end
|
||||
SetBtn(self._mapNode.btnCloseQuest, not bLock)
|
||||
SetBtn(self._mapNode.snapshot, not bLock)
|
||||
SetBtn(self._mapNode.btnFastReceive, not bLock)
|
||||
if self._mapCtrl == nil then
|
||||
return
|
||||
end
|
||||
for _, objGrid in pairs(self._mapCtrl) do
|
||||
if objGrid._mapNode ~= nil and objGrid._mapNode.btnReceive ~= nil then
|
||||
local bCan = objGrid.mapDormQuest ~= nil and objGrid.mapDormQuest.nStatus == 1
|
||||
objGrid._mapNode.btnReceive.interactable = not bLock and bCan
|
||||
end
|
||||
end
|
||||
end
|
||||
function DormQuestCtrl:IsGuideEnterDone()
|
||||
local DormGuideAdapter = require("Game.UI.Dorm.DormGuideAdapter")
|
||||
return DormGuideAdapter.AnimatorSettled(self._mapNode.rtQuest, "rtQuest_in")
|
||||
end
|
||||
function DormQuestCtrl:OnEvent_GridRecieveClick(nId)
|
||||
local DormGuideAdapter = require("Game.UI.Dorm.DormGuideAdapter")
|
||||
local callback = function()
|
||||
self:RefreshPanel()
|
||||
DormGuideAdapter.NoteQuest(nId, true)
|
||||
if DormGuideUI._bQuestLock then
|
||||
self:SetGuideOperateLock(true)
|
||||
end
|
||||
end
|
||||
PlayerData.Quest:ReceiveDormQuest(0, nId, callback)
|
||||
end
|
||||
return DormQuestCtrl
|
||||
@@ -0,0 +1,109 @@
|
||||
local DormQuestGridCtrl = class("DormQuestGridCtrl", BaseCtrl)
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
local totalLength = 616
|
||||
local totalHeight = 37
|
||||
DormQuestGridCtrl._mapNodeConfig = {
|
||||
txtQuestDesc = {sComponentName = "TMP_Text"},
|
||||
txtProgress = {sComponentName = "TMP_Text"},
|
||||
txtUnComplete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_undone"
|
||||
},
|
||||
txtBtnReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Receive_Btn_Text"
|
||||
},
|
||||
txtBtnJump = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_JumpTo_Text"
|
||||
},
|
||||
imgReceived = {},
|
||||
imgCompleteMask = {},
|
||||
rtProgressFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
btnItem = {
|
||||
sComponentName = "UIButton",
|
||||
nCount = 2,
|
||||
callback = "OnBtnClick_Reward"
|
||||
},
|
||||
btnReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Receive"
|
||||
},
|
||||
btnJump = {sComponentName = "UIButton"},
|
||||
goRewardItem = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl",
|
||||
nCount = 2
|
||||
},
|
||||
imgRewardEmpty = {nCount = 2}
|
||||
}
|
||||
DormQuestGridCtrl._mapEventConfig = {}
|
||||
DormQuestGridCtrl._mapRedDotConfig = {}
|
||||
function DormQuestGridCtrl:Awake()
|
||||
end
|
||||
function DormQuestGridCtrl:FadeIn()
|
||||
end
|
||||
function DormQuestGridCtrl:FadeOut()
|
||||
end
|
||||
function DormQuestGridCtrl:OnEnable()
|
||||
end
|
||||
function DormQuestGridCtrl:OnDisable()
|
||||
end
|
||||
function DormQuestGridCtrl:OnDestroy()
|
||||
end
|
||||
function DormQuestGridCtrl:OnRelease()
|
||||
end
|
||||
function DormQuestGridCtrl:Refresh(mapDormQuest)
|
||||
if mapDormQuest == nil then
|
||||
self.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
local mapDormQuestCfgData = ConfigTable.GetData("DormQuest", mapDormQuest.nTid)
|
||||
if mapDormQuestCfgData == nil then
|
||||
self.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
self.mapDormQuestCfgData = mapDormQuestCfgData
|
||||
self.mapDormQuest = mapDormQuest
|
||||
NovaAPI.SetTMPText(self._mapNode.txtQuestDesc, mapDormQuestCfgData.Title)
|
||||
self.tbRewardId = {
|
||||
mapDormQuestCfgData.Reward1,
|
||||
mapDormQuestCfgData.Reward2
|
||||
}
|
||||
for i = 1, 2 do
|
||||
self._mapNode.goRewardItem[i].gameObject:SetActive(mapDormQuestCfgData["Reward" .. i] ~= 0)
|
||||
self._mapNode.imgRewardEmpty[i].gameObject:SetActive(mapDormQuestCfgData["Reward" .. i] == 0)
|
||||
if mapDormQuestCfgData["Reward" .. i] ~= 0 then
|
||||
self._mapNode.goRewardItem[i]:SetItem(mapDormQuestCfgData["Reward" .. i], nil, mapDormQuestCfgData["RewardQty" .. i], nil, mapDormQuest.nStatus == 2, nil, nil, true)
|
||||
end
|
||||
end
|
||||
if mapDormQuest.nStatus ~= 2 then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", mapDormQuest.nCurProgress, mapDormQuest.nGoal))
|
||||
self._mapNode.rtProgressFill.sizeDelta = Vector2(mapDormQuest.nCurProgress / mapDormQuest.nGoal * totalLength, totalHeight)
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, ConfigTable.GetUIText("Quest_Complete"))
|
||||
self._mapNode.rtProgressFill.sizeDelta = Vector2(totalLength, totalHeight)
|
||||
end
|
||||
self._mapNode.imgReceived:SetActive(mapDormQuest.nStatus == 2)
|
||||
self._mapNode.imgCompleteMask:SetActive(mapDormQuest.nStatus == 2)
|
||||
self._mapNode.txtUnComplete.gameObject:SetActive(mapDormQuest.nStatus == 0 and mapDormQuestCfgData.JumpTo == 0)
|
||||
self._mapNode.btnJump.gameObject:SetActive(mapDormQuest.nStatus == 0 and mapDormQuestCfgData.JumpTo ~= 0)
|
||||
self._mapNode.btnReceive.gameObject:SetActive(mapDormQuest.nStatus == 1)
|
||||
end
|
||||
function DormQuestGridCtrl:ShowItemDetail(id, rtIcon)
|
||||
UTILS.ClickItemGridWithTips(id, rtIcon.transform, true, true, false)
|
||||
end
|
||||
function DormQuestGridCtrl:OnBtnClick_Receive()
|
||||
EventManager.Hit("DormQuestGridReceive", self.mapDormQuest.nTid)
|
||||
end
|
||||
function DormQuestGridCtrl:OnBtnClick_JumpTo()
|
||||
local nJumptoId = self.mapDormQuestCfgData.JumpTo
|
||||
JumpUtil.JumpTo(nJumptoId)
|
||||
end
|
||||
function DormQuestGridCtrl:OnBtnClick_Reward(btn, nIdx)
|
||||
if self.tbRewardId[nIdx] ~= 0 then
|
||||
self:ShowItemDetail(self.tbRewardId[nIdx], btn)
|
||||
end
|
||||
end
|
||||
return DormQuestGridCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local DormQuestPanel = class("DormQuestPanel", BasePanel)
|
||||
DormQuestPanel._bIsMainPanel = false
|
||||
DormQuestPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Dorm/DormQuestPanel.prefab",
|
||||
sCtrlName = "Game.UI.Dorm.DormQuest.DormQuestCtrl"
|
||||
}
|
||||
}
|
||||
function DormQuestPanel:Awake()
|
||||
end
|
||||
function DormQuestPanel:OnEnable()
|
||||
end
|
||||
function DormQuestPanel:OnAfterEnter()
|
||||
end
|
||||
function DormQuestPanel:OnDisable()
|
||||
end
|
||||
function DormQuestPanel:OnDestroy()
|
||||
end
|
||||
function DormQuestPanel:OnRelease()
|
||||
end
|
||||
return DormQuestPanel
|
||||
Reference in New Issue
Block a user