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:
@@ -2,22 +2,100 @@ local ActivityMiningCtrl = class("ActivityMiningCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local axeItemId = 0
|
||||
local barMinX = -365
|
||||
local barMaxX = 0
|
||||
ActivityMiningCtrl._mapNodeConfig = {
|
||||
btnGo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
},
|
||||
txtBtnGo = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_Go"
|
||||
},
|
||||
txtBtnActDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_ActDetail"
|
||||
},
|
||||
btnActDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtTime = {sComponentName = "TMP_Text"},
|
||||
txtAdvanceMat = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_RewardPre"
|
||||
},
|
||||
svItem = {
|
||||
sNodeName = "PreviewUpgradeMaterial",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
txt_quest = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MiningGame_QuestTitle"
|
||||
},
|
||||
redDotQuest = {},
|
||||
btn_quest = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Quest"
|
||||
},
|
||||
txt_mainProcess = {sComponentName = "TMP_Text"},
|
||||
imgMainBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
ActivityMiningCtrl._mapEventConfig = {
|
||||
MiningQuestUpdate = "InitQuest",
|
||||
MiningCloseQuestPanel = "OnEvent_CloseQuestPanel"
|
||||
}
|
||||
ActivityMiningCtrl._mapRedDotConfig = {
|
||||
[RedDotDefine.Activity_Mining_AllQuest] = {
|
||||
sNodeName = "redDotQuest"
|
||||
}
|
||||
}
|
||||
function ActivityMiningCtrl:OnDestroy(...)
|
||||
self:UnInit()
|
||||
end
|
||||
function ActivityMiningCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = self.actData:GetActId()
|
||||
self:ShowAddAxeCount()
|
||||
self:RefreshTimeout()
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, "RefreshTimeout", true, true, false)
|
||||
end
|
||||
self:InitItem()
|
||||
self:InitQuest()
|
||||
end
|
||||
function ActivityMiningCtrl:UnInit(...)
|
||||
RedDotManager.UnRegisterNode(RedDotDefine.Activity_Mining_Quest_Group, nil, self._mapNode.reddot_Task)
|
||||
function ActivityMiningCtrl:InitItem()
|
||||
local config = ConfigTable.GetData("MiningControl", self.nActId)
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
local rewardData = config.RewardsShow
|
||||
self.tbReward = decodeJson(rewardData)
|
||||
self.tbItemIns = {}
|
||||
self._mapNode.svItem:Init(#self.tbReward, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
end
|
||||
function ActivityMiningCtrl:OnGridRefresh(go, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbReward[nDataIndex]
|
||||
local goItem = go.transform:Find("AnimRoot/item").gameObject
|
||||
local instanceId = goItem:GetInstanceID()
|
||||
if self.tbItemIns[instanceId] == nil then
|
||||
self.tbItemIns[instanceId] = self:BindCtrlByNode(goItem, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
self.tbItemIns[instanceId]:SetItem(itemId)
|
||||
end
|
||||
function ActivityMiningCtrl:OnGridBtnClick(go, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbReward[nDataIndex]
|
||||
UTILS.ClickItemGridWithTips(itemId, go.transform:Find("AnimRoot/item"), true, true, false)
|
||||
end
|
||||
function ActivityMiningCtrl:InitQuest()
|
||||
local allCount = self.actData:GetAllQuestCount()
|
||||
local receivedCount = self.actData:GetAllReceivedCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_mainProcess, receivedCount .. "/" .. allCount)
|
||||
self._mapNode.imgMainBarFill.anchoredPosition = Vector2(barMinX + (barMaxX - barMinX) * (receivedCount / allCount), self._mapNode.imgMainBarFill.anchoredPosition.y)
|
||||
end
|
||||
function ActivityMiningCtrl:RefreshTimeout()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
@@ -38,33 +116,21 @@ function ActivityMiningCtrl:RefreshTimeout()
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
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 = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
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 = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
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 = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTimeout, sTimeStr)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTime, sTimeStr)
|
||||
end
|
||||
function ActivityMiningCtrl:ShowAddAxeCount()
|
||||
local nActId = self.actData:GetActId()
|
||||
@@ -80,59 +146,40 @@ function ActivityMiningCtrl:ShowAddAxeCount()
|
||||
data:ResetAddAxeCount()
|
||||
end
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Go(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
local tbStoryConfig = self.actData:GetStoryConfigIdList()
|
||||
local nCurLevel = self.actData:GetLevel()
|
||||
local sNeedPlayAvgyId = 0
|
||||
local nStoryId = 0
|
||||
local tbAllData = self.actData:GetGroupStoryData()
|
||||
for _, v in pairs(tbStoryConfig) do
|
||||
if nCurLevel >= v.config.UnlockLayer then
|
||||
local temp = v.config.Id
|
||||
if not tbAllData[temp].bIsRead then
|
||||
sNeedPlayAvgyId = v.config.AvgId
|
||||
nStoryId = v.config.Id
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
local bAvgReadState = true
|
||||
if tbAllData[nStoryId] ~= nil then
|
||||
bAvgReadState = false
|
||||
end
|
||||
if sNeedPlayAvgyId ~= 0 and not bAvgReadState then
|
||||
local callback = function(...)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PureAvgStory)
|
||||
self.actData:RequestFinishAvg(nStoryId)
|
||||
end
|
||||
local mapData = {
|
||||
nType = AllEnum.StoryAvgType.Plot,
|
||||
sAvgId = sNeedPlayAvgyId,
|
||||
nNodeId = nil,
|
||||
callback = callback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PureAvgStory, mapData)
|
||||
function ActivityMiningCtrl:OnBtnClick_Go()
|
||||
local config = ConfigTable.GetData("MiningControl", self.nActId)
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MiningGame, nActId)
|
||||
EventManager.Hit(EventId.OpenPanel, config.GamePanelId, self.nActId)
|
||||
end
|
||||
self.actData:RequestLevelData(0, callback)
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Story(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MiningGameStory, nActId)
|
||||
function ActivityMiningCtrl:OnBtnClick_Quest()
|
||||
local config = ConfigTable.GetData("MiningControl", self.nActId)
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, config.QuestPanelId, self.nActId)
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Task(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MiningGameQuest, nActId)
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Shop(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
local tbConfig = ConfigTable.GetData("MiningControl", nActId)
|
||||
local nShopId = tbConfig.ShopId
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ShopPanel, nShopId)
|
||||
function ActivityMiningCtrl:OnBtnClick_Detail()
|
||||
local config = ConfigTable.GetData("MiningControl", self.nActId)
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = config.Desc,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
})
|
||||
end
|
||||
function ActivityMiningCtrl:ClearActivity()
|
||||
if self.tbItemIns ~= nil then
|
||||
for _, ctrl in pairs(self.tbItemIns) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
self.tbItemIns = {}
|
||||
end
|
||||
return ActivityMiningCtrl
|
||||
|
||||
Reference in New Issue
Block a user