Initial version - 1.2.0.60

EN: 1.2.0.60
CN: 1.2.0.61
JP: 1.2.0.63
KR: 1.2.0.67
This commit is contained in:
SL1900
2025-12-03 01:00:00 +09:00
commit 5e0d58cfad
3595 changed files with 9373562 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,24 @@
local CookieBoardPanel = class("CookieBoardPanel", BasePanel)
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
CookieBoardPanel._bIsMainPanel = true
CookieBoardPanel._tbDefine = {
{
sPrefabPath = "Play_Cookie/CookieBoardPanel.prefab",
sCtrlName = "Game.UI.Play_Cookie.CookieBoardCtrl"
}
}
function CookieBoardPanel:Awake()
GamepadUIManager.EnterAdventure(true)
end
function CookieBoardPanel:OnEnable()
end
function CookieBoardPanel:OnAfterEnter()
end
function CookieBoardPanel:OnDisable()
end
function CookieBoardPanel:OnDestroy()
GamepadUIManager.QuitAdventure()
end
function CookieBoardPanel:OnRelease()
end
return CookieBoardPanel
+463
View File
@@ -0,0 +1,463 @@
local CookieGameCtrl = class("CookieGameCtrl", BaseCtrl)
local TimerManager = require("GameCore.Timer.TimerManager")
local ClientManager = CS.ClientManager.Instance
CookieGameCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
goDailyModeInfo = {},
goNightmareModeInfo = {},
goDailyOn = {},
goNightmareOn = {},
goDailyOff = {},
goNightmareOff = {},
goNightmareLock = {},
iconNightmareLock = {},
btnDaily = {
sNodeName = "goDailyOff",
sComponentName = "UIButton",
callback = "OnBtnClick_DailyMode"
},
btnNightmare = {
sNodeName = "goNightmareOff",
sComponentName = "UIButton",
callback = "OnBtnClick_NightmareMode"
},
txtDailyOn = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_DailyMode"
},
txtNightmareOn = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_NightmareMode"
},
txtDailyOff = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_DailyMode"
},
txtNightmareOff = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_NightmareMode"
},
imgModeIcon = {sComponentName = "Image"},
txtLevelTitle = {sComponentName = "TMP_Text"},
txtLevelTitleNM = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_NightmareMode_Title"
},
txtLevelDesc = {sComponentName = "TMP_Text"},
txtLevelDescNM = {sComponentName = "TMP_Text"},
txtLabelLevelGoal = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Level_Goal"
},
txtLabelHighScore = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Level_HighScore"
},
txtNormalHighScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Level_HighScore"
},
txtNormalHighScoreNum = {sComponentName = "TMP_Text"},
imgNormalHighScore = {},
txtLabelLevelGoalDesc = {sComponentName = "TMP_Text"},
txtLabelHighScoreNum = {sComponentName = "TMP_Text"},
txtLabelLevelReward = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Level_Reward"
},
imgNew = {},
btnEnter = {
nCount = 2,
sComponentName = "UIButton",
callback = "OnBtnClick_Enter"
},
txtEnterDaily = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Level_Go"
},
txtEnterDailyGray = {sComponentName = "TMP_Text"},
txtEnterNMGray = {sComponentName = "TMP_Text"},
txtNM = {
sComponentName = "TMP_Text",
sLanguageId = "WeeklyBoss_Chanllenge"
},
item = {
nCount = 3,
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
btnItem = {nCount = 3, sComponentName = "UIButton"},
svLevel = {
sComponentName = "LoopScrollView"
},
btnQuestDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_QuestDetail"
},
imgFill = {sComponentName = "Image"},
txtProgress = {sComponentName = "TMP_Text"},
txtQuestTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_QuestTitle"
},
redDotQuest = {},
animLevels = {sNodeName = "goLevels", sComponentName = "Animator"}
}
CookieGameCtrl._mapEventConfig = {
CookieLevelUpdate = "OnEvent_CookieLevelUpdate",
CookieLevelReward = "OnEvent_CookieLevelReward"
}
function CookieGameCtrl:Refresh()
self._mapNode.svLevel.gameObject:SetActive(true)
if self.nSelectedMode == GameEnum.CookiePackModel.CookiePackNormalModel then
self.nCurSelectLevelIndex = self:GetLastesetLevelId()
elseif self.nSelectedMode == GameEnum.CookiePackModel.CookiePackNightmareModel then
self.nCurSelectLevelIndex = nil
self._mapNode.svLevel.gameObject:SetActive(false)
end
self:RefreshLevelData()
self:RefreshLevelInfoPage(self.nCurSelectLevelIndex)
self:RefreshQuestInfo()
NovaAPI.SetImageFillAmount(self._mapNode.imgFill, self.nCompletedMiniGameQuest / self.nTotalMiniGameQuest or 1)
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.nCompletedMiniGameQuest, self.nTotalMiniGameQuest))
end
function CookieGameCtrl:RefreshQuestInfo()
self.tbQuestGroupId = 0
local nQuestActId = tonumber(tostring(self.nMainActId) .. "03")
local func_Parse_ActivityTaskGroup = function(mapData)
if mapData.ActivityId == nQuestActId and mapData.Order == 4 then
self.tbQuestGroupId = mapData.Id
end
end
ForEachTableLine(DataTable.ActivityTaskGroup, func_Parse_ActivityTaskGroup)
self.nTotalMiniGameQuest = 0
self.nCompletedMiniGameQuest = 0
if self.tbQuestGroupId == 0 then
return
end
local func_Parse_ActivityTask = function(mapData)
if mapData.ActivityTaskGroupId == self.tbQuestGroupId then
self.nTotalMiniGameQuest = self.nTotalMiniGameQuest + 1
local _nTaskId = mapData.Id
local taskData = PlayerData.Activity:GetActivityDataById(nQuestActId).mapActivityTaskDatas[_nTaskId]
if taskData.nStatus == AllEnum.ActQuestStatus.Received then
self.nCompletedMiniGameQuest = self.nCompletedMiniGameQuest + 1
end
end
end
ForEachTableLine(DataTable.ActivityTask, func_Parse_ActivityTask)
end
function CookieGameCtrl:RefreshLevelInfoPage(nIndex)
local levelData
for k, v in pairs(self.tbComplexLevelData) do
if v.PackModel == GameEnum.CookiePackModel.CookiePackComplexModel then
levelData = v
break
end
end
if levelData ~= nil then
local bTimeUnlock, bPreLevelUnlock = self.cookieData:IsLevelUnlocked(levelData.Id)
self._mapNode.goNightmareLock:SetActive(not bPreLevelUnlock or not bTimeUnlock)
self._mapNode.iconNightmareLock:SetActive(not bPreLevelUnlock or not bTimeUnlock)
self._mapNode.btnEnter[2].gameObject:SetActive(bPreLevelUnlock and bTimeUnlock)
self._mapNode.txtEnterNMGray.gameObject:SetActive(not bPreLevelUnlock or not bTimeUnlock)
if not bPreLevelUnlock or not bTimeUnlock then
local sText = ""
if not bTimeUnlock then
local sUnlockTime = os.date("%Y-%m-%d %H:%M", levelData.DayOpen * 86400 + self.nOpenTime)
local sRemainTimeStr, bRemainTimeValid = self:GetRemainTimeStr(self.nOpenTime, levelData.DayOpen)
sText = sRemainTimeStr
elseif not bPreLevelUnlock then
sText = ConfigTable.GetUIText("Cookie_Act_Level_Lock_PreLevel")
end
NovaAPI.SetTMPText(self._mapNode.txtEnterNMGray, sText)
end
end
if nIndex == nil then
self._mapNode.goDailyModeInfo:SetActive(false)
self._mapNode.goNightmareModeInfo:SetActive(true)
if levelData ~= nil then
NovaAPI.SetTMPText(self._mapNode.txtLevelDescNM, levelData.PackContent)
local bNewDay = self.cookieData:GetNMHighScoreToday()
self._mapNode.imgNew:SetActive(bNewDay)
local nHighScore = self.cookieData:GetLevelDataById(levelData.Id).nMaxScore or 0
NovaAPI.SetTMPText(self._mapNode.txtLabelHighScoreNum, nHighScore)
end
return
end
levelData = self.tbLevelData[nIndex]
if levelData == nil then
return
end
self._mapNode.svLevel:SetScrollGridPos(nIndex - 1, 0, 1)
self._mapNode.goDailyModeInfo:SetActive(true)
self._mapNode.goNightmareModeInfo:SetActive(false)
self:SetPngSprite(self._mapNode.imgModeIcon, AllEnum.CookieModeIcon[levelData.PackModel] or AllEnum.CookieModeIcon[1])
NovaAPI.SetTMPText(self._mapNode.txtLevelTitle, levelData.Name)
NovaAPI.SetTMPText(self._mapNode.txtLevelDesc, levelData.PackContent)
local sGoal = ConfigTable.GetUIText("Cookie_Act_Level_Goal_Desc") or ""
sGoal = orderedFormat(sGoal, levelData.FirstCompletionScore)
NovaAPI.SetTMPText(self._mapNode.txtLabelLevelGoalDesc, sGoal)
local nHighScore = self.cookieData:GetLevelDataById(levelData.Id).nMaxScore or 0
NovaAPI.SetTMPText(self._mapNode.txtNormalHighScoreNum, nHighScore)
for i = 1, 3 do
do
local nItemId = levelData["FirstCompletionReward" .. i .. "Tid"]
local nItemCount = levelData["FirstCompletionReward" .. i .. "Qty"]
if nItemId ~= nil and 0 < nItemId then
self._mapNode.item[i]:SetItem(nItemId, nil, nItemCount, nil, self.cookieData:GetLevelDataById(levelData.Id).bFirstComplete, true)
self._mapNode.btnItem[i].gameObject:SetActive(true)
self._mapNode.btnItem[i].onClick:RemoveAllListeners()
self._mapNode.btnItem[i].onClick:AddListener(function()
UTILS.ClickItemGridWithTips(nItemId, self._mapNode.btnItem[i].transform, true, true, false)
end)
else
self._mapNode.btnItem[i].gameObject:SetActive(false)
end
end
end
local bTimeUnlock, bPreLevelUnlock = self.cookieData:IsLevelUnlocked(levelData.Id)
self._mapNode.btnEnter[1].gameObject:SetActive(bPreLevelUnlock and bTimeUnlock)
self._mapNode.txtEnterDailyGray.gameObject:SetActive(not bPreLevelUnlock or not bTimeUnlock)
if not bPreLevelUnlock or not bTimeUnlock then
local sText = ""
if not bTimeUnlock then
local sRemainTimeStr, bRemainTimeValid = self:GetRemainTimeStr(self.nOpenTime, levelData.DayOpen)
sText = sRemainTimeStr
elseif not bPreLevelUnlock then
sText = ConfigTable.GetUIText("Cookie_Act_Level_Lock_PreLevel")
end
NovaAPI.SetTMPText(self._mapNode.txtEnterDailyGray, sText)
end
end
function CookieGameCtrl:RefreshLevelData()
self.tbLevelData = {}
self.tbComplexLevelData = {}
local fc = function(mapData)
if mapData.ActivityId == self.nActId then
if mapData.PackType == GameEnum.CookiePackType.Daily then
table.insert(self.tbLevelData, mapData)
else
table.insert(self.tbComplexLevelData, mapData)
end
end
end
ForEachTableLine(ConfigTable.Get("CookieLevel"), fc)
if self.nCurSelectLevelIndex ~= nil and self.nCurSelectLevelIndex > #self.tbLevelData then
self.nCurSelectLevelIndex = #self.tbLevelData
end
if self.tbLevelGridCtrl ~= nil then
for k, v in pairs(self.tbLevelGridCtrl) do
if v ~= nil then
self:UnbindCtrlByNode(v)
self.tbLevelGridCtrl[k] = nil
end
end
end
self.tbLevelGridCtrl = {}
self._mapNode.svLevel:Init(#self.tbLevelData, self, self.OnGridRefresh, self.OnGridBtnClick)
end
function CookieGameCtrl:OnGridRefresh(go, nIndex)
local nDataIndex = nIndex + 1
local levelData = self.tbLevelData[nDataIndex]
if levelData == nil then
return
end
local gridCtrl = self:BindCtrlByNode(go, "Game.UI.Play_Cookie.CookieLevelGridCtrl")
if gridCtrl ~= nil then
local bTimeUnlock, bPreLevelUnlock = self.cookieData:IsLevelUnlocked(levelData.Id)
gridCtrl:Init(levelData, self.cookieData:GetLevelDataById(levelData.Id), bTimeUnlock, bPreLevelUnlock, nDataIndex)
self.tbLevelGridCtrl[nDataIndex] = gridCtrl
if self.nCurSelectLevelIndex == nDataIndex then
self.lastSelectGridCtrl = gridCtrl
gridCtrl:SetSelect(true)
else
gridCtrl:SetSelect(false)
end
end
end
function CookieGameCtrl:OnGridBtnClick(go, nIndex)
local nDataIndex = nIndex + 1
local gridCtrl = self.tbLevelGridCtrl[nDataIndex]
if gridCtrl == nil then
return
end
if gridCtrl == self.lastSelectGridCtrl then
return
end
if self.lastSelectGridCtrl ~= nil then
self.lastSelectGridCtrl:SetSelect(false)
end
self.lastSelectGridCtrl = gridCtrl
gridCtrl:SetSelect(true)
self.nCurSelectLevelIndex = nDataIndex
self._mapNode.animLevels:Play("CookieGame_Daily_Next", 0, 0)
if self.timerNext ~= nil then
self.timerNext:Cancel()
self.timerNext = nil
end
EventManager.Hit(EventId.TemporaryBlockInput, 0.25)
self.timerNext = self:AddTimer(1, 0.25, function()
self:RefreshLevelInfoPage(nDataIndex)
end, true, true, true)
end
function CookieGameCtrl:GetLastesetLevelId()
local tbLevelInfo = self.cookieData:GetLevelData()
for k, v in pairs(tbLevelInfo) do
if v.bFirstComplete == false then
return k
end
end
return 1
end
function CookieGameCtrl:GetRemainTimeStr(nOpenTime, openDay)
local timeStr = ""
local curTime = CS.ClientManager.Instance.serverTimeStamp
local openTime = CS.ClientManager.Instance:GetNextRefreshTime(nOpenTime) - 86400
local nRemainTime = openTime + openDay * 86400 - curTime
local day = math.floor(nRemainTime / 86400)
local hour = math.floor(nRemainTime / 3600)
local min = math.floor((nRemainTime - hour * 3600) / 60)
local sec = nRemainTime - hour * 3600 - min * 60
if 0 < day then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Day_Color"), day)
elseif 0 < hour then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Hour_Color"), hour)
elseif 0 < min then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Min_Color"), min)
elseif 0 < sec then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Sec_Color"), sec)
end
return timeStr, 0 < nRemainTime
end
function CookieGameCtrl:Awake()
local param = self:GetPanelParam()
if type(param) == "table" then
self.nActId = param[1]
self.nMainActId = param[2] or 0
end
self.cookieData = PlayerData.Activity:GetActivityDataById(self.nActId)
self.nOpenTime = self.cookieData:GetActOpenTime() or 0
self.nSelectedMode = GameEnum.CookiePackModel.CookiePackNormalModel
self._mapNode.goDailyOn:SetActive(true)
self._mapNode.goNightmareOn:SetActive(false)
self._mapNode.goDailyOff:SetActive(false)
self._mapNode.goNightmareOff:SetActive(true)
self._mapNode.btnDaily.gameObject:SetActive(false)
self._mapNode.btnNightmare.gameObject:SetActive(true)
end
function CookieGameCtrl:OnEnable()
EventManager.Hit(EventId.SetTransition)
self:Refresh()
local nQuestActId = tonumber(tostring(self.nMainActId) .. "03")
RedDotManager.RegisterNode(RedDotDefine.Activity_Group_Task, {
self.nMainActId,
nQuestActId
}, self._mapNode.redDotQuest)
end
function CookieGameCtrl:OnDisable()
for k, v in pairs(self.tbLevelGridCtrl) do
self:UnbindCtrlByNode(v)
self.tbLevelGridCtrl[k] = nil
end
end
function CookieGameCtrl:OnDestroy(...)
end
function CookieGameCtrl:OnBtnClick_Enter()
local levelData = self.nSelectedMode == GameEnum.CookiePackModel.CookiePackNormalModel and self.tbLevelData[self.nCurSelectLevelIndex] or self.tbComplexLevelData[1]
if levelData == nil then
return
end
self.nLevelId = levelData.Id
local bPipeLineMode = levelData.PackModel == GameEnum.CookiePackModel.CookiePackPathsModel
local bRhythmlMode = levelData.PackModel == GameEnum.CookiePackModel.CookiePackRhythmlModel
if levelData.PackModel == GameEnum.CookiePackModel.CookiePackComplexModel then
bRhythmlMode = true
bPipeLineMode = true
end
local nScoreNeedToPass = levelData.FirstCompletionScore
local openPanel = function()
EventManager.Hit(EventId.OpenPanel, PanelId.CookieBoardPanel, self.nLevelId, bRhythmlMode, bPipeLineMode, levelData.CountDownLimit, self.nActId, nScoreNeedToPass or 0)
end
local nRandom = math.random(28, 29)
EventManager.Hit(EventId.SetTransition, nRandom, openPanel)
end
function CookieGameCtrl:OnBtnClick_Gray()
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Cookie_Act_Level_Lock_PreLevel"))
end
function CookieGameCtrl:OnBtnClick_DailyMode()
self.nSelectedMode = GameEnum.CookiePackModel.CookiePackNormalModel
self._mapNode.goDailyOn:SetActive(true)
self._mapNode.goNightmareOn:SetActive(false)
self._mapNode.goDailyOff:SetActive(false)
self._mapNode.goNightmareOff:SetActive(true)
self._mapNode.btnDaily.gameObject:SetActive(false)
self._mapNode.btnNightmare.gameObject:SetActive(true)
self._mapNode.animLevels:Play("CookieGame_Daily_Switch", 0, 0)
if self.timerSwitch ~= nil then
self.timerSwitch:Cancel()
self.timerSwitch = nil
end
self._mapNode.svLevel.gameObject:SetActive(false)
EventManager.Hit(EventId.TemporaryBlockInput, 0.35)
self.timerSwitch = self:AddTimer(1, 0.35, function()
self:Refresh()
end, true, true, true)
end
function CookieGameCtrl:OnBtnClick_NightmareMode()
self.nSelectedMode = GameEnum.CookiePackModel.CookiePackNightmareModel
self._mapNode.goDailyOn:SetActive(false)
self._mapNode.goNightmareOn:SetActive(true)
self._mapNode.goDailyOff:SetActive(true)
self._mapNode.goNightmareOff:SetActive(false)
self._mapNode.btnDaily.gameObject:SetActive(true)
self._mapNode.btnNightmare.gameObject:SetActive(false)
self._mapNode.animLevels:Play("CookieGame_Nightmare_Switch", 0, 0)
if self.timerSwitch ~= nil then
self.timerSwitch:Cancel()
self.timerSwitch = nil
end
EventManager.Hit(EventId.TemporaryBlockInput, 0.35)
self.timerSwitch = self:AddTimer(1, 0.35, function()
self:Refresh()
end, true, true, true)
end
function CookieGameCtrl:OnBtnClick_QuestDetail()
local actData = PlayerData.Activity:GetActivityGroupDataById(self.nMainActId):GetActivityDataByIndex(2)
local activityId = actData.ActivityId
local activityData = ConfigTable.GetData("Activity", activityId)
local state = 1
if activityData ~= nil then
local curTime = ClientManager.serverTimeStamp
if activityData.StartTime ~= "" and activityData.EndTime ~= "" then
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
local endTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.EndTime)
if curTime < openTime then
state = 1
elseif curTime >= openTime and curTime <= endTime then
state = 2
else
state = 3
end
elseif activityData.EndType == GameEnum.activityEndType.NoLimit then
state = 2
if activityData.StartTime ~= "" then
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
if curTime < openTime then
state = 1
end
end
end
end
if actData.PanelId ~= nil and 2 == state then
EventManager.Hit(EventId.OpenPanel, actData.PanelId, actData.ActivityId, 4)
end
end
function CookieGameCtrl:OnEvent_CookieLevelUpdate()
end
function CookieGameCtrl:OnEvent_CookieLevelReward(mapChangeInfo)
self.rewardChangeInfo = mapChangeInfo
end
return CookieGameCtrl
@@ -0,0 +1,21 @@
local CookieGamePanel = class("CookieGamePanel", BasePanel)
CookieGamePanel._bIsMainPanel = true
CookieGamePanel._tbDefine = {
{
sPrefabPath = "Play_Cookie/CookieGamePanel.prefab",
sCtrlName = "Game.UI.Play_Cookie.CookieGameCtrl"
}
}
function CookieGamePanel:Awake()
end
function CookieGamePanel:OnEnable()
end
function CookieGamePanel:OnAfterEnter()
end
function CookieGamePanel:OnDisable()
end
function CookieGamePanel:OnDestroy()
end
function CookieGamePanel:OnRelease()
end
return CookieGamePanel
@@ -0,0 +1,71 @@
local CookieGameQuestCtrl = class("CookieGameQuestCtrl", BaseCtrl)
local totalLength = 520
local totalHeight = 37
CookieGameQuestCtrl._mapNodeConfig = {
loopSv = {
sNodeName = "goQuest",
sComponentName = "LoopScrollView"
},
rtBarFill = {
sComponentName = "RectTransform"
},
btn_AllReceive = {
sComponentName = "UIButton",
callback = "OnBtnClick_AllReceive"
},
txt_AllReceive = {
ComponentName = "TMP_Text",
sLanguageId = "Quest_AllReceive"
}
}
CookieGameQuestCtrl._mapEventConfig = {}
function CookieGameQuestCtrl:Awake()
local param = self:GetPanelParam()
if type(param) == "table" then
self.nActId = param[1]
end
self:InitData()
end
function CookieGameQuestCtrl:OnDisable()
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
end
self.tbGridCtrl = {}
end
function CookieGameQuestCtrl:InitData()
self.actData = PlayerData.Activity:GetActivityDataById(self.nActId)
self.tbQuestList = {}
self.tbGridCtrl = {}
end
function CookieGameQuestCtrl:InitQuestData()
self.tbQuestList = self.actData:GetAllQuestData()
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)
if nil ~= self.tbQuestList then
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
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)
end
function CookieGameQuestCtrl: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.Cookie.CookieQuestCellCtrl")
end
self.tbGridCtrl[nInstanceId]:SetData(self.nActId, self.tbQuestList[nIndex])
end
function CookieGameQuestCtrl:OnBtnClick_AllReceive()
PlayerData.Activity:SendReceivePerQuest(self.nActId, 0, nil)
end
return CookieGameQuestCtrl
+122
View File
@@ -0,0 +1,122 @@
local CookieGridCtrl = class("CookieGridCtrl", BaseCtrl)
CookieGridCtrl._mapNodeConfig = {
imgCookieIcon = {sComponentName = "Image"},
imgTips = {},
imgHalo_01 = {},
imgHalo_02 = {},
imgHeart = {}
}
local CookieShapeEnum = {
Sera = 1,
Kohaku = 2,
Ayame = 3
}
local IconPathDefault = {
[CookieShapeEnum.Sera] = "UI/Play_Cookie/SpriteAtlas/Sprite/zs_cookie_01",
[CookieShapeEnum.Kohaku] = "UI/Play_Cookie/SpriteAtlas/Sprite/zs_cookie_02",
[CookieShapeEnum.Ayame] = "UI/Play_Cookie/SpriteAtlas/Sprite/zs_cookie_03"
}
local nPerfectTiming = 0.33
local colorPerfect = Color(255, 77, 203, 255)
function CookieGridCtrl:Init(nShape, nGreatTime, nPerfectTime)
self.animator = self.gameObject:GetComponent("Animator")
self.nShape = nShape
self:SetPngSprite(self._mapNode.imgCookieIcon, IconPathDefault[nShape])
NovaAPI.SetImageColor(self._mapNode.imgCookieIcon, Color(1, 1, 1, 0.15))
self:SetSelect(false)
self:PlayEnterAnim()
self.nGreatTime = nGreatTime
self.nPerfectTime = nPerfectTime
end
function CookieGridCtrl:SetFilled()
NovaAPI.SetImageColor(self._mapNode.imgCookieIcon, Color(1, 1, 1, 1))
self:PlayEnterAnim()
end
function CookieGridCtrl:GetGirdShape()
if nil ~= self.nShape then
return self.nShape
end
return 0
end
function CookieGridCtrl:SetSelect(bActive)
self._mapNode.imgTips:SetActive(bActive)
end
function CookieGridCtrl:PlayLightAnim()
self._mapNode.imgHalo_01:SetActive(false)
self._mapNode.imgHalo_02:SetActive(false)
self.animator:Play("CookieGrid_Light")
end
function CookieGridCtrl:PlayWrongAnim(nBlockTime, bShowHeart)
self._mapNode.imgHalo_01:SetActive(false)
self._mapNode.imgHalo_02:SetActive(false)
if nBlockTime == nil or nBlockTime <= 0 then
nBlockTime = 1
end
self._mapNode.imgHeart:SetActive(bShowHeart == true)
local nAnimLength = NovaAPI.GetAnimClipLength(self.animator, {
"CookieGrid_wrong"
})
local nSpeed = nAnimLength / nBlockTime
self.animator:SetFloat("WrongSpeed", nSpeed or 1)
self.animator:Play("CookieGrid_wrong", 0, 0)
end
function CookieGridCtrl:PlayHaloAnim(nSpeed)
self._mapNode.imgHalo_01:SetActive(true)
self._mapNode.imgHalo_02:SetActive(true)
self.animator:SetFloat("PlaySpeed", nSpeed or 1)
self.animator:Play("CookieGrid_play", 0, 0)
self:StartFadingColor()
end
function CookieGridCtrl:StartFadingColor()
if self.timerColorFade ~= nil then
self.timerColorFade:Cancel()
self.timerColorFade = nil
end
GameUIUtils.SetUIMaterialAnimationColorValue1(self._mapNode.imgHalo_01.gameObject, 1, 1, 1, 1)
local nTimeNeed = self.nGreatTime - self.nPerfectTime
self.colorCur = Color(1, 1, 1, 1)
self.nColorTime = 0
self.timerColorFade = self:AddTimer(0, 0.034, function()
self.nColorTime = self.nColorTime + 0.034
local tempColor = self:_LerpColor(self.colorCur, colorPerfect, self.nColorTime, nTimeNeed)
GameUIUtils.SetUIMaterialAnimationColorValue1(self._mapNode.imgHalo_01.gameObject, tempColor.r, tempColor.g, tempColor.b, tempColor.a)
end, true, true, true)
self:AddTimer(1, nTimeNeed + 0.1, function()
if self.timerColorFade ~= nil then
self.timerColorFade:Cancel()
self.timerColorFade = nil
end
self._mapNode.imgHalo_01:SetActive(false)
self._mapNode.imgHalo_02:SetActive(false)
end, true, true, true)
end
function CookieGridCtrl:_LerpColor(currentColor, targetColor, elapsedTime, totalTime)
if totalTime <= 0 then
return {
r = targetColor.r,
g = targetColor.g,
b = targetColor.b,
a = targetColor.a or 1
}
end
local t = elapsedTime / totalTime
if 1 < t then
t = 1
end
if t < 0 then
t = 0
end
local res = Color(currentColor.r + (targetColor.r - currentColor.r) * t, currentColor.g + (targetColor.g - currentColor.g) * t, currentColor.b + (targetColor.b - currentColor.b) * t, (currentColor.a or 1) + ((targetColor.a or 1) - (currentColor.a or 1)) * t)
return res
end
function CookieGridCtrl:StopAllAnim()
self.animator:Play("Empty", 0, 0)
self._mapNode.imgHalo_01:SetActive(false)
self._mapNode.imgHalo_02:SetActive(false)
end
function CookieGridCtrl:PlayEnterAnim()
self._mapNode.imgHalo_01:SetActive(false)
self._mapNode.imgHalo_02:SetActive(false)
self.animator:Play("CookieGrid_in", 0, 0)
end
return CookieGridCtrl
@@ -0,0 +1,22 @@
local CookieLevelGridCtrl = class("CookieLevelGridCtrl", BaseCtrl)
CookieLevelGridCtrl._mapNodeConfig = {
imgLock = {},
iconLock = {},
imgIcon = {sComponentName = "Image"},
txtLevelNumber = {sComponentName = "TMP_Text"},
imgCmp = {},
imgChoose = {},
btnGrid = {sComponentName = "UIButton"}
}
function CookieLevelGridCtrl:Init(mapData, levelData, bTimeUnlock, bPreLevelUnlock, nIndex)
self:SetPngSprite(self._mapNode.imgIcon, AllEnum.CookieModeIcon[mapData.PackModel] or AllEnum.CookieModeIcon[1])
NovaAPI.SetTMPText(self._mapNode.txtLevelNumber, nIndex)
self._mapNode.imgChoose:SetActive(false)
self._mapNode.imgLock:SetActive(not bTimeUnlock)
self._mapNode.iconLock:SetActive(not bPreLevelUnlock or not bTimeUnlock)
self._mapNode.imgCmp:SetActive(levelData.bFirstComplete == true)
end
function CookieLevelGridCtrl:SetSelect(bActive)
self._mapNode.imgChoose:SetActive(bActive)
end
return CookieLevelGridCtrl
@@ -0,0 +1,133 @@
local CookieQuestCellCtrl = class("CookieQuestCellCtrl", BaseCtrl)
local JumpUtil = require("Game.Common.Utils.JumpUtil")
CookieQuestCellCtrl._mapNodeConfig = {
txtQuestName = {sComponentName = "TMP_Text"},
imgTrophy = {sComponentName = "Image"},
btnReceive = {
sComponentName = "UIButton",
callback = "OnBtnClick_Receive"
},
txtBtnReceive = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_Receive_Btn_Text"
},
btnJumpTo = {
sComponentName = "UIButton",
callback = "OnBtnClick_JumpTo"
},
txtBtnJumpTo = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_JumpTo_Text"
},
goReceived = {},
goBtns = {},
imgBarFill = {
sComponentName = "RectTransform"
},
txtProgress = {sComponentName = "TMP_Text"},
btnRewardItem = {nCount = 2, sComponentName = "UIButton"},
item = {
nCount = 2,
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
btnItem = {
sNodeName = "btnRewardItem",
nCount = 2,
sComponentName = "UIButton",
callback = "OnBtnClick_RewardItem"
}
}
local tbTrophySprite = {
"UI/big_sprites/bg_activity_cookie_task_01",
"UI/big_sprites/bg_activity_cookie_task_02",
"UI/big_sprites/bg_activity_cookie_task_03"
}
local nProgressBarLength = 562
local nProgressBarMin = 48
local nProgressBarHeight = 37
function CookieQuestCellCtrl:Init(questData, nActId)
self.questData = questData
if self.questData == nil then
return
end
self.actData = PlayerData.Activity:GetActivityDataById(nActId)
self.mapStatus = self.actData:GetQuestDataById(questData.Id)
if self.mapStatus == nil then
local tbJson = decodeJson(questData.CompleteCondParams)
self.mapStatus = {
nId = questData.Id,
nStatus = AllEnum.ActQuestStatus.UnComplete,
progress = {
Cur = 0,
Max = tbJson[#tbJson]
}
}
end
self.tbReward = {}
for i = 1, 2 do
local nRewardId = self.questData["Reward" .. i .. "Tid"]
local nRewardQty = self.questData["Reward" .. i .. "Qty"]
if nRewardId ~= nil and 0 < nRewardId and nRewardQty ~= nil and 0 < nRewardQty then
table.insert(self.tbReward, {nRewardId, nRewardQty})
self._mapNode.btnRewardItem[i].gameObject:SetActive(true)
else
self._mapNode.btnRewardItem[i].gameObject:SetActive(false)
end
end
self.tbBtn = self._mapNode.btnRewardItem
for k, v in pairs(self.tbReward) do
self._mapNode.item[k]:SetItem(v[1], nil, v[2])
end
NovaAPI.SetTMPText(self._mapNode.txtQuestName, self.questData.Desc)
self:SetPngSprite(self._mapNode.imgTrophy, tbTrophySprite[self.questData.Rarity] or tbTrophySprite[1])
self:UpdateCellStatus()
end
function CookieQuestCellCtrl:Awake(...)
end
function CookieQuestCellCtrl:OnDisable()
end
function CookieQuestCellCtrl:UpdateCellStatus()
self._mapNode.btnReceive.gameObject:SetActive(false)
self._mapNode.btnJumpTo.gameObject:SetActive(false)
self._mapNode.goReceived:SetActive(false)
NovaAPI.SetTMPText(self._mapNode.txtProgress, orderedFormat("{0}/{1}", self.mapStatus.progress.Cur, self.mapStatus.progress.Max))
if self.mapStatus.nStatus == AllEnum.ActQuestStatus.Complete then
self._mapNode.btnReceive.gameObject:SetActive(true)
self._mapNode.imgBarFill.sizeDelta = Vector2(nProgressBarLength, nProgressBarHeight)
elseif self.mapStatus.nStatus == AllEnum.ActQuestStatus.UnComplete then
local nLength = self.mapStatus.progress.Cur / self.mapStatus.progress.Max * nProgressBarLength
if nLength < nProgressBarMin then
if 0 < nLength then
nLength = nProgressBarMin
else
nLength = 0
end
end
self._mapNode.imgBarFill.sizeDelta = Vector2(nLength, nProgressBarHeight)
if self.questData.JumpTo ~= nil then
self.nJumpTo = self.questData.JumpTo
self._mapNode.btnJumpTo.gameObject:SetActive(true)
end
elseif self.mapStatus.nStatus == AllEnum.ActQuestStatus.Received then
self._mapNode.goReceived:SetActive(true)
self._mapNode.imgBarFill.sizeDelta = Vector2(nProgressBarLength, nProgressBarHeight)
end
end
function CookieQuestCellCtrl:OnBtnClick_RewardItem(btn, nIndex)
local nRewardId
if self.tbReward ~= nil and self.tbReward[nIndex] ~= nil then
nRewardId = self.tbReward[nIndex][1]
end
if nRewardId ~= nil then
UTILS.ClickItemGridWithTips(nRewardId, btn.transform, true, true, false)
end
end
function CookieQuestCellCtrl:OnBtnClick_Receive()
self.actData:SendQuestReceive(self.mapStatus.nId)
end
function CookieQuestCellCtrl:OnBtnClick_JumpTo()
if nil ~= self.nJumpTo and 0 ~= self.nJumpTo then
JumpUtil.JumpTo(self.nJumpTo)
end
end
return CookieQuestCellCtrl
+153
View File
@@ -0,0 +1,153 @@
local CookieQuestCtrl = class("CookieQuestCtrl", BaseCtrl)
local TimerManager = require("GameCore.Timer.TimerManager")
CookieQuestCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
goBlur = {},
tog = {
nCount = 2,
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
},
btnTog = {
sNodeName = "tog",
nCount = 2,
sComponentName = "UIButton",
callback = "OnBtnClick_ChangeTab"
},
svQuest = {
sComponentName = "LoopScrollView"
},
btnClaimAll = {
sComponentName = "UIButton",
callback = "OnBtnClick_ClaimAll"
},
btnClaimAllGray = {},
txtClaimAll = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_Btn_ReceiveAll"
},
txtClaimAllGary = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_Btn_ReceiveAll"
}
}
CookieQuestCtrl._mapEventConfig = {
CookieQuestUpdate = "OnEvent_CookieQuestUpdate",
CookieLevelUpdate = "OnEvent_CookieLevelUpdate"
}
local tbModeTextKey = {
"Cookie_Act_DailyMode",
"Cookie_Act_NightmareMode"
}
function CookieQuestCtrl:Refresh()
for i = 1, #self._mapNode.tog do
self._mapNode.tog[i]:SetText(ConfigTable.GetUIText(tbModeTextKey[i]))
self._mapNode.tog[i]:SetDefault(i == self.nCurSeletedTab)
end
if self.tbQuestGridCtrl ~= nil then
for k, v in pairs(self.tbQuestGridCtrl) do
if v ~= nil then
self:UnbindCtrlByNode(v)
self.tbQuestGridCtrl[k] = nil
end
end
end
self.tbDailyQuestData = {}
self.tbNightmareQuestData = {}
self.tbQuestStatus = PlayerData.Activity:GetActivityDataById(self.nActId):GetQuestData()
local fc = function(mapData)
if mapData == nil then
return
end
if mapData.CookieQuestLabel == 1 then
table.insert(self.tbDailyQuestData, mapData)
elseif mapData.CookieQuestLabel == 2 then
table.insert(self.tbNightmareQuestData, mapData)
end
end
ForEachTableLine(ConfigTable.Get("CookieQuest"), fc)
if self.nCurSeletedTab == 1 then
self.tbQuestData = self.tbDailyQuestData
elseif self.nCurSeletedTab == 2 then
self.tbQuestData = self.tbNightmareQuestData
end
table.sort(self.tbQuestData, function(a, b)
local statusA, statusB
if self.tbQuestStatus ~= nil then
for k, v in pairs(self.tbQuestStatus) do
if v.nId == a.Id then
statusA = v.nStatus
end
if v.nId == b.Id then
statusB = v.nStatus
end
if statusA ~= nil and statusB ~= nil then
break
end
end
end
if statusA ~= statusB then
return statusA < statusB
else
return a.Id < b.Id
end
end)
self._mapNode.svQuest:Init(#self.tbQuestData, self, self.OnGridRefresh)
local bHasComplete = false
if self.tbQuestStatus ~= nil then
for k, v in pairs(self.tbQuestStatus) do
if v ~= nil and v.nStatus == AllEnum.ActQuestStatus.Complete then
bHasComplete = true
end
end
end
self._mapNode.btnClaimAll.gameObject:SetActive(bHasComplete)
self._mapNode.btnClaimAllGray.gameObject:SetActive(not bHasComplete)
end
function CookieQuestCtrl:OnGridRefresh(go, nIndex)
local nDataIndex = nIndex + 1
local qeustData = self.tbQuestData[nDataIndex]
if qeustData == nil then
return
end
local gridCtrl = self:BindCtrlByNode(go, "Game.UI.Play_Cookie.CookieQuestCellCtrl")
if gridCtrl ~= nil then
gridCtrl:Init(qeustData, self.nActId)
self.tbQuestGridCtrl[nDataIndex] = gridCtrl
end
end
function CookieQuestCtrl:Awake()
local tbParam = self:GetPanelParam()
if tbParam ~= nil then
self.nActId = tbParam[1] or 0
end
self.tbQuestGridCtrl = {}
self.nCurSeletedTab = 1
end
function CookieQuestCtrl:OnEnable()
self:Refresh()
end
function CookieQuestCtrl:OnDisable()
for k, v in pairs(self.tbQuestGridCtrl) do
self:UnbindCtrlByNode(v)
self.tbQuestGridCtrl[k] = nil
end
end
function CookieQuestCtrl:OnDestroy(...)
end
function CookieQuestCtrl:OnBtnClick_ChangeTab(btn, nIndex)
if self.nCurSeletedTab == nIndex then
return
end
self.nCurSeletedTab = nIndex
self:Refresh()
end
function CookieQuestCtrl:OnBtnClick_ClaimAll()
PlayerData.Activity:GetActivityDataById(self.nActId):SendQuestReceive(0)
end
function CookieQuestCtrl:OnEvent_CookieQuestUpdate()
self:Refresh()
end
return CookieQuestCtrl
@@ -0,0 +1,21 @@
local CookieQuestPanel = class("CookieQuestPanel", BasePanel)
CookieQuestPanel._bIsMainPanel = true
CookieQuestPanel._tbDefine = {
{
sPrefabPath = "Play_Cookie/CookieQuestPanel.prefab",
sCtrlName = "Game.UI.Play_Cookie.CookieQuestCtrl"
}
}
function CookieQuestPanel:Awake()
end
function CookieQuestPanel:OnEnable()
end
function CookieQuestPanel:OnAfterEnter()
end
function CookieQuestPanel:OnDisable()
end
function CookieQuestPanel:OnDestroy()
end
function CookieQuestPanel:OnRelease()
end
return CookieQuestPanel
@@ -0,0 +1,40 @@
local CookieScoreBoardCtrl = class("CookieScoreBoardCtrl", BaseCtrl)
CookieScoreBoardCtrl._mapNodeConfig = {
imgModeIcon = {sComponentName = "Image"},
txtTotalScore = {sComponentName = "TMP_Text"},
txtScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Score_Title"
},
imgNew = {},
txtCookieCountRes = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Cookie_Count_Score"
},
txtCookieCountResNum = {sComponentName = "TMP_Text"},
txtBoxCountRes = {
sComponentName = "TMP_Text",
sLanguageId = "Cookie_Act_Box_Count_Score"
},
txtBoxCountResNum = {sComponentName = "TMP_Text"},
txtCriticalPerfectCountNum = {sComponentName = "TMP_Text"},
txtPerfectCountNum = {sComponentName = "TMP_Text"},
txtGoodCountNum = {sComponentName = "TMP_Text"},
txtMissCountNum = {sComponentName = "TMP_Text"},
imgFullCombo = {},
imgAllPerfect = {}
}
function CookieScoreBoardCtrl:Init(nMode, nTotalScore, nCookieCount, nBoxCount, nCriticalPerfectCount, nPerfectCount, nGoodCount, nMissCount, bIsNewRecord, bFullCombo, bAllPerfect)
self:SetPngSprite(self._mapNode.imgModeIcon, AllEnum.CookieModeIcon[nMode] or AllEnum.CookieModeIcon[1])
NovaAPI.SetTMPText(self._mapNode.txtTotalScore, tostring(nTotalScore or 0))
NovaAPI.SetTMPText(self._mapNode.txtCookieCountResNum, tostring(nCookieCount or 0))
NovaAPI.SetTMPText(self._mapNode.txtBoxCountResNum, tostring(nBoxCount or 0))
NovaAPI.SetTMPText(self._mapNode.txtCriticalPerfectCountNum, tostring(nCriticalPerfectCount or 0))
NovaAPI.SetTMPText(self._mapNode.txtPerfectCountNum, tostring(nPerfectCount or 0))
NovaAPI.SetTMPText(self._mapNode.txtGoodCountNum, tostring(nGoodCount or 0))
NovaAPI.SetTMPText(self._mapNode.txtMissCountNum, tostring(nMissCount or 0))
self._mapNode.imgFullCombo:SetActive(bFullCombo == true and bAllPerfect == false)
self._mapNode.imgAllPerfect:SetActive(bAllPerfect == true and bFullCombo == true)
self._mapNode.imgNew:SetActive(bIsNewRecord == true)
end
return CookieScoreBoardCtrl