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,221 @@
|
||||
local GuideMissionCtrl = class("GuideMissionCtrl", BaseCtrl)
|
||||
local GuideMissionData = PlayerData.GuideMission
|
||||
GuideMissionCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
rtChapterList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
tog = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnToggleChange"
|
||||
},
|
||||
rtReview = {
|
||||
sCtrlName = "Game.UI.GuideMission.GuideMissionQuestCtrl"
|
||||
},
|
||||
rtShop = {
|
||||
sCtrlName = "Game.UI.GuideMission.GuideMissionShopCtrl"
|
||||
}
|
||||
}
|
||||
GuideMissionCtrl._mapEventConfig = {
|
||||
GuideMissionQuestGoBack = "OnGuideMissionQuestGoBack",
|
||||
GuideMissionQuestGroupChange = "OnGuideMissionQuestGroupChange"
|
||||
}
|
||||
local ToggleText = {
|
||||
[1] = "GuideMission_Boss_Record",
|
||||
[2] = "GuideMission_Item_Change",
|
||||
[3] = "GuideMission_Disc_Change"
|
||||
}
|
||||
local nLastReviewChapterId, nLastReviewGroupIndex
|
||||
function GuideMissionCtrl:FadeIn(bPlayFadeIn)
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
end
|
||||
function GuideMissionCtrl:Awake()
|
||||
self.tbRedDotLastChapterId = self.tbRedDotLastChapterId or {}
|
||||
end
|
||||
function GuideMissionCtrl:OnEnable()
|
||||
self:SetContentVisible(false)
|
||||
local tbParam = self:GetPanelParam()
|
||||
local nJumpTog = 1
|
||||
if tbParam ~= nil and tbParam[1] ~= nil then
|
||||
nJumpTog = tbParam[1]
|
||||
end
|
||||
self.nJumpTogIndex = nJumpTog
|
||||
PlayerData.Quest:RequestGuideMissionInfo(function()
|
||||
self:RefreshPanel()
|
||||
end)
|
||||
end
|
||||
function GuideMissionCtrl:OnDisable()
|
||||
end
|
||||
function GuideMissionCtrl:OnDestroy()
|
||||
end
|
||||
function GuideMissionCtrl:SetContentVisible(bVisible)
|
||||
for _, tog in ipairs(self._mapNode.tog) do
|
||||
tog.gameObject:SetActive(bVisible)
|
||||
end
|
||||
self._mapNode.rtChapterList.gameObject:SetActive(false)
|
||||
self._mapNode.rtReview.gameObject:SetActive(false)
|
||||
self._mapNode.rtShop.gameObject:SetActive(false)
|
||||
end
|
||||
function GuideMissionCtrl:RefreshPanel()
|
||||
self:SetContentVisible(true)
|
||||
self:RefreshChapterList()
|
||||
self:RefreshTog()
|
||||
self.nCurTogIndex = nil
|
||||
self.bInReview = false
|
||||
self:OnToggleChange(nil, self.nJumpTogIndex or 1)
|
||||
if self.nJumpTogIndex == nil or self.nJumpTogIndex == 1 then
|
||||
if nLastReviewChapterId ~= nil then
|
||||
local bUnlock = GuideMissionData:IsChapterUnlock(nLastReviewChapterId)
|
||||
if bUnlock then
|
||||
self:EnterReview(nLastReviewChapterId, nLastReviewGroupIndex)
|
||||
else
|
||||
nLastReviewChapterId = nil
|
||||
nLastReviewGroupIndex = nil
|
||||
end
|
||||
else
|
||||
local nChapterId = GuideMissionData:FindReceivableChapter()
|
||||
if nChapterId ~= nil then
|
||||
self:EnterReview(nChapterId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function GuideMissionCtrl:RefreshTog()
|
||||
for nIndex, tog in ipairs(self._mapNode.tog) do
|
||||
local animSwitch = tog.gameObject.transform:Find("AnimRoot/AnimSwitch")
|
||||
local txtSelect = animSwitch:Find("txt_Select"):GetComponent("TMP_Text")
|
||||
local txtUnSelect = animSwitch:Find("txt_unSelect"):GetComponent("TMP_Text")
|
||||
local sText = ConfigTable.GetUIText(ToggleText[nIndex])
|
||||
NovaAPI.SetTMPText(txtSelect, sText)
|
||||
NovaAPI.SetTMPText(txtUnSelect, sText)
|
||||
end
|
||||
end
|
||||
function GuideMissionCtrl:RefreshChapterList()
|
||||
self.tbChapterList = GuideMissionData:GetChapterList()
|
||||
self._mapNode.rtChapterList:Init(#self.tbChapterList + 1, self, self.OnChapterGridRefresh)
|
||||
end
|
||||
function GuideMissionCtrl:OnChapterGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapChapter = self.tbChapterList[nIndex]
|
||||
local btn = goGrid.transform:Find("btn"):GetComponent("UIButton")
|
||||
btn.onClick:RemoveAllListeners()
|
||||
btn.onClick:AddListener(function()
|
||||
self:OnChapterGridBtnClick(goGrid, gridIndex)
|
||||
end)
|
||||
local rootTrans = goGrid.transform:Find("btn/AnimRoot")
|
||||
local goUnlock = rootTrans:Find("goUnlock")
|
||||
local goLock = rootTrans:Find("goLock")
|
||||
local goComplete = rootTrans:Find("goComplete")
|
||||
local goEmpty = rootTrans:Find("goEmpty")
|
||||
local bEmpty = mapChapter == nil
|
||||
local imgTitle4Lock = rootTrans:Find("imgTitle4Lock"):GetComponent("Image")
|
||||
local imgTitle4 = rootTrans:Find("imgTitle4"):GetComponent("Image")
|
||||
local txtTitleEmpty = goEmpty:Find("txtTitleEmpty"):GetComponent("TMP_Text")
|
||||
goEmpty.gameObject:SetActive(bEmpty)
|
||||
NovaAPI.SetTMPText(txtTitleEmpty, ConfigTable.GetUIText("StorySet_Chapter_Empty"))
|
||||
if bEmpty then
|
||||
goLock.gameObject:SetActive(false)
|
||||
goComplete.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
local bUnlock, sLockReson = GuideMissionData:IsChapterUnlock(mapChapter.Id)
|
||||
goLock.gameObject:SetActive(not bUnlock)
|
||||
imgTitle4Lock.gameObject:SetActive(not bUnlock)
|
||||
imgTitle4.gameObject:SetActive(bUnlock)
|
||||
local imgChapterPic = goUnlock:Find("imgChapterPic"):GetComponent("Image")
|
||||
local imgStar = goUnlock:Find("imgChapterPic/imgStar"):GetComponent("Image")
|
||||
local txtChapterIndex = goUnlock:Find("imgTitle1/txtChapterIndex"):GetComponent("TMP_Text")
|
||||
local txtTitle = goUnlock:Find("txtTitle"):GetComponent("TMP_Text")
|
||||
self:SetPngSprite(imgChapterPic, mapChapter.IconPath)
|
||||
self:SetPngSprite(imgStar, mapChapter.IconPath)
|
||||
NovaAPI.SetTMPText(txtChapterIndex, mapChapter.Index)
|
||||
NovaAPI.SetTMPText(txtTitle, mapChapter.Title)
|
||||
if not bUnlock then
|
||||
local txtLock = goLock:Find("txtLock"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtLock, sLockReson)
|
||||
end
|
||||
local isComplete = GuideMissionData:IsChapterComplete(mapChapter.Id)
|
||||
goComplete.gameObject:SetActive(isComplete)
|
||||
if isComplete then
|
||||
local txtComplete = goComplete:Find("imgBg/txtComplete"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtComplete, ConfigTable.GetUIText("PerActivity_Quest_Complete"))
|
||||
end
|
||||
local goRedDot = rootTrans:Find("ChapterRedDot")
|
||||
local nGoInstanceId = goRedDot.gameObject:GetInstanceID()
|
||||
local nLastChapterId = self.tbRedDotLastChapterId[nGoInstanceId]
|
||||
if nLastChapterId ~= nil and nLastChapterId ~= mapChapter.Id then
|
||||
RedDotManager.UnRegisterNode(RedDotDefine.GuideMission_Chapter, nLastChapterId, goRedDot.gameObject)
|
||||
end
|
||||
self.tbRedDotLastChapterId[nGoInstanceId] = mapChapter.Id
|
||||
RedDotManager.RegisterNode(RedDotDefine.GuideMission_Chapter, mapChapter.Id, goRedDot.gameObject)
|
||||
end
|
||||
function GuideMissionCtrl:OnChapterGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapChapter = self.tbChapterList[nIndex]
|
||||
if mapChapter == nil then
|
||||
return
|
||||
end
|
||||
local bUnlock, sLockReson = GuideMissionData:IsChapterUnlock(mapChapter.Id)
|
||||
if not bUnlock then
|
||||
EventManager.Hit(EventId.OpenMessageBox, sLockReson)
|
||||
return
|
||||
end
|
||||
self:EnterReview(mapChapter.Id)
|
||||
end
|
||||
function GuideMissionCtrl:EnterReview(nChapterId, nGroupIndex)
|
||||
nLastReviewChapterId = nChapterId
|
||||
nLastReviewGroupIndex = nGroupIndex
|
||||
self.bInReview = true
|
||||
self._mapNode.rtReview:RefreshPanel(nChapterId, nGroupIndex)
|
||||
self._mapNode.rtReview.gameObject:SetActive(true)
|
||||
self._mapNode.rtChapterList.gameObject:SetActive(false)
|
||||
end
|
||||
function GuideMissionCtrl:OnToggleChange(btn, nIndex)
|
||||
if self.nCurTogIndex == nIndex then
|
||||
return
|
||||
end
|
||||
if self.nCurTogIndex ~= nil then
|
||||
local animSwitchOff = self._mapNode.tog[self.nCurTogIndex].gameObject.transform:Find("AnimRoot/AnimSwitch"):GetComponent("Animator")
|
||||
animSwitchOff:Play("t_tog_01_switch_off")
|
||||
end
|
||||
local animSwitchOn = self._mapNode.tog[nIndex].gameObject.transform:Find("AnimRoot/AnimSwitch"):GetComponent("Animator")
|
||||
animSwitchOn:Play("t_tog_01_switch_in")
|
||||
self.nCurTogIndex = nIndex
|
||||
self._mapNode.rtReview.gameObject:SetActive(false)
|
||||
if nIndex == 2 or nIndex == 3 then
|
||||
self._mapNode.rtChapterList.gameObject:SetActive(false)
|
||||
self._mapNode.rtShop.gameObject:SetActive(true)
|
||||
self._mapNode.rtShop:EnterShop(nIndex)
|
||||
else
|
||||
self._mapNode.rtShop:ExitShop()
|
||||
self._mapNode.rtShop.gameObject:SetActive(false)
|
||||
if self.bInReview then
|
||||
self._mapNode.rtReview.gameObject:SetActive(true)
|
||||
self._mapNode.rtChapterList.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.rtChapterList.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
function GuideMissionCtrl:OnGuideMissionQuestGroupChange(nChapterId, nGroupIndex)
|
||||
nLastReviewChapterId = nChapterId
|
||||
nLastReviewGroupIndex = nGroupIndex
|
||||
end
|
||||
function GuideMissionCtrl:OnGuideMissionQuestGoBack()
|
||||
nLastReviewChapterId = nil
|
||||
nLastReviewGroupIndex = nil
|
||||
self.bInReview = false
|
||||
self._mapNode.rtReview.gameObject:SetActive(false)
|
||||
self._mapNode.rtChapterList.gameObject:SetActive(true)
|
||||
self:RefreshChapterList()
|
||||
PlayerData.Quest:RequestGuideMissionInfo(function()
|
||||
if self.bInReview == false and self.nCurTogIndex == 1 then
|
||||
self:RefreshChapterList()
|
||||
end
|
||||
end)
|
||||
end
|
||||
return GuideMissionCtrl
|
||||
@@ -0,0 +1,16 @@
|
||||
local GuideMissionPanel = class("GuideMissionPanel", BasePanel)
|
||||
GuideMissionPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "GuideMission/GuideMissionPanel.prefab",
|
||||
sCtrlName = "Game.UI.GuideMission.GuideMissionCtrl"
|
||||
}
|
||||
}
|
||||
function GuideMissionPanel:Awake()
|
||||
end
|
||||
function GuideMissionPanel:OnEnable()
|
||||
end
|
||||
function GuideMissionPanel:OnDisable()
|
||||
end
|
||||
function GuideMissionPanel:OnDestroy()
|
||||
end
|
||||
return GuideMissionPanel
|
||||
@@ -0,0 +1,349 @@
|
||||
local GuideMissionQuestCtrl = class("GuideMissionQuestCtrl", BaseCtrl)
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local GuideMissionData = PlayerData.GuideMission
|
||||
GuideMissionQuestCtrl._mapNodeConfig = {
|
||||
PerActGroupItem = {
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnGroupBtnClick"
|
||||
},
|
||||
btnGroupLock = {
|
||||
sNodeName = "btnGroupLock",
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GroupLock"
|
||||
},
|
||||
imgChapterPicture = {sComponentName = "Image"},
|
||||
imgChapterStar = {sComponentName = "Image"},
|
||||
txtChapterIndex = {sComponentName = "TMP_Text"},
|
||||
txtTitle = {sComponentName = "TMP_Text"},
|
||||
srGuideQuest = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnQuickRec = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_QuickRec"
|
||||
},
|
||||
txtBtnQuickRec = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Fast_Receive_Btn_Text"
|
||||
},
|
||||
btnGoBack = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GoBack"
|
||||
},
|
||||
txtBtnGoBack = {sComponentName = "TMP_Text", sLanguageId = "Go_Back"},
|
||||
btnQuickRecGray = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_QuickRecGray"
|
||||
},
|
||||
txtBtnQuickRecGray = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Fast_Receive_Btn_Text"
|
||||
}
|
||||
}
|
||||
GuideMissionQuestCtrl._mapEventConfig = {}
|
||||
function GuideMissionQuestCtrl:RefreshPanel(nChapterId, nGroupIndex)
|
||||
self.nChapterId = nChapterId
|
||||
local mapChapter = ConfigTable.GetData("GuideMissionChapter", nChapterId)
|
||||
self:SetPngSprite(self._mapNode.imgChapterPicture, mapChapter.IconPath)
|
||||
self:SetPngSprite(self._mapNode.imgChapterStar, mapChapter.IconPath)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtChapterIndex, mapChapter.Index)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitle, mapChapter.Title)
|
||||
local tbGroupListRef = PlayerData.Quest:GetGuideMissionQuestGroupByChapter(nChapterId)
|
||||
self.tbGroupList = {}
|
||||
if tbGroupListRef ~= nil then
|
||||
for _, mapGroup in pairs(tbGroupListRef) do
|
||||
table.insert(self.tbGroupList, mapGroup)
|
||||
end
|
||||
end
|
||||
table.sort(self.tbGroupList, function(a, b)
|
||||
return a.Id < b.Id
|
||||
end)
|
||||
local mapJumpGroup = nGroupIndex ~= nil and self.tbGroupList[nGroupIndex] or nil
|
||||
local bJumpGroupUnlock = mapJumpGroup ~= nil and GuideMissionData:IsGroupUnlock(self.nChapterId, mapJumpGroup.Id)
|
||||
self:RefreshQuestList(bJumpGroupUnlock and nGroupIndex or self:GetDefaultGroupIndex())
|
||||
end
|
||||
function GuideMissionQuestCtrl:GetDefaultGroupIndex()
|
||||
local nDefaultIndex = 1
|
||||
local nMaxGroupId
|
||||
for nIndex, mapGroup in ipairs(self.tbGroupList) do
|
||||
local bUnlock = GuideMissionData:IsGroupUnlock(self.nChapterId, mapGroup.Id)
|
||||
if bUnlock and self:HasReceivableQuest(mapGroup.Id) and (nMaxGroupId == nil or nMaxGroupId < mapGroup.Id) then
|
||||
nMaxGroupId = mapGroup.Id
|
||||
nDefaultIndex = nIndex
|
||||
end
|
||||
end
|
||||
return nDefaultIndex
|
||||
end
|
||||
function GuideMissionQuestCtrl:HasReceivableQuest(nGroupId)
|
||||
local tbQuestList = PlayerData.Quest:GetGuideMissionQuestListByGroup(nGroupId)
|
||||
if tbQuestList == nil then
|
||||
return false
|
||||
end
|
||||
for _, mapQuest in pairs(tbQuestList) do
|
||||
local mapQuestData = PlayerData.Quest:GetGuideMissionQuestDataById(mapQuest.Id)
|
||||
if mapQuestData ~= nil and mapQuestData.nStatus == 1 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
function GuideMissionQuestCtrl:RefreshQuestList(nIndex)
|
||||
local mapGroup = self.tbGroupList[nIndex]
|
||||
if mapGroup == nil then
|
||||
return
|
||||
end
|
||||
local bUnlock = GuideMissionData:IsGroupUnlock(self.nChapterId, mapGroup.Id)
|
||||
if not bUnlock then
|
||||
return
|
||||
end
|
||||
self:RefreshGroupItemSelect(nIndex)
|
||||
self.nCurGroupIndex = nIndex
|
||||
EventManager.Hit("GuideMissionQuestGroupChange", self.nChapterId, nIndex)
|
||||
local tbQuestListRef = PlayerData.Quest:GetGuideMissionQuestListByGroup(mapGroup.Id)
|
||||
self.tbQuestList = {}
|
||||
if tbQuestListRef ~= nil then
|
||||
for _, mapQuest in pairs(tbQuestListRef) do
|
||||
table.insert(self.tbQuestList, mapQuest)
|
||||
end
|
||||
end
|
||||
local tbStatusOrder = {
|
||||
[1] = 0,
|
||||
[0] = 1,
|
||||
[2] = 2
|
||||
}
|
||||
table.sort(self.tbQuestList, function(a, b)
|
||||
local mapQuestDataA = PlayerData.Quest:GetGuideMissionQuestDataById(a.Id)
|
||||
local mapQuestDataB = PlayerData.Quest:GetGuideMissionQuestDataById(b.Id)
|
||||
local nStatusA = mapQuestDataA ~= nil and mapQuestDataA.nStatus or 0
|
||||
local nStatusB = mapQuestDataB ~= nil and mapQuestDataB.nStatus or 0
|
||||
if nStatusA ~= nStatusB then
|
||||
return tbStatusOrder[nStatusA] < tbStatusOrder[nStatusB]
|
||||
end
|
||||
return a.Id < b.Id
|
||||
end)
|
||||
self._mapNode.srGuideQuest:Init(#self.tbQuestList, self, self.OnGridRefresh)
|
||||
local bCanReceive = false
|
||||
local mapFirstQuestData = self.tbQuestList[1] ~= nil and PlayerData.Quest:GetGuideMissionQuestDataById(self.tbQuestList[1].Id) or nil
|
||||
if mapFirstQuestData ~= nil and mapFirstQuestData.nStatus == 1 then
|
||||
bCanReceive = true
|
||||
end
|
||||
self._mapNode.btnQuickRec.gameObject:SetActive(bCanReceive)
|
||||
self._mapNode.btnQuickRecGray.gameObject:SetActive(not bCanReceive)
|
||||
end
|
||||
function GuideMissionQuestCtrl:IsGroupQuestComplete(nGroupId)
|
||||
local tbQuestList = PlayerData.Quest:GetGuideMissionQuestListByGroup(nGroupId)
|
||||
if tbQuestList == nil or next(tbQuestList) == nil then
|
||||
return false
|
||||
end
|
||||
for _, mapQuest in pairs(tbQuestList) do
|
||||
local mapQuestData = PlayerData.Quest:GetGuideMissionQuestDataById(mapQuest.Id)
|
||||
local nStatus = mapQuestData ~= nil and mapQuestData.nStatus or 0
|
||||
if nStatus ~= 2 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
function GuideMissionQuestCtrl:RefreshGroupItemSelect(nIndex)
|
||||
local nNextUnlockGroupIndex, nNextUnlockTime
|
||||
for k, v in ipairs(self._mapNode.PerActGroupItem) do
|
||||
local mapGroup = self.tbGroupList[k]
|
||||
local bUnlock, nGroupUnlockTime = false, 0
|
||||
if mapGroup ~= nil then
|
||||
bUnlock, nGroupUnlockTime = GuideMissionData:IsGroupUnlock(self.nChapterId, mapGroup.Id)
|
||||
end
|
||||
local goNormal = v.gameObject.transform:Find("AnimRoot/goNormal")
|
||||
local goSelect = v.gameObject.transform:Find("AnimRoot/goSelect")
|
||||
local goLock = v.gameObject.transform:Find("AnimRoot/goLock")
|
||||
local imgComplete = v.gameObject.transform:Find("AnimRoot/imgComplete")
|
||||
NovaAPI.SetTMPText(goNormal:Find("txt_Group1"):GetComponent("TMP_Text"), k)
|
||||
NovaAPI.SetTMPText(goSelect:Find("txt_Group2"):GetComponent("TMP_Text"), k)
|
||||
NovaAPI.SetTMPText(goLock:Find("txt_Group3"):GetComponent("TMP_Text"), k)
|
||||
goLock.gameObject:SetActive(not bUnlock)
|
||||
goNormal.gameObject:SetActive(bUnlock and k ~= nIndex)
|
||||
goSelect.gameObject:SetActive(bUnlock and k == nIndex)
|
||||
local bGroupComplete = bUnlock and mapGroup ~= nil and self:IsGroupQuestComplete(mapGroup.Id)
|
||||
imgComplete.gameObject:SetActive(bGroupComplete)
|
||||
if not bUnlock and mapGroup ~= nil and nNextUnlockGroupIndex == nil then
|
||||
nNextUnlockGroupIndex = k
|
||||
nNextUnlockTime = nGroupUnlockTime
|
||||
end
|
||||
v.gameObject.transform:Find("AnimRoot/goTime").gameObject:SetActive(false)
|
||||
local redDotGroup = v.gameObject.transform:Find("AnimRoot/redDotGroup")
|
||||
if mapGroup ~= nil then
|
||||
RedDotManager.RegisterNode(RedDotDefine.GuideMission_Group, {
|
||||
self.nChapterId,
|
||||
mapGroup.Id
|
||||
}, redDotGroup.gameObject)
|
||||
end
|
||||
end
|
||||
if self.groupTimeTimer ~= nil then
|
||||
TimerManager.Remove(self.groupTimeTimer)
|
||||
self.groupTimeTimer = nil
|
||||
end
|
||||
if nNextUnlockGroupIndex ~= nil then
|
||||
self.nNextUnlockGroupIndex = nNextUnlockGroupIndex
|
||||
self.nNextUnlockTime = nNextUnlockTime
|
||||
self._mapNode.PerActGroupItem[nNextUnlockGroupIndex].gameObject.transform:Find("AnimRoot/goTime").gameObject:SetActive(true)
|
||||
self:RefreshGroupOpenTime()
|
||||
self.groupTimeTimer = self:AddTimer(0, 1, "RefreshGroupOpenTime", true, true, false)
|
||||
end
|
||||
end
|
||||
function GuideMissionQuestCtrl:RefreshGroupOpenTime()
|
||||
if self.nNextUnlockGroupIndex == nil then
|
||||
return
|
||||
end
|
||||
local v = self._mapNode.PerActGroupItem[self.nNextUnlockGroupIndex]
|
||||
local goTime = v.gameObject.transform:Find("AnimRoot/goTime")
|
||||
local txtOpenTime = goTime:Find("txtOpenTime"):GetComponent("TMP_Text")
|
||||
local nServerTimeStamp = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = self.nNextUnlockTime - nServerTimeStamp
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.groupTimeTimer)
|
||||
self.groupTimeTimer = nil
|
||||
self:RefreshGroupItemSelect(self.nCurGroupIndex)
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime < 3600 then
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("PerActivity_Quest_Open_Time_2") or "", 1)
|
||||
else
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("PerActivity_Quest_Open_Time_1") or "", hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(txtOpenTime, sTimeStr)
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local index = gridIndex + 1
|
||||
local mapQuest = self.tbQuestList[index]
|
||||
local rootTrans = goGrid.transform:Find("AnimRoot/imgBg")
|
||||
local TMPTitle = rootTrans:Find("rtTitle/TMPTitle"):GetComponent("TMP_Text")
|
||||
local rtBarFill = rootTrans:Find("rtTitle/imgBarBg/rtBarFill"):GetComponent("RectTransform")
|
||||
local TMPProcess = rootTrans:Find("rtTitle/imgBarBg/TMPProcess"):GetComponent("TMP_Text")
|
||||
local btnReward1 = rootTrans:Find("btnReward1"):GetComponent("UIButton")
|
||||
local btnReward2 = rootTrans:Find("btnReward2"):GetComponent("UIButton")
|
||||
local itemReward1 = rootTrans:Find("btnReward1/AnimRoot/rtReward")
|
||||
local itemReward2 = rootTrans:Find("btnReward2/AnimRoot/rtReward")
|
||||
local btnReceive = rootTrans:Find("btnReceive"):GetComponent("UIButton")
|
||||
local txtBtnReceive = rootTrans:Find("btnReceive/AnimRoot/txtBtnReceive"):GetComponent("TMP_Text")
|
||||
local btnJump = rootTrans:Find("btnJump"):GetComponent("UIButton")
|
||||
local txtBtnJump = rootTrans:Find("btnJump/AnimRoot/txtBtnJump"):GetComponent("TMP_Text")
|
||||
local imgComplete = rootTrans:Find("imgComplete")
|
||||
local imgCompleteMask = rootTrans:Find("imgCompleteMask")
|
||||
NovaAPI.SetTMPText(TMPTitle, mapQuest.Title)
|
||||
NovaAPI.SetTMPText(txtBtnReceive, ConfigTable.GetUIText("Quest_Receive"))
|
||||
NovaAPI.SetTMPText(txtBtnJump, ConfigTable.GetUIText("Quest_JumpTo"))
|
||||
local mapQuestData = PlayerData.Quest:GetGuideMissionQuestDataById(mapQuest.Id)
|
||||
local nStatus = mapQuestData ~= nil and mapQuestData.nStatus or 0
|
||||
local nCurProgress = mapQuestData ~= nil and mapQuestData.nCurProgress or 0
|
||||
local nGoal = mapQuestData ~= nil and mapQuestData.nGoal or mapQuest.Goal or 0
|
||||
if nStatus ~= 2 then
|
||||
NovaAPI.SetTMPText(TMPProcess, string.format("%d/%d", nCurProgress, nGoal))
|
||||
else
|
||||
NovaAPI.SetTMPText(TMPProcess, ConfigTable.GetUIText("Quest_Complete"))
|
||||
end
|
||||
rtBarFill.sizeDelta = Vector2(0 < nGoal and nCurProgress / nGoal * rtBarFill.parent:GetComponent("RectTransform").rect.width or 0, rtBarFill.sizeDelta.y)
|
||||
btnReceive.gameObject:SetActive(nStatus == 1)
|
||||
btnReceive.onClick:RemoveAllListeners()
|
||||
btnReceive.onClick:AddListener(function()
|
||||
self:OnBtnClick_Receive(mapQuest)
|
||||
end)
|
||||
imgComplete.gameObject:SetActive(nStatus == 2)
|
||||
imgCompleteMask.gameObject:SetActive(nStatus == 2)
|
||||
btnJump.gameObject:SetActive(nStatus == 0 and mapQuest.JumpTo ~= nil and 0 < mapQuest.JumpTo)
|
||||
btnJump.onClick:RemoveAllListeners()
|
||||
btnJump.onClick:AddListener(function()
|
||||
self:OnBtnClick_JumpTo(mapQuest)
|
||||
end)
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = {
|
||||
itemReward1 = self:BindCtrlByNode(itemReward1, "Game.UI.TemplateEx.TemplateItemCtrl"),
|
||||
itemReward2 = self:BindCtrlByNode(itemReward2, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
}
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID].itemReward1:SetItem(mapQuest.Reward1Tid, nil, mapQuest.Reward1Qty)
|
||||
self.tbGridCtrl[nInstanceID].itemReward2:SetItem(mapQuest.Reward2Tid, nil, mapQuest.Reward2Qqty)
|
||||
btnReward1.onClick:RemoveAllListeners()
|
||||
btnReward1.onClick:AddListener(function()
|
||||
self:OnBtnClick_Reward(btnReward1, mapQuest.Reward1Tid)
|
||||
end)
|
||||
btnReward2.onClick:RemoveAllListeners()
|
||||
btnReward2.onClick:AddListener(function()
|
||||
self:OnBtnClick_Reward(btnReward2, mapQuest.Reward2Tid)
|
||||
end)
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_JumpTo(mapQuest)
|
||||
JumpUtil.JumpTo(mapQuest.JumpTo)
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_Reward(btn, nTid)
|
||||
local mapData = {
|
||||
nTid = nTid,
|
||||
bShowDepot = true,
|
||||
bShowJumpto = true
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ItemTips, btn.transform, mapData)
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_Receive(mapQuest)
|
||||
PlayerData.Quest:ReceiveGuideMissionQuestReward(mapQuest.Id, false, function()
|
||||
self:RefreshQuestList(self.nCurGroupIndex)
|
||||
end)
|
||||
end
|
||||
function GuideMissionQuestCtrl:Awake()
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnEnable()
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnDisable()
|
||||
for _, mapCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(mapCtrl.itemReward1)
|
||||
self:UnbindCtrlByNode(mapCtrl.itemReward2)
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
if self.groupTimeTimer ~= nil then
|
||||
TimerManager.Remove(self.groupTimeTimer)
|
||||
self.groupTimeTimer = nil
|
||||
end
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnDestroy()
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnGroupBtnClick(btn, nIndex)
|
||||
self:RefreshQuestList(nIndex)
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_GroupLock()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Guide_Mission_NotOpen"))
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_QuickRec()
|
||||
local mapGroup = self.tbGroupList[self.nCurGroupIndex]
|
||||
if mapGroup == nil then
|
||||
return
|
||||
end
|
||||
local tbQuestList = PlayerData.Quest:GetGuideMissionQuestListByGroup(mapGroup.Id)
|
||||
if tbQuestList == nil then
|
||||
return
|
||||
end
|
||||
local nReceivableTid
|
||||
for _, mapQuest in pairs(tbQuestList) do
|
||||
local mapQuestData = PlayerData.Quest:GetGuideMissionQuestDataById(mapQuest.Id)
|
||||
if mapQuestData ~= nil and mapQuestData.nStatus == 1 then
|
||||
nReceivableTid = mapQuest.Id
|
||||
break
|
||||
end
|
||||
end
|
||||
if nReceivableTid == nil then
|
||||
return
|
||||
end
|
||||
PlayerData.Quest:ReceiveGuideMissionQuestReward(nReceivableTid, true, function()
|
||||
self:RefreshQuestList(self.nCurGroupIndex)
|
||||
end)
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_QuickRecGray()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("DoubleDrop_Reward_Receive_Tip"))
|
||||
end
|
||||
function GuideMissionQuestCtrl:OnBtnClick_GoBack()
|
||||
EventManager.Hit("GuideMissionQuestGoBack")
|
||||
end
|
||||
return GuideMissionQuestCtrl
|
||||
@@ -0,0 +1,223 @@
|
||||
local GuideMissionShopCtrl = class("GuideMissionShopCtrl", BaseCtrl)
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local BubbleVoiceManager = require("Game.Actor2D.BubbleVoiceManager")
|
||||
local PlayerVoiceData = PlayerData.Voice
|
||||
GuideMissionShopCtrl._mapNodeConfig = {
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
rawImgActor2D = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
btnActor2D = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Actor2D"
|
||||
},
|
||||
goBubbleRoot = {
|
||||
sNodeName = "----fixed_bubble----"
|
||||
},
|
||||
goRefresh = {},
|
||||
txtRefreshCn = {sComponentName = "TMP_Text"},
|
||||
txtRefreshTime = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
GuideMissionShopCtrl._mapEventConfig = {
|
||||
[EventId.ShowBubbleVoiceText] = "OnEvent_ShowBubbleVoiceText",
|
||||
ShopRefreshGoods = "OnEvent_ShopRefreshGoods",
|
||||
ShopBuyVoice = "PlayBuyVoice"
|
||||
}
|
||||
local npcId = 915201
|
||||
function GuideMissionShopCtrl:PlayEnterVoice()
|
||||
local sTimeVoice = PlayerVoiceData:GetNPCGreetTimeVoiceKey()
|
||||
local sVoice = math.random(1, 2) == 1 and sTimeVoice or "greet_npc"
|
||||
PlayerVoiceData:PlayCharVoice(sVoice, npcId, nil, true)
|
||||
end
|
||||
function GuideMissionShopCtrl:PlayBuyVoice(bSale, bLimit)
|
||||
if not self.bInShop then
|
||||
return
|
||||
end
|
||||
local sVoice = ""
|
||||
if bSale then
|
||||
sVoice = "onsale"
|
||||
elseif bLimit then
|
||||
sVoice = "limited"
|
||||
else
|
||||
sVoice = "thank_npc"
|
||||
end
|
||||
PlayerVoiceData:PlayCharVoice(sVoice, npcId, nil, true)
|
||||
end
|
||||
function GuideMissionShopCtrl:PlaySwitchTogVoice()
|
||||
PlayerVoiceData:PlayCharVoice("Tab", npcId, nil, true)
|
||||
end
|
||||
function GuideMissionShopCtrl:EnterShop(nTogIndex)
|
||||
if not self.bInShop then
|
||||
self.bInShop = true
|
||||
self.nTogIndex = nil
|
||||
PlayerVoiceData:StartBoardFreeTimer(npcId)
|
||||
self:RefreshNPC2D()
|
||||
self:PlayEnterVoice()
|
||||
end
|
||||
self:CheckShopData(nTogIndex)
|
||||
end
|
||||
function GuideMissionShopCtrl:ExitShop()
|
||||
if not self.bInShop then
|
||||
return
|
||||
end
|
||||
self.bInShop = false
|
||||
self.nTogIndex = nil
|
||||
Actor2DManager.UnsetBoardNPC2D()
|
||||
BubbleVoiceManager.StopBubbleAnim()
|
||||
PlayerVoiceData:ClearTimer()
|
||||
PlayerVoiceData:StopCharVoice()
|
||||
end
|
||||
function GuideMissionShopCtrl:CheckShopData(nTogIndex)
|
||||
if nTogIndex ~= nil and self.nTogIndex ~= nil and self.nTogIndex ~= nTogIndex then
|
||||
self:PlaySwitchTogVoice()
|
||||
end
|
||||
self.nTogIndex = nTogIndex or self.nTogIndex
|
||||
PlayerData.Shop:CheckShopData(function()
|
||||
self:RefreshData()
|
||||
end)
|
||||
end
|
||||
function GuideMissionShopCtrl:RefreshData()
|
||||
self.tbShops = PlayerData.Shop:GetShopListByType(GameEnum.ShopType.GuideMission)
|
||||
local nShopIndex = self.nTogIndex == 3 and 2 or 1
|
||||
self.bDiscShop = self.nTogIndex == 3
|
||||
local mapShop = self.tbShops[nShopIndex]
|
||||
self.mapCurShop = mapShop
|
||||
if mapShop == nil then
|
||||
self.nShopId = nil
|
||||
self.tbGoods = {}
|
||||
self:RefreshList()
|
||||
self:RefreshRemainTime(0)
|
||||
return
|
||||
end
|
||||
self.nShopId = mapShop.nId
|
||||
PlayerData.Shop:CheckGoodsData(self.nShopId)
|
||||
self.tbGoods = PlayerData.Shop:GetGoodsList(self.nShopId)
|
||||
self:RefreshList()
|
||||
local nRemainTime = mapShop.nNextRefreshTime == 0 and 0 or mapShop.nNextRefreshTime - CS.ClientManager.Instance.serverTimeStamp
|
||||
self:RefreshRemainTime(nRemainTime)
|
||||
end
|
||||
function GuideMissionShopCtrl:RefreshList()
|
||||
if self.tbGridCtrl ~= nil then
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
self._mapNode.sv:SetAnim(0.02)
|
||||
self._mapNode.sv:Init(#self.tbGoods, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
end
|
||||
function GuideMissionShopCtrl:RefreshRemainTime(nRemainTime)
|
||||
self.nRemainTime = nRemainTime
|
||||
if self.timerCountDown == nil then
|
||||
self.timerCountDown = self:AddTimer(0, 1, "RefreshTime", false, true, false)
|
||||
end
|
||||
if self.nRemainTime > 0 then
|
||||
self._mapNode.goRefresh:SetActive(true)
|
||||
self:RefreshTime()
|
||||
self.timerCountDown:Pause(false)
|
||||
else
|
||||
self._mapNode.goRefresh:SetActive(false)
|
||||
self.timerCountDown:Pause(true)
|
||||
end
|
||||
end
|
||||
function GuideMissionShopCtrl:RefreshTime()
|
||||
self.nRemainTime = self.nRemainTime - 1
|
||||
if self.nRemainTime > 0 then
|
||||
local mapShop = self.mapCurShop
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRefreshCn, mapShop ~= nil and mapShop.nNextRefreshTime == mapShop.nCloseTime and ConfigTable.GetUIText("Shop_NextClose") or ConfigTable.GetUIText("Shop_NextRefresh"))
|
||||
local sTime = ""
|
||||
if self.nRemainTime <= 60 then
|
||||
local sec = math.floor(self.nRemainTime)
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_NextRefresh_Sec") or "", sec)
|
||||
elseif self.nRemainTime > 60 and self.nRemainTime <= 3600 then
|
||||
local min = math.floor(self.nRemainTime / 60)
|
||||
local sec = math.floor(self.nRemainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_NextRefresh_Min") or "", min, sec)
|
||||
elseif self.nRemainTime > 3600 and self.nRemainTime <= 86400 then
|
||||
local hour = math.floor(self.nRemainTime / 3600)
|
||||
local min = math.floor((self.nRemainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_NextRefresh_Hour") or "", hour, min)
|
||||
elseif self.nRemainTime > 86400 then
|
||||
local day = math.floor(self.nRemainTime / 86400)
|
||||
local hour = math.floor((self.nRemainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_NextRefresh_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRefreshTime, sTime)
|
||||
else
|
||||
self.timerCountDown:Pause(true)
|
||||
end
|
||||
end
|
||||
function GuideMissionShopCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbGoods[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.ShopEx.ShopGoodsItemCtrl")
|
||||
end
|
||||
mapData.bGuideMissionShop = self.bDiscShop
|
||||
self.tbGridCtrl[nInstanceID]:Refresh(mapData)
|
||||
end
|
||||
function GuideMissionShopCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbGoods[nIndex]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ShopPopupPanel, mapData, self.nShopId)
|
||||
end
|
||||
function GuideMissionShopCtrl:RefreshNPC2D()
|
||||
local bUseL2D = LocalSettingData.mapData.UseLive2D
|
||||
self._mapNode.rawImgActor2D.transform.localScale = bUseL2D == true and Vector3.one or Vector3.zero
|
||||
self._mapNode.trActor2D_PNG.localScale = bUseL2D == true and Vector3.zero or Vector3.one
|
||||
if bUseL2D == true then
|
||||
Actor2DManager.SetBoardNPC2D(self:GetPanelId(), self._mapNode.rawImgActor2D, npcId)
|
||||
else
|
||||
Actor2DManager.SetBoardNPC2D_PNG(self._mapNode.trActor2D_PNG, self:GetPanelId(), npcId)
|
||||
end
|
||||
end
|
||||
function GuideMissionShopCtrl:Awake()
|
||||
end
|
||||
function GuideMissionShopCtrl:OnEnable()
|
||||
self.bInShop = false
|
||||
end
|
||||
function GuideMissionShopCtrl:OnDisable()
|
||||
self:ExitShop()
|
||||
end
|
||||
function GuideMissionShopCtrl:OnDestroy()
|
||||
end
|
||||
function GuideMissionShopCtrl:OnBtnClick_Actor2D()
|
||||
PlayerVoiceData:PlayBoardNPCClickVoice(npcId)
|
||||
end
|
||||
function GuideMissionShopCtrl:OnEvent_ShopRefreshGoods()
|
||||
self:CheckShopData()
|
||||
end
|
||||
function GuideMissionShopCtrl:OnEvent_ShowBubbleVoiceText(nNpcId, nId)
|
||||
if nNpcId ~= npcId then
|
||||
return
|
||||
end
|
||||
local mapVoDirectoryData = ConfigTable.GetData("VoDirectory", nId)
|
||||
if mapVoDirectoryData == nil then
|
||||
printError("VoDirectory未找到数据id:" .. nId)
|
||||
return
|
||||
end
|
||||
BubbleVoiceManager.PlayFixedBubbleAnim(self._mapNode.goBubbleRoot, mapVoDirectoryData.voResource)
|
||||
end
|
||||
return GuideMissionShopCtrl
|
||||
Reference in New Issue
Block a user