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:
@@ -0,0 +1,576 @@
|
||||
local ActivityLevelsSelectCtrl = class("ActivityLevelsSelectCtrl", BaseCtrl)
|
||||
local mapToggle = {
|
||||
[1] = GameEnum.diffculty.Diffculty_1,
|
||||
[2] = GameEnum.diffculty.Diffculty_2,
|
||||
[3] = GameEnum.diffculty.Diffculty_3,
|
||||
[4] = GameEnum.diffculty.Diffculty_4,
|
||||
[5] = GameEnum.diffculty.Diffculty_5,
|
||||
[6] = GameEnum.diffculty.Diffculty_6,
|
||||
[7] = GameEnum.diffculty.Diffculty_7,
|
||||
[8] = GameEnum.diffculty.Diffculty_8,
|
||||
[9] = GameEnum.diffculty.Diffculty_9,
|
||||
[10] = GameEnum.diffculty.Diffculty_10
|
||||
}
|
||||
ActivityLevelsSelectCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
goEnemyInfo = {
|
||||
sCtrlName = "Game.UI.MainlineEx.MainlineMonsterInfoCtrl"
|
||||
},
|
||||
togTypeExplore = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_TogTypeExplore"
|
||||
},
|
||||
togTypeExploreCtrl = {
|
||||
sNodeName = "togTypeExplore",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
|
||||
},
|
||||
lockExplore = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnClick_BtnLockExplore"
|
||||
},
|
||||
redExplore = {},
|
||||
togTypeAdventure = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_TogTypeAdventure"
|
||||
},
|
||||
togTypeAdventureCtrl = {
|
||||
sNodeName = "togTypeAdventure",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
|
||||
},
|
||||
lockAdventure = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnClick_BtnLockAdventure"
|
||||
},
|
||||
redAdventure = {},
|
||||
rtToggles = {
|
||||
sNodeName = "srToggle",
|
||||
sComponentName = "UIScrollRect"
|
||||
},
|
||||
tog = {
|
||||
sComponentName = "UIButton",
|
||||
nCount = 10,
|
||||
callback = "OnBtnClick_Tog"
|
||||
},
|
||||
togCtrl = {
|
||||
sNodeName = "tog",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl",
|
||||
nCount = 10
|
||||
},
|
||||
togAniRoot = {sNodeName = "rt_Toggle", sComponentName = "Animator"},
|
||||
txtRecommendLevel = {
|
||||
sNodeName = "txtSuggestLevel",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "InfinityTower_Recommend_Lv"
|
||||
},
|
||||
txtBuildTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "InfinityTower_Recommend_Construct"
|
||||
},
|
||||
imgBuild = {sComponentName = "Image"},
|
||||
TMPName = {sComponentName = "TMP_Text"},
|
||||
detailDesc = {sComponentName = "TMP_Text"},
|
||||
btnEnemyInfo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_EnemyInfo"
|
||||
},
|
||||
tex_EnemyInfo = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Equipment_Instance_EnemyInfo"
|
||||
},
|
||||
txtTitleTarget = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "RogueBoss_Pause_Target"
|
||||
},
|
||||
txtReward = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Level_Award"
|
||||
},
|
||||
Task = {sComponentName = "Transform", nCount = 3},
|
||||
rewardRoot = {sComponentName = "Transform"},
|
||||
btn_itemTemp = {},
|
||||
btnListRoot = {},
|
||||
btnRaid = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnClickBtnRaid"
|
||||
},
|
||||
imgRaidUnlockMask = {},
|
||||
txtBtnRaid = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Raid_Title_Raid"
|
||||
},
|
||||
TMPRaidUnlockHint = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Raid_Btn_Cond"
|
||||
},
|
||||
btnGo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnClickBtnGo"
|
||||
},
|
||||
txtBtnGo = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Maninline_Btn_Go"
|
||||
},
|
||||
goCoin = {},
|
||||
txtTicketsCount = {sComponentName = "TMP_Text"},
|
||||
levelLockRoot = {},
|
||||
UnlockTime = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
ActivityLevelsSelectCtrl._mapEventConfig = {
|
||||
[EventId.UpdateEnergy] = "OnEvent_UpdateEnergy"
|
||||
}
|
||||
ActivityLevelsSelectCtrl._mapRedDotConfig = {}
|
||||
function ActivityLevelsSelectCtrl:Awake()
|
||||
local param = self:GetPanelParam()
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
end
|
||||
self.nLevelType = GameEnum.ActivityLevelType.Explore
|
||||
self.tabRewardList = {}
|
||||
self.AniRoot = self.gameObject:GetComponent("Animator")
|
||||
local bInActGroup, nActGroupId = PlayerData.Activity:IsActivityInActivityGroup(self.nActId)
|
||||
if bInActGroup then
|
||||
RedDotManager.RegisterNode(RedDotDefine.ActivityLevel_Explore, {nActGroupId}, self._mapNode.redExplore)
|
||||
RedDotManager.RegisterNode(RedDotDefine.ActivityLevel_Adventure, {nActGroupId}, self._mapNode.redAdventure)
|
||||
end
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnEnable()
|
||||
self.timeTab = {}
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
self.SelectTogPreLvLock = nil
|
||||
self.AniRoot:Play("ActivityLevelsSelect_in")
|
||||
self:Init()
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnDisable()
|
||||
self.timeTab = {}
|
||||
for i = 1, #self.tabRewardList do
|
||||
local go = self.tabRewardList[i].gameObject
|
||||
local btnSelect = self.tabRewardList[i].gameObject:GetComponent("UIButton")
|
||||
btnSelect.onClick:RemoveAllListeners()
|
||||
self:UnbindCtrlByNode(self.tabRewardList[i])
|
||||
destroy(go)
|
||||
end
|
||||
self.tabRewardList = {}
|
||||
self.SelectTogPreLvLock = nil
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnDestroy(...)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:Init()
|
||||
self.activityLevelsData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self:RefreshTogTypeCount()
|
||||
self:Refresh()
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:Refresh()
|
||||
self.nLevelType = self.activityLevelsData:GetDefaultSelectionType()
|
||||
self:RefreshTogType(self.nLevelType)
|
||||
local nDifficulty = self.activityLevelsData:GetDefaultSelectionDifficulty(self.nLevelType)
|
||||
self:RefreshTogList(self.nLevelType, nDifficulty)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:RefreshTogTypeCount()
|
||||
self._mapNode.togTypeExploreCtrl:SetText(ConfigTable.GetUIText("ActivityLevels_Explore"))
|
||||
self._mapNode.togTypeAdventureCtrl:SetText(ConfigTable.GetUIText("ActivityLevels_Adventure"))
|
||||
self._mapNode.togTypeExploreCtrl:SetDefaultActivity(self.nLevelType == GameEnum.ActivityLevelType.Explore)
|
||||
self._mapNode.togTypeAdventureCtrl:SetDefaultActivity(self.nLevelType == GameEnum.ActivityLevelType.Adventure)
|
||||
local texExplore_SelectCount = self._mapNode.togTypeExplore.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_SelectCount"):GetComponent("TMP_Text")
|
||||
local texExplore_UnSelectCount = self._mapNode.togTypeExplore.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_unSelectCount"):GetComponent("TMP_Text")
|
||||
local texAdventure_SelectCount = self._mapNode.togTypeAdventure.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_SelectCount"):GetComponent("TMP_Text")
|
||||
local texAdventure_UnSelectCount = self._mapNode.togTypeAdventure.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_unSelectCount"):GetComponent("TMP_Text")
|
||||
local totalExplore, exploreCount = self.activityLevelsData:GetLevelStarMsg(GameEnum.ActivityLevelType.Explore)
|
||||
local totalAdventure, adventureCount = self.activityLevelsData:GetLevelStarMsg(GameEnum.ActivityLevelType.Adventure)
|
||||
local str = "%s/%s"
|
||||
self.firstExploreLevel = self.activityLevelsData.levelTabExploreDifficulty[1]
|
||||
local isOpenExplore = self.activityLevelsData:GetLevelDayOpen(GameEnum.ActivityLevelType.Explore, self.firstExploreLevel)
|
||||
self._mapNode.lockExplore.gameObject:SetActive(not isOpenExplore)
|
||||
if isOpenExplore then
|
||||
NovaAPI.SetTMPText(texExplore_SelectCount, string.format(str, exploreCount, totalExplore))
|
||||
NovaAPI.SetTMPText(texExplore_UnSelectCount, string.format(str, exploreCount, totalExplore))
|
||||
else
|
||||
NovaAPI.SetTMPText(texExplore_SelectCount, "")
|
||||
NovaAPI.SetTMPText(texExplore_UnSelectCount, "")
|
||||
end
|
||||
self.firstAdventureLevel = self.activityLevelsData.levelTabAdventureDifficulty[1]
|
||||
local isOpenAdventure = self.activityLevelsData:GetLevelDayOpen(GameEnum.ActivityLevelType.Adventure, self.firstAdventureLevel)
|
||||
self._mapNode.lockAdventure.gameObject:SetActive(not isOpenAdventure)
|
||||
if isOpenAdventure then
|
||||
NovaAPI.SetTMPText(texAdventure_SelectCount, string.format(str, adventureCount, totalAdventure))
|
||||
NovaAPI.SetTMPText(texAdventure_UnSelectCount, string.format(str, adventureCount, totalAdventure))
|
||||
else
|
||||
NovaAPI.SetTMPText(texAdventure_SelectCount, "")
|
||||
NovaAPI.SetTMPText(texAdventure_UnSelectCount, "")
|
||||
end
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnClick_BtnLockExplore()
|
||||
self:FirstLevelLockTips(GameEnum.ActivityLevelType.Explore, self.firstExploreLevel)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnClick_BtnLockAdventure()
|
||||
self:FirstLevelLockTips(GameEnum.ActivityLevelType.Adventure, self.firstAdventureLevel)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:FirstLevelLockTips(nType, nLevel)
|
||||
local day = self.activityLevelsData:GetUnLockDay(nType, nLevel)
|
||||
local strTips = ""
|
||||
if day == 0 then
|
||||
local hour, min, sec = self.activityLevelsData:GetUnLockHour(nType, nLevel)
|
||||
if 0 < hour then
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Hour"), hour)
|
||||
elseif 0 < min then
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Min"), min)
|
||||
elseif 0 < sec then
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Sec"), sec)
|
||||
end
|
||||
else
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Day"), day)
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, strTips)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnBtnClick_TogTypeExplore()
|
||||
if self.nLevelType == GameEnum.ActivityLevelType.Explore then
|
||||
return
|
||||
end
|
||||
self:CloseAllTimer()
|
||||
self.AniRoot:Play("ActivityLevelsSelect_in1")
|
||||
self._mapNode.togAniRoot:Play("ActivityLevelsSelect_Toggle_in")
|
||||
self.nLevelType = GameEnum.ActivityLevelType.Explore
|
||||
self:RefreshTogType(self.nLevelType)
|
||||
local nDifficulty = self.activityLevelsData:GetDefaultSelectionDifficulty(self.nLevelType)
|
||||
self:RefreshTogList(self.nLevelType, nDifficulty)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnBtnClick_TogTypeAdventure()
|
||||
if self.nLevelType == GameEnum.ActivityLevelType.Adventure then
|
||||
return
|
||||
end
|
||||
self:CloseAllTimer()
|
||||
self.AniRoot:Play("ActivityLevelsSelect_in1")
|
||||
self._mapNode.togAniRoot:Play("ActivityLevelsSelect_Toggle_in")
|
||||
self.nLevelType = GameEnum.ActivityLevelType.Adventure
|
||||
self:RefreshTogType(self.nLevelType)
|
||||
local nDifficulty = self.activityLevelsData:GetDefaultSelectionDifficulty(self.nLevelType)
|
||||
self:RefreshTogList(self.nLevelType, nDifficulty)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:CloseAllTimer()
|
||||
for i, v in pairs(self.timeTab) do
|
||||
v:Pause(true)
|
||||
end
|
||||
self.timeTab = {}
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:RefreshTogType(nType)
|
||||
if self.SelectTogPreLvLock ~= nil then
|
||||
NovaAPI.SetImageColor(self.SelectTogPreLvLock, Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764, 1))
|
||||
end
|
||||
self._mapNode.togTypeExploreCtrl:SetTrigger(nType == GameEnum.ActivityLevelType.Explore)
|
||||
self._mapNode.togTypeAdventureCtrl:SetTrigger(nType == GameEnum.ActivityLevelType.Adventure)
|
||||
self._mapNode.togTypeExploreCtrl:SetDefaultActivity(nType == GameEnum.ActivityLevelType.Explore)
|
||||
self._mapNode.togTypeAdventureCtrl:SetDefaultActivity(nType == GameEnum.ActivityLevelType.Adventure)
|
||||
local explore_SelectCount = self._mapNode.togTypeExplore.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_SelectCount").gameObject
|
||||
local explore_UnSelectCount = self._mapNode.togTypeExplore.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_unSelectCount").gameObject
|
||||
local adventure_SelectCount = self._mapNode.togTypeAdventure.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_SelectCount").gameObject
|
||||
local adventure_UnSelectCount = self._mapNode.togTypeAdventure.gameObject.transform:Find("AnimRoot/AnimSwitch/txt_unSelectCount").gameObject
|
||||
explore_SelectCount:SetActive(nType == GameEnum.ActivityLevelType.Explore)
|
||||
explore_UnSelectCount:SetActive(nType ~= GameEnum.ActivityLevelType.Explore)
|
||||
adventure_SelectCount:SetActive(nType == GameEnum.ActivityLevelType.Adventure)
|
||||
adventure_UnSelectCount:SetActive(nType ~= GameEnum.ActivityLevelType.Adventure)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:RefreshTogList(nType, nDifficulty)
|
||||
local tabLevelInfo, tabLevelInfoDifficulty
|
||||
if nType == GameEnum.ActivityLevelType.Explore then
|
||||
tabLevelInfo = self.activityLevelsData.levelTabExplore
|
||||
tabLevelInfoDifficulty = self.activityLevelsData.levelTabExploreDifficulty
|
||||
else
|
||||
tabLevelInfo = self.activityLevelsData.levelTabAdventure
|
||||
tabLevelInfoDifficulty = self.activityLevelsData.levelTabAdventureDifficulty
|
||||
end
|
||||
for i = 1, 10 do
|
||||
self._mapNode.tog[i].gameObject:SetActive(i <= #tabLevelInfoDifficulty)
|
||||
end
|
||||
for i = 1, #tabLevelInfoDifficulty do
|
||||
local tmpId = tabLevelInfoDifficulty[i]
|
||||
local tmpData = tabLevelInfo[tmpId]
|
||||
self._mapNode.togCtrl[i]:SetText(tmpData.baseData.Name)
|
||||
local isOpen = self.activityLevelsData:GetLevelDayOpen(nType, tmpData.baseData.Id)
|
||||
local isLevelUnLock = self.activityLevelsData:GetLevelUnLock(nType, tmpData.baseData.Id)
|
||||
local objTog = self._mapNode.tog[i].gameObject
|
||||
local rt_Targets = objTog.transform:Find("AnimRoot/AnimSwitch/rt_Targets").gameObject
|
||||
local rtLockInfo = objTog.transform:Find("AnimRoot/AnimSwitch/rtLockInfo").gameObject
|
||||
local rtLockPreLv = objTog.transform:Find("AnimRoot/AnimSwitch/rtLockPreLv").gameObject
|
||||
local rtLockPreLvSelect = rtLockPreLv.transform:Find("rtLockPreLvSelect"):GetComponent("Image")
|
||||
NovaAPI.SetImageColor(rtLockPreLvSelect, Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764, 1))
|
||||
local strTips = ""
|
||||
local redH = objTog.transform:Find("AnimRoot/AnimSwitch/redH").gameObject
|
||||
local bInActGroup, nActGroupId = PlayerData.Activity:IsActivityInActivityGroup(self.nActId)
|
||||
if bInActGroup then
|
||||
if tmpData.baseData.Type == GameEnum.ActivityLevelType.Explore then
|
||||
RedDotManager.RegisterNode(RedDotDefine.ActivityLevel_Explore_Level, {
|
||||
nActGroupId,
|
||||
tmpData.baseData.Id
|
||||
}, redH)
|
||||
else
|
||||
RedDotManager.RegisterNode(RedDotDefine.ActivityLevel_Adventure_Level, {
|
||||
nActGroupId,
|
||||
tmpData.baseData.Id
|
||||
}, redH)
|
||||
end
|
||||
end
|
||||
if isOpen and isLevelUnLock then
|
||||
rt_Targets:SetActive(true)
|
||||
for j = 1, 3 do
|
||||
local btnStar = rt_Targets.gameObject.transform:Find("btnTarget" .. j):GetComponent("Button")
|
||||
btnStar.interactable = j <= tmpData.Star
|
||||
end
|
||||
rtLockInfo:SetActive(false)
|
||||
rtLockPreLv:SetActive(false)
|
||||
elseif isOpen and not isLevelUnLock then
|
||||
rt_Targets:SetActive(false)
|
||||
rtLockInfo:SetActive(false)
|
||||
rtLockPreLv:SetActive(true)
|
||||
elseif not isOpen then
|
||||
for i = 1, 5 do
|
||||
local objDeco = objTog.transform:Find("AnimRoot/AnimSwitch/goBg/Select/imgFlowWave1/imgDeco" .. i).gameObject
|
||||
if objDeco ~= nil then
|
||||
objDeco:SetActive(false)
|
||||
end
|
||||
end
|
||||
rt_Targets:SetActive(false)
|
||||
local day = self.activityLevelsData:GetUnLockDay(nType, tmpData.baseData.Id)
|
||||
if day == 0 then
|
||||
local rtLockInfoDay = rtLockInfo.gameObject.transform:Find("rtLockInfoDay").gameObject
|
||||
local bgCondition = rtLockInfo.gameObject.transform:Find("bgCondition").gameObject
|
||||
rtLockInfoDay:SetActive(false)
|
||||
bgCondition:SetActive(true)
|
||||
local txtLockCondition = rtLockInfo.gameObject.transform:Find("bgCondition/txtLockCondition"):GetComponent("TMP_Text")
|
||||
local timerCount = function()
|
||||
local hour, min, sec = self.activityLevelsData:GetUnLockHour(nType, tmpData.baseData.Id)
|
||||
if 0 < hour then
|
||||
NovaAPI.SetTMPText(txtLockCondition, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Hour_Color"), hour))
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Hour"), hour)
|
||||
elseif 0 < min then
|
||||
NovaAPI.SetTMPText(txtLockCondition, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Min_Color"), min))
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Min"), min)
|
||||
elseif 0 < sec then
|
||||
NovaAPI.SetTMPText(txtLockCondition, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Sec_Color"), sec))
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Sec"), sec)
|
||||
end
|
||||
end
|
||||
timerCount()
|
||||
self.timeTab[tmpData.baseData.Id] = self:AddTimer(0, 1, function()
|
||||
timerCount()
|
||||
end, true, true, false)
|
||||
rtLockInfo:SetActive(true)
|
||||
rtLockPreLv:SetActive(false)
|
||||
else
|
||||
rt_Targets:SetActive(false)
|
||||
local rtLockInfoDay = rtLockInfo.gameObject.transform:Find("rtLockInfoDay").gameObject
|
||||
local bgCondition = rtLockInfo.gameObject.transform:Find("bgCondition").gameObject
|
||||
rtLockInfoDay:SetActive(true)
|
||||
bgCondition:SetActive(false)
|
||||
strTips = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Day"), day)
|
||||
rtLockInfo:SetActive(true)
|
||||
rtLockPreLv:SetActive(false)
|
||||
end
|
||||
end
|
||||
local clickCb = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, strTips)
|
||||
end
|
||||
if i == nDifficulty then
|
||||
self:RefreshInstanceInfo(nType, nDifficulty, true, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnBtnClick_Tog(btn)
|
||||
local nHard = table.indexof(self._mapNode.tog, btn:GetComponent("UIButton"))
|
||||
local togIdx = table.indexof(self._mapNode.tog, btn)
|
||||
if nHard == nil then
|
||||
return
|
||||
end
|
||||
if self.curSelectHard ~= nHard then
|
||||
if self.SelectTogPreLvLock ~= nil then
|
||||
NovaAPI.SetImageColor(self.SelectTogPreLvLock, Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764, 1))
|
||||
end
|
||||
for idx, value in pairs(mapToggle) do
|
||||
if value == self.curSelectHard then
|
||||
self._mapNode.togCtrl[idx]:SetDefault(false)
|
||||
break
|
||||
end
|
||||
end
|
||||
self._mapNode.togCtrl[togIdx]:SetDefault(true)
|
||||
self.SelectTogPreLvLock = self._mapNode.togCtrl[togIdx].gameObject.transform:Find("AnimRoot/AnimSwitch/rtLockPreLv/rtLockPreLvSelect"):GetComponent("Image")
|
||||
NovaAPI.SetImageColor(self.SelectTogPreLvLock, Color(1, 1, 1, 1))
|
||||
self:RefreshInstanceInfo(self.nLevelType, nHard, nil, false)
|
||||
local levelId = 0
|
||||
if self.nLevelType == GameEnum.ActivityLevelType.Explore then
|
||||
levelId = self.activityLevelsData.levelTabExploreDifficulty[nHard]
|
||||
else
|
||||
levelId = self.activityLevelsData.levelTabAdventureDifficulty[nHard]
|
||||
end
|
||||
self.activityLevelsData:ChangeRedDot(self.nLevelType, levelId)
|
||||
self.AniRoot:Play("ActivityLevelsSelect_in1")
|
||||
end
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:RefreshInstanceInfo(nType, nHard, bLocation, bSetTog)
|
||||
if bLocation then
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
NovaAPI.UIScrollRectScrollTo(self._mapNode.rtToggles, nHard + 1, true)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
if bSetTog then
|
||||
for i = 1, 10 do
|
||||
self._mapNode.togCtrl[i]:SetDefault(i == nHard)
|
||||
end
|
||||
end
|
||||
self.curSelectHard = nHard
|
||||
local levelId = 0
|
||||
self.selectLevelData = nil
|
||||
if nType == GameEnum.ActivityLevelType.Explore then
|
||||
levelId = self.activityLevelsData.levelTabExploreDifficulty[nHard]
|
||||
self.selectLevelData = self.activityLevelsData.levelTabExplore[levelId]
|
||||
else
|
||||
levelId = self.activityLevelsData.levelTabAdventureDifficulty[nHard]
|
||||
self.selectLevelData = self.activityLevelsData.levelTabAdventure[levelId]
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRecommendLevel, self.selectLevelData.baseData.SuggestedPower)
|
||||
local sRank = "Icon/BuildRank/BuildRank_" .. self.selectLevelData.baseData.RecommendBuildRank
|
||||
self:SetPngSprite(self._mapNode.imgBuild, sRank)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPName, self.selectLevelData.baseData.Name)
|
||||
NovaAPI.SetTMPText(self._mapNode.detailDesc, self.selectLevelData.baseData.Desc)
|
||||
self.curStar = self.selectLevelData.Star
|
||||
local tbCond = {
|
||||
self.selectLevelData.baseData.OneStarDesc,
|
||||
self.selectLevelData.baseData.TwoStarDesc,
|
||||
self.selectLevelData.baseData.ThreeStarDesc
|
||||
}
|
||||
for i = 1, 3 do
|
||||
local rtTask = self._mapNode.Task[i]
|
||||
local goDone = rtTask:Find("imgDone").gameObject
|
||||
local imgUnDone = rtTask:Find("imgUnDone").gameObject
|
||||
local Text = rtTask:Find("Text"):GetComponent("TMP_Text")
|
||||
goDone:SetActive(i <= self.curStar)
|
||||
imgUnDone:SetActive(i > self.curStar)
|
||||
local cond = tbCond[i]
|
||||
if cond == nil then
|
||||
rtTask.gameObject:SetActive(false)
|
||||
return
|
||||
else
|
||||
rtTask.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(Text, cond)
|
||||
end
|
||||
end
|
||||
self.PreviewMonsterGroupId = self.selectLevelData.baseData.PreviewMonsterGroupId
|
||||
local isOpen = self.activityLevelsData:GetLevelDayOpen(nType, self.selectLevelData.baseData.Id)
|
||||
local isLevelUnLock = self.activityLevelsData:GetLevelUnLock(nType, self.selectLevelData.baseData.Id)
|
||||
local isNeedEnergyConsume = true
|
||||
if not self.selectLevelData.baseData.EnergyConsumeOnRetry and 0 < self.selectLevelData.Star then
|
||||
isNeedEnergyConsume = false
|
||||
end
|
||||
if isOpen and isLevelUnLock then
|
||||
self._mapNode.btnListRoot:SetActive(true)
|
||||
self._mapNode.levelLockRoot:SetActive(false)
|
||||
if self.selectLevelData.baseData.ThreeStarSweep then
|
||||
self._mapNode.btnRaid.gameObject:SetActive(true)
|
||||
self._mapNode.txtBtnRaid.gameObject:SetActive(self.curStar == 3)
|
||||
self._mapNode.imgRaidUnlockMask.gameObject:SetActive(self.curStar ~= 3)
|
||||
else
|
||||
self._mapNode.btnRaid.gameObject:SetActive(false)
|
||||
end
|
||||
local nHas = PlayerData.Base:GetCurEnergy()
|
||||
local nRequire = self.selectLevelData.baseData.EnergyConsume
|
||||
if not isNeedEnergyConsume then
|
||||
nRequire = 0
|
||||
end
|
||||
self.curRequireEnergy = nRequire
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTicketsCount, nRequire)
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtTicketsCount, nRequire > nHas.nEnergy and Red_Unable or Blue_Normal)
|
||||
self._mapNode.goCoin:SetActive(isNeedEnergyConsume)
|
||||
elseif isOpen and not isLevelUnLock then
|
||||
self._mapNode.btnListRoot:SetActive(false)
|
||||
self._mapNode.levelLockRoot:SetActive(true)
|
||||
local preLevelId = self.selectLevelData.baseData.PreLevelId
|
||||
if preLevelId ~= 0 then
|
||||
local tmpData = ConfigTable.GetData("ActivityLevelsLevel", preLevelId)
|
||||
NovaAPI.SetTMPText(self._mapNode.UnlockTime, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_PreLevel"), tmpData.Name))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.UnlockTime, ConfigTable.GetUIText("Unlocked_By_PreLevel"))
|
||||
end
|
||||
elseif not isOpen then
|
||||
self._mapNode.btnListRoot:SetActive(false)
|
||||
self._mapNode.levelLockRoot:SetActive(true)
|
||||
local day = self.activityLevelsData:GetUnLockDay(nType, self.selectLevelData.baseData.Id)
|
||||
if day == 0 then
|
||||
local hour, min, sec = self.activityLevelsData:GetUnLockHour(nType, self.selectLevelData.baseData.Id)
|
||||
if 0 < hour then
|
||||
NovaAPI.SetTMPText(self._mapNode.UnlockTime, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Hour"), hour))
|
||||
elseif 0 < min then
|
||||
NovaAPI.SetTMPText(self._mapNode.UnlockTime, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Min"), min))
|
||||
elseif 0 < sec then
|
||||
NovaAPI.SetTMPText(self._mapNode.UnlockTime, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Sec"), sec))
|
||||
end
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.UnlockTime, orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_DayOpen"), day))
|
||||
end
|
||||
end
|
||||
for i = 1, #self.tabRewardList do
|
||||
self.tabRewardList[i].gameObject:SetActive(false)
|
||||
end
|
||||
local tbReward = decodeJson(self.selectLevelData.baseData.CompleteRewardPreview)
|
||||
for i = 1, #tbReward do
|
||||
if i > #self.tabRewardList then
|
||||
local obj = instantiate(self._mapNode.btn_itemTemp, self._mapNode.rewardRoot)
|
||||
self.tabRewardList[i] = self:BindCtrlByNode(obj, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
do
|
||||
local itemCtrl = self.tabRewardList[i]
|
||||
itemCtrl.gameObject:SetActive(true)
|
||||
if tbReward[i] ~= nil then
|
||||
local bReceived = 0 < self.selectLevelData.Star and tbReward[i][3] == 1
|
||||
local bFirstPass = tbReward[i][3] == 1
|
||||
itemCtrl:SetItem(tbReward[i][1], nil, UTILS.ParseRewardItemCount(tbReward[i]), nil, bReceived, bFirstPass, false, true)
|
||||
local btnItem = itemCtrl.gameObject:GetComponent("UIButton")
|
||||
btnItem.onClick:RemoveAllListeners()
|
||||
local clickCb = function()
|
||||
self:OnBtnClick_RewardItem(tbReward[i][1], btnItem.gameObject)
|
||||
end
|
||||
btnItem.onClick:AddListener(clickCb)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnBtnClick_RewardItem(nTid, btn)
|
||||
local rtBtn = btn.transform
|
||||
UTILS.ClickItemGridWithTips(nTid, rtBtn, false, true, false)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnClickBtnGo()
|
||||
local nEnergy = PlayerData.Base:GetCurEnergy().nEnergy
|
||||
if nEnergy < self.curRequireEnergy then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.EnergyBuy)
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EnergyBuy, AllEnum.EnergyPanelType.Main, {}, true, callback)
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("MainlineData_Energy"))
|
||||
return
|
||||
end
|
||||
self.activityLevelsData:ChangeRedDot(self.selectLevelData.baseData.Type, self.selectLevelData.baseData.Id)
|
||||
PlayerData.Activity:SetActivityLevelActId(self.nActId)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RegionBossFormation, AllEnum.RegionBossFormationType.ActivityLevels, self.selectLevelData.baseData.Id, {
|
||||
self.nActId
|
||||
})
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnClickBtnRaid()
|
||||
if self.curStar ~= 3 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Raid_Lock"))
|
||||
return
|
||||
end
|
||||
local nNeedEnergy = self.curRequireEnergy
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Raid, self.selectLevelData.baseData.Id, nNeedEnergy, 5, self.nActId)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnBtnClick_EnemyInfo()
|
||||
EventManager.Hit("OpenActivityLevelsMonsterInfo", self.PreviewMonsterGroupId)
|
||||
end
|
||||
function ActivityLevelsSelectCtrl:OnEvent_UpdateEnergy()
|
||||
local nHas = PlayerData.Base:GetCurEnergy()
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtTicketsCount, nHas.nEnergy < self.curRequireEnergy and Red_Unable or Blue_Normal)
|
||||
end
|
||||
return ActivityLevelsSelectCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local ActivityLevelsSelectPanel = class("ActivityLevelsSelectPanel", BasePanel)
|
||||
ActivityLevelsSelectPanel._sUIResRootPath = "UI_Activity/"
|
||||
ActivityLevelsSelectPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Swim/ActivityLevels/ActivityLevelsSelect.prefab",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.ActivityLevels.ActivityLevelsSelectCtrl"
|
||||
}
|
||||
}
|
||||
function ActivityLevelsSelectPanel:Awake()
|
||||
end
|
||||
function ActivityLevelsSelectPanel:OnEnable()
|
||||
end
|
||||
function ActivityLevelsSelectPanel:OnAfterEnter()
|
||||
end
|
||||
function ActivityLevelsSelectPanel:OnDisable()
|
||||
end
|
||||
function ActivityLevelsSelectPanel:OnDestroy()
|
||||
end
|
||||
function ActivityLevelsSelectPanel:OnRelease()
|
||||
end
|
||||
return ActivityLevelsSelectPanel
|
||||
@@ -0,0 +1,173 @@
|
||||
local ActivitySwimCtrl = class("ActivitySwimCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
ActivitySwimCtrl._mapNodeConfig = {
|
||||
btnGo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
},
|
||||
txtTime = {sComponentName = "TMP_Text"},
|
||||
svReward = {
|
||||
sNodeName = "PreviewUpgradeMaterial",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
txtAdvanceMat = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MessageBox_Reward"
|
||||
},
|
||||
txtDate = {sComponentName = "TMP_Text"},
|
||||
imgLock = {},
|
||||
txtLock = {sComponentName = "TMP_Text"},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtBtnDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Btn_Detail"
|
||||
},
|
||||
imgEnd = {},
|
||||
txtActivityEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
imgRemaineTime = {},
|
||||
txtBtnGo = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "TowerDef_EnterActivity"
|
||||
}
|
||||
}
|
||||
function ActivitySwimCtrl:Awake()
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function ActivitySwimCtrl:OnDisable()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function ActivitySwimCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self:RefreshLockState()
|
||||
self:RefreshDate()
|
||||
self:RefreshTimeout()
|
||||
self:RefreshReward()
|
||||
end
|
||||
function ActivitySwimCtrl:UnInit()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function ActivitySwimCtrl:UnbindCtrl()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function ActivitySwimCtrl:RefreshLockState()
|
||||
local IsUnlock, txtLock = self.actData:IsUnlock()
|
||||
self._mapNode.imgLock.gameObject:SetActive(not IsUnlock)
|
||||
self._mapNode.btnGo.gameObject:SetActive(IsUnlock)
|
||||
if not IsUnlock then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLock, txtLock)
|
||||
end
|
||||
end
|
||||
function ActivitySwimCtrl:RefreshTimeout()
|
||||
local endTime = self.actData:GetActGroupEndTime()
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
self._mapNode.imgRemaineTime:SetActive(0 < remainTime)
|
||||
self._mapNode.imgEnd:SetActive(remainTime <= 0)
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
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 = 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 = 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 = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTime, sTimeStr)
|
||||
end
|
||||
function ActivitySwimCtrl:RefreshDate()
|
||||
local nOpenMonth, nOpenDay, nEndMonth, nEndDay, nOpenYear, nEndYear = self.actData:GetActGroupDate()
|
||||
local strOpenDay = string.format("%02d", nOpenDay)
|
||||
local strEndDay = string.format("%02d", nEndDay)
|
||||
local dateStr = string.format("%s/%s/%s ~ %s/%s/%s", nOpenYear, nOpenMonth, strOpenDay, nEndYear, nEndMonth, strEndDay)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDate, dateStr)
|
||||
end
|
||||
function ActivitySwimCtrl:RefreshReward()
|
||||
local actGroupCfg = self.actData:GetActGroupCfgData()
|
||||
local rewardData = actGroupCfg.RewardsShow
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._mapNode.svReward:Init(#rewardData, self, self.RefreshRewardGridItem, self.BtnRewardGridClick)
|
||||
end
|
||||
function ActivitySwimCtrl:RefreshRewardGridItem(go, index)
|
||||
local actGroupCfg = self.actData:GetActGroupCfgData()
|
||||
local rewardData = actGroupCfg.RewardsShow
|
||||
local rewardId = rewardData[index + 1]
|
||||
local nInstanceID = go:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(go, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetItem(rewardId)
|
||||
end
|
||||
function ActivitySwimCtrl:BtnRewardGridClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local actGroupCfg = self.actData:GetActGroupCfgData()
|
||||
local rewardData = actGroupCfg.RewardsShow
|
||||
local item = goGrid.transform:Find("AnimRoot/item")
|
||||
UTILS.ClickItemGridWithTips(rewardData[nIndex], item.transform, true, true, false)
|
||||
end
|
||||
function ActivitySwimCtrl:OnBtnClick_Go()
|
||||
local actGroupCfg = self.actData:GetActGroupCfgData()
|
||||
if actGroupCfg ~= nil then
|
||||
if actGroupCfg.TransitionId ~= nil and actGroupCfg.TransitionId > 0 then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SwimTheme, actGroupCfg.Id)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, actGroupCfg.TransitionId, callback)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SwimTheme, actGroupCfg.Id)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivitySwimCtrl:OnBtnClick_Detail()
|
||||
local actGroupCfg = self.actData:GetActGroupCfgData()
|
||||
if actGroupCfg == nil then
|
||||
return
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = actGroupCfg.DesText,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function ActivitySwimCtrl:ClearActivity()
|
||||
end
|
||||
return ActivitySwimCtrl
|
||||
@@ -0,0 +1,259 @@
|
||||
local ActivityShopCtrl = class("ActivityShopCtrl", BaseCtrl)
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local BubbleVoiceManager = require("Game.Actor2D.BubbleVoiceManager")
|
||||
local PlayerVoiceData = PlayerData.Voice
|
||||
ActivityShopCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
rawImgActor2D = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
aniRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnActor2D = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Actor2D"
|
||||
},
|
||||
svTog = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
trSvTog = {sNodeName = "svTog", sComponentName = "Transform"},
|
||||
Goods = {
|
||||
sNodeName = "---Goods---",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.Shop.ActivityShopGoodsCtrl"
|
||||
},
|
||||
goBubbleRoot = {
|
||||
sNodeName = "----fixed_bubble----"
|
||||
}
|
||||
}
|
||||
ActivityShopCtrl._mapEventConfig = {
|
||||
ActivityShopTimeRefresh = "OnEvent_TimeRefresh",
|
||||
[EventId.ShowBubbleVoiceText] = "OnEvent_ShowBubbleVoiceText",
|
||||
ActivityShopBuyVoice = "PlayBuyVoice",
|
||||
[EventId.UIBackConfirm] = "OnEvent_UIBack",
|
||||
[EventId.UIHomeConfirm] = "OnEvent_Home"
|
||||
}
|
||||
function ActivityShopCtrl:CheckShopData()
|
||||
EventManager.Hit("ActivityShopCloseDetail")
|
||||
self._panel.actShopData:RefreshActivityShopData()
|
||||
self:RefreshData()
|
||||
if self.nShopCount == 0 or not self.nSelectShop then
|
||||
return
|
||||
end
|
||||
self:RefreshTog()
|
||||
self:SetTimer()
|
||||
self:SwitchTog()
|
||||
self:RefreshNPC2D()
|
||||
end
|
||||
function ActivityShopCtrl:RefreshData()
|
||||
self.tbShops = self._panel.actShopData:GetShopList()
|
||||
self.nShopCount = #self.tbShops
|
||||
self.ctrlTog = {}
|
||||
if self.nCurTog == nil then
|
||||
self.nCurTog = 1
|
||||
if self._panel.nDefaultId then
|
||||
for k, v in ipairs(self.tbShops) do
|
||||
if v.nId == self._panel.nDefaultId then
|
||||
self.nCurTog = k
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not self.tbShops[self.nCurTog] or self.nSelectShop and self.tbShops[self.nCurTog].nId ~= self.nSelectShop then
|
||||
self.nCurTog = 1
|
||||
end
|
||||
if self.tbShops[self.nCurTog] then
|
||||
self.nSelectShop = self.tbShops[self.nCurTog].nId
|
||||
end
|
||||
end
|
||||
function ActivityShopCtrl:RefreshTog()
|
||||
if self.nShopCount > 1 then
|
||||
self._mapNode.svTog.gameObject:SetActive(true)
|
||||
for nInstanceID, objCtrl in pairs(self.ctrlTog) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.ctrlTog[nInstanceID] = nil
|
||||
end
|
||||
self._mapNode.svTog:Init(self.nShopCount, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
else
|
||||
self._mapNode.svTog.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function ActivityShopCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.ctrlTog[nInstanceID] then
|
||||
self.ctrlTog[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.TemplateEx.TemplateToggleCtrl")
|
||||
end
|
||||
local mapCfg = ConfigTable.GetData("ActivityShop", self.tbShops[nIndex].nId)
|
||||
if mapCfg then
|
||||
self.ctrlTog[nInstanceID]:SetText(mapCfg.Name)
|
||||
end
|
||||
self.ctrlTog[nInstanceID]:SetDefault(nIndex == self.nCurTog)
|
||||
end
|
||||
function ActivityShopCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if nIndex == self.nCurTog then
|
||||
return
|
||||
end
|
||||
self.ctrlTog[nInstanceID]:SetTrigger(true)
|
||||
if self.nCurTog then
|
||||
local goSelect = self._mapNode.trSvTog:Find("Viewport/Content/" .. self.nCurTog - 1)
|
||||
if goSelect then
|
||||
self.ctrlTog[goSelect.gameObject:GetInstanceID()]:SetTrigger(false)
|
||||
end
|
||||
end
|
||||
self.nCurTog = nIndex
|
||||
self.nSelectShop = self.tbShops[self.nCurTog].nId
|
||||
self:SwitchTog()
|
||||
self._mapNode.aniRoot:Play("ShopPanel_in")
|
||||
self:PlaySwitchTogVoice()
|
||||
end
|
||||
function ActivityShopCtrl:SetTimer()
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel(false)
|
||||
self.timer = nil
|
||||
end
|
||||
local nTime = self._panel.actShopData:GetShopAutoUpdateTime()
|
||||
if 0 < nTime then
|
||||
self.timer = self:AddTimer(1, nTime, function()
|
||||
self:CheckShopData()
|
||||
if self.nShopCount == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_End_Notice"))
|
||||
EventManager.Hit(EventId.CloseMessageBox)
|
||||
EventManager.Hit(EventId.CloesCurPanel)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Shop_ShopRefresh"))
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
end
|
||||
function ActivityShopCtrl:SwitchTog()
|
||||
local mapShop = self.tbShops[self.nCurTog]
|
||||
local mapCfg = ConfigTable.GetData("ActivityShop", mapShop.nId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
self._mapNode.TopBar:CreateCoin({
|
||||
mapCfg.CurrencyItemId
|
||||
})
|
||||
self._mapNode.Goods:Open(mapShop.nId, mapShop.nNextRefreshTime)
|
||||
end
|
||||
function ActivityShopCtrl: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, self.nNpcId)
|
||||
else
|
||||
Actor2DManager.SetBoardNPC2D_PNG(self._mapNode.trActor2D_PNG, self:GetPanelId(), self.nNpcId)
|
||||
end
|
||||
end
|
||||
function ActivityShopCtrl:PlayEnterVoice()
|
||||
local nTimeNow = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local bFirst = self._panel.actShopData:GetShopFirstIn()
|
||||
local sTimeVoice = ""
|
||||
local nHour = tonumber(os.date("!%H", nTimeNow))
|
||||
if 6 <= nHour and nHour < 12 then
|
||||
sTimeVoice = "greetmorn_npc"
|
||||
elseif 12 <= nHour and nHour < 18 then
|
||||
sTimeVoice = "greetnoon_npc"
|
||||
else
|
||||
sTimeVoice = "greetnight_npc"
|
||||
end
|
||||
if bFirst then
|
||||
PlayerData.Voice:PlayCharVoice(sTimeVoice, self.nNpcId)
|
||||
else
|
||||
local nIndex = math.random(1, 2)
|
||||
local sVoice = nIndex == 1 and sTimeVoice or "greet_npc"
|
||||
PlayerData.Voice:PlayCharVoice(sVoice, self.nNpcId)
|
||||
end
|
||||
end
|
||||
function ActivityShopCtrl:PlayBuyVoice(bLimit)
|
||||
local sVoice = ""
|
||||
if bLimit then
|
||||
sVoice = "limited"
|
||||
else
|
||||
sVoice = "thank_npc"
|
||||
end
|
||||
PlayerData.Voice:PlayCharVoice(sVoice, self.nNpcId)
|
||||
end
|
||||
function ActivityShopCtrl:PlaySwitchTogVoice()
|
||||
PlayerData.Voice:PlayCharVoice("Tab", self.nNpcId)
|
||||
end
|
||||
function ActivityShopCtrl:RefreshNPCId()
|
||||
local mapCfg = ConfigTable.GetData("ActivityShopControl", self._panel.nActId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
local tbNpc = mapCfg.Npc
|
||||
local nRandomIndex = math.random(1, #tbNpc)
|
||||
self.nNpcId = tbNpc[nRandomIndex]
|
||||
end
|
||||
function ActivityShopCtrl:FadeIn(bPlayFadeIn)
|
||||
self._mapNode.aniRoot:Play("ShopPanel_in")
|
||||
end
|
||||
function ActivityShopCtrl:Awake()
|
||||
self.nCurTog = nil
|
||||
end
|
||||
function ActivityShopCtrl:OnEnable()
|
||||
self:RefreshNPCId()
|
||||
PlayerVoiceData:StartBoardFreeTimer(self.nNpcId)
|
||||
self:PlayEnterVoice()
|
||||
self:CheckShopData()
|
||||
end
|
||||
function ActivityShopCtrl:OnDisable()
|
||||
if self.ctrlTog then
|
||||
for nInstanceId, objCtrl in pairs(self.ctrlTog) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.ctrlTog[nInstanceId] = nil
|
||||
end
|
||||
self.ctrlTog = {}
|
||||
end
|
||||
Actor2DManager.UnsetBoardNPC2D()
|
||||
BubbleVoiceManager.StopBubbleAnim()
|
||||
PlayerVoiceData:ClearTimer()
|
||||
PlayerVoiceData:StopCharVoice()
|
||||
end
|
||||
function ActivityShopCtrl:OnDestroy()
|
||||
end
|
||||
function ActivityShopCtrl:OnBtnClick_Actor2D()
|
||||
PlayerVoiceData:PlayBoardNPCClickVoice(self.nNpcId)
|
||||
end
|
||||
function ActivityShopCtrl:OnEvent_TimeRefresh()
|
||||
self:CheckShopData()
|
||||
end
|
||||
function ActivityShopCtrl:OnEvent_ShowBubbleVoiceText(nNpcId, nId)
|
||||
if nNpcId ~= self.nNpcId 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
|
||||
function ActivityShopCtrl:OnEvent_UIBack(nPanelId)
|
||||
if PanelId.DiscSample ~= nPanelId or PanelId.CharBgTrialPanel ~= nPanelId then
|
||||
PlayerVoiceData:StartBoardFreeTimer(self.nNpcId)
|
||||
CS.WwiseAudioManager.Instance:SetState("menuTransition", "open")
|
||||
end
|
||||
end
|
||||
function ActivityShopCtrl:OnEvent_Home(nPanelId)
|
||||
if PanelId.DiscSample ~= nPanelId or PanelId.CharBgTrialPanel ~= nPanelId then
|
||||
PlayerVoiceData:StartBoardFreeTimer(self.nNpcId)
|
||||
end
|
||||
end
|
||||
return ActivityShopCtrl
|
||||
@@ -0,0 +1,75 @@
|
||||
local ActivityShopGoodsCtrl = class("ActivityShopGoodsCtrl", BaseCtrl)
|
||||
ActivityShopGoodsCtrl._mapNodeConfig = {
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
}
|
||||
}
|
||||
ActivityShopGoodsCtrl._mapEventConfig = {
|
||||
ActivityShopRefreshGoods = "CheckGoodsData"
|
||||
}
|
||||
function ActivityShopGoodsCtrl:Open(nShopId, nShopAutoTime)
|
||||
self.nShopId = nShopId
|
||||
self.nShopAutoTime = nShopAutoTime
|
||||
self:CheckGoodsData(true)
|
||||
end
|
||||
function ActivityShopGoodsCtrl:CheckGoodsData(bResetPos)
|
||||
self._panel.actShopData:CheckGoodsData(self.nShopId)
|
||||
self.tbGoods = self._panel.actShopData:GetGoodsList(self.nShopId)
|
||||
self:SetTimer()
|
||||
self:RefreshList(bResetPos)
|
||||
end
|
||||
function ActivityShopGoodsCtrl:SetTimer()
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel(false)
|
||||
self.timer = nil
|
||||
end
|
||||
local nTime = self._panel.actShopData:GetGoodsAutoUpdateTime(self.nShopId)
|
||||
if 0 < nTime and (self.nShopAutoTime == 0 or nTime < self.nShopAutoTime) then
|
||||
self.timer = self:AddTimer(1, nTime, function()
|
||||
EventManager.Hit("ActivityShopCloseDetail")
|
||||
EventManager.Hit(EventId.CloseMessageBox)
|
||||
self:CheckGoodsData(true)
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Shop_GoodsRefresh"))
|
||||
end, true, true, false)
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsCtrl:RefreshList(bResetPos)
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._mapNode.sv:SetAnim(0.04)
|
||||
self._mapNode.sv:Init(#self.tbGoods, self, self.OnGridRefresh, self.OnGridBtnClick, not bResetPos)
|
||||
end
|
||||
function ActivityShopGoodsCtrl: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.ActivityTheme.Swim.Shop.ActivityShopGoodsItemCtrl")
|
||||
end
|
||||
local mapCfg = ConfigTable.GetData("ActivityShop", self.nShopId)
|
||||
if mapCfg then
|
||||
self.tbGridCtrl[nInstanceID]:Refresh(mapData, mapCfg.CurrencyItemId)
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbGoods[nIndex]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SwimShopPopup, mapData, self.nShopId, self._panel.nActId)
|
||||
end
|
||||
function ActivityShopGoodsCtrl:Awake()
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function ActivityShopGoodsCtrl:OnEnable()
|
||||
end
|
||||
function ActivityShopGoodsCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function ActivityShopGoodsCtrl:OnDestroy()
|
||||
end
|
||||
return ActivityShopGoodsCtrl
|
||||
@@ -0,0 +1,256 @@
|
||||
local ActivityShopGoodsDetailCtrl = class("ActivityShopGoodsDetailCtrl", BaseCtrl)
|
||||
ActivityShopGoodsDetailCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Shop_TitleBuy"
|
||||
},
|
||||
goItem = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
txtDesc = {sComponentName = "TMP_Text"},
|
||||
txtHas = {sComponentName = "TMP_Text"},
|
||||
txtPriceCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Shop_UnitPrice"
|
||||
},
|
||||
imgCoin = {nCount = 2, sComponentName = "Image"},
|
||||
txtPrice = {sComponentName = "TMP_Text"},
|
||||
txtStock = {sComponentName = "TMP_Text"},
|
||||
goStock = {},
|
||||
txtBtnBuy = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Shop_Btn_Buy"
|
||||
},
|
||||
txtCoinCount = {sComponentName = "TMP_Text"},
|
||||
btnBuy = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Buy"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
btnBuy2 = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Disable"
|
||||
},
|
||||
txtDisable = {sComponentName = "TMP_Text"},
|
||||
goQuantitySelector = {
|
||||
sNodeName = "tc_quantity_selector",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateQuantitySelectorCtrl"
|
||||
}
|
||||
}
|
||||
ActivityShopGoodsDetailCtrl._mapEventConfig = {}
|
||||
function ActivityShopGoodsDetailCtrl:Refresh(mapData, nShopId, nActId)
|
||||
self.mapGoodsCfg = ConfigTable.GetData("ActivityGoods", mapData.nId)
|
||||
local mapShopCfg = ConfigTable.GetData("ActivityShop", nShopId)
|
||||
if not self.mapGoodsCfg or not mapShopCfg then
|
||||
return
|
||||
end
|
||||
self.mapData = mapData
|
||||
self.nShopId = nShopId
|
||||
self.nCurrencyItemId = mapShopCfg.CurrencyItemId
|
||||
self.bAble = mapData.bPurchasTime and mapData.bPurchasable and not mapData.bSoldOut
|
||||
self.actShopData = PlayerData.Activity:GetActivityDataById(nActId)
|
||||
self:PlayInAni()
|
||||
self:RefreshInfo()
|
||||
self:RefreshPrice()
|
||||
self:RefreshBuyState()
|
||||
self:RefreshBuyCount()
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:RefreshInfo()
|
||||
local nItemId = self.mapGoodsCfg.ItemId
|
||||
local mapCfg = ConfigTable.GetData_Item(nItemId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, self.mapGoodsCfg.Name)
|
||||
self._mapNode.goItem:SetItem(nItemId, nil, self.mapGoodsCfg.ItemQuantity, nil, nil, nil, nil, true)
|
||||
if mapCfg.Type == GameEnum.itemType.Disc or mapCfg.Type == GameEnum.itemType.Char or mapCfg.Type == GameEnum.itemType.CharacterSkin then
|
||||
self._mapNode.txtHas.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.txtHas.gameObject:SetActive(true)
|
||||
local nCount = PlayerData.Item:GetItemCountByID(nItemId)
|
||||
if 999999 < nCount then
|
||||
local nFloor = math.floor(nCount / 100)
|
||||
local nK = string.format("%.0f", nFloor / 10)
|
||||
local sCount = nK .. "k"
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHas, ConfigTable.GetUIText("Shop_Has") .. sCount)
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHas, ConfigTable.GetUIText("Shop_Has") .. nCount)
|
||||
end
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, self.mapGoodsCfg.Desc)
|
||||
local bLimit = self.mapData.nMaximumLimit > 0
|
||||
if bLimit then
|
||||
local nLeft = self.mapData.nMaximumLimit - self.mapData.nBoughtCount
|
||||
NovaAPI.SetTMPText(self._mapNode.txtStock, orderedFormat(ConfigTable.GetUIText("Shop_Stock"), nLeft))
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtStock, nLeft == 0 and Red_Unable or Blue_Dark)
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtStock, ConfigTable.GetUIText("Shop_Unlimited"))
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtStock, Blue_Dark)
|
||||
end
|
||||
self._mapNode.btnDetail.interactable = mapCfg and (mapCfg.Stype == GameEnum.itemStype.Disc or mapCfg.Stype == GameEnum.itemStype.Char or mapCfg.Stype == GameEnum.itemStype.RandomPackage or mapCfg.Stype == GameEnum.itemStype.ComCYO or mapCfg.Stype == GameEnum.itemStype.OutfitCYO)
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:RefreshPrice()
|
||||
for i = 1, 2 do
|
||||
self:SetSprite_Coin(self._mapNode.imgCoin[i], self.nCurrencyItemId)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPrice, self.mapGoodsCfg.Price)
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:RefreshBuyCount()
|
||||
local nCost = self.nBuyCount * self.mapGoodsCfg.Price
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCoinCount, nCost)
|
||||
local nHasCoin = PlayerData.Item:GetItemCountByID(self.nCurrencyItemId)
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtCoinCount, nCost > nHasCoin and Red_Unable or Blue_Normal)
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:RefreshBuyState()
|
||||
self._mapNode.btnBuy.gameObject:SetActive(self.bAble)
|
||||
self._mapNode.btnBuy2.gameObject:SetActive(not self.bAble)
|
||||
self._mapNode.txtDisable.gameObject:SetActive(not self.mapData.bPurchasable or self.mapData.bSoldOut)
|
||||
self.nBuyCount = self.bAble and 1 or 0
|
||||
local nMax = self:CountMaxBuy()
|
||||
local callback = function(nCount)
|
||||
self.nBuyCount = nCount
|
||||
self:RefreshBuyCount()
|
||||
end
|
||||
self._mapNode.goQuantitySelector:Init(callback, self.nBuyCount, nMax)
|
||||
if self.mapData.bSoldOut then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDisable, ConfigTable.GetUIText("Shop_Cond_SoldOutShort"))
|
||||
elseif not self.mapData.bPurchasable then
|
||||
if self.mapData.nPurchaseCondType == GameEnum.shopCond.WorldClassSpecific then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDisable, orderedFormat(ConfigTable.GetUIText("Shop_Cond_WorldClassShort"), self.mapData.tbPurchaseCondParams[1]))
|
||||
elseif self.mapData.nPurchaseCondType == GameEnum.shopCond.ShopPreGoodsSellOut or self.mapData.nPurchaseCondType == GameEnum.shopCond.ActivityShopPreGoodsSellOut then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDisable, ConfigTable.GetUIText("Shop_Cond_PreGoodsSellOut"))
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:CountMaxBuy()
|
||||
local nHasCoin = PlayerData.Item:GetItemCountByID(self.nCurrencyItemId)
|
||||
local nMax = math.floor(nHasCoin / self.mapGoodsCfg.Price)
|
||||
if nMax == 0 then
|
||||
return 1
|
||||
end
|
||||
if 0 < self.mapData.nMaximumLimit then
|
||||
local nRemain = self.mapData.nMaximumLimit - self.mapData.nBoughtCount
|
||||
return nMax > nRemain and nRemain or nMax
|
||||
else
|
||||
return nMax
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnEnable()
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnDisable()
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnDestroy()
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnBtnClick_Buy()
|
||||
local nCost = self.nBuyCount * self.mapGoodsCfg.Price
|
||||
local nHasCoin = PlayerData.Item:GetItemCountByID(self.nCurrencyItemId)
|
||||
local sName = ConfigTable.GetData_Item(self.nCurrencyItemId).Title
|
||||
if nCost > nHasCoin then
|
||||
EventManager.Hit(EventId.OpenMessageBox, orderedFormat(ConfigTable.GetUIText("Shop_NotEnough"), sName))
|
||||
return
|
||||
end
|
||||
local buy = function()
|
||||
local callback = function()
|
||||
EventManager.Hit("ActivityShopRefreshGoods")
|
||||
EventManager.Hit("ActivityShopCloseDetail")
|
||||
local bLimit = self.mapData.nMaximumLimit > 0
|
||||
EventManager.Hit("ActivityShopBuyVoice", bLimit)
|
||||
end
|
||||
self.actShopData:SendActivityShopPurchaseReq(self.nShopId, self.mapData.nId, self.nBuyCount, callback)
|
||||
end
|
||||
local buy_confirm = function()
|
||||
local nAll = self.mapGoodsCfg.ItemQuantity * self.nBuyCount
|
||||
local sTip = 1 < nAll and orderedFormat(ConfigTable.GetUIText("Shop_MultiBuyComfirm"), nCost, sName, nAll, self.mapGoodsCfg.Name) or orderedFormat(ConfigTable.GetUIText("Shop_BuyComfirm"), nCost, sName, self.mapGoodsCfg.Name)
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = sTip,
|
||||
callbackConfirm = buy,
|
||||
bBlur = false
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
local nItemId = self.mapGoodsCfg.ItemId
|
||||
local mapCfg = ConfigTable.GetData_Item(nItemId)
|
||||
local sTip
|
||||
if mapCfg then
|
||||
if mapCfg.Type == GameEnum.itemType.Disc then
|
||||
sTip = PlayerData.Item:GetDiscHoldingState(nItemId, self.nBuyCount)
|
||||
elseif mapCfg.Type == GameEnum.itemType.Char then
|
||||
sTip = PlayerData.Item:GetCharHoldingState(nItemId, self.nBuyCount)
|
||||
elseif mapCfg.Stype == GameEnum.itemStype.CharShard then
|
||||
local nCharId = PlayerData.Talent:GetFragmentsToChar(nItemId)
|
||||
sTip = PlayerData.Item:GetCharHoldingState(nCharId, 0, self.nBuyCount)
|
||||
end
|
||||
end
|
||||
if sTip then
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = sTip,
|
||||
callbackConfirm = buy_confirm,
|
||||
bBlur = false
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
else
|
||||
buy_confirm()
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnBtnClick_Close()
|
||||
EventManager.Hit("ActivityShopCloseDetail")
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnBtnClick_Detail()
|
||||
local nItemId = self.mapGoodsCfg.ItemId
|
||||
local mapCfg = ConfigTable.GetData_Item(nItemId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
if mapCfg.Stype == GameEnum.itemStype.Disc then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DiscSample, nItemId)
|
||||
elseif mapCfg.Stype == GameEnum.itemStype.Char then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgTrialPanel, PanelId.CharInfoTrial, nItemId)
|
||||
elseif mapCfg.Stype == GameEnum.itemStype.RandomPackage or mapCfg.Stype == GameEnum.itemStype.ComCYO then
|
||||
local tbDetailItem, sDetailTitle = PlayerData.Item:GetCYODisplayItem(nItemId)
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.ItemList,
|
||||
tbItem = tbDetailItem,
|
||||
sTitle = sDetailTitle,
|
||||
bBlur = false
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
elseif mapCfg.Stype == GameEnum.itemStype.OutfitCYO then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DiscPreview, nItemId)
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsDetailCtrl:OnBtnClick_Disable()
|
||||
if self.mapData.bSoldOut then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Shop_GoodsEmpty"))
|
||||
elseif not self.mapData.bPurchasable then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Shop_Condition"))
|
||||
elseif not self.mapData.bPurchasTime then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Shop_NotPurchasTime"))
|
||||
end
|
||||
end
|
||||
return ActivityShopGoodsDetailCtrl
|
||||
@@ -0,0 +1,125 @@
|
||||
local ActivityShopGoodsItemCtrl = class("ActivityShopGoodsItemCtrl", BaseCtrl)
|
||||
ActivityShopGoodsItemCtrl._mapNodeConfig = {
|
||||
imgRare = {sComponentName = "Image"},
|
||||
imgLeft = {},
|
||||
txtLeft = {sComponentName = "TMP_Text"},
|
||||
imgTime = {},
|
||||
txtLeftTime = {sComponentName = "TMP_Text"},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
imgIcon = {sComponentName = "Image"},
|
||||
imgElement = {sComponentName = "Image"},
|
||||
imgExpire = {sComponentName = "Image"},
|
||||
txtCount = {sComponentName = "TMP_Text"},
|
||||
imgCoin = {sComponentName = "Image"},
|
||||
txtPrice = {sComponentName = "TMP_Text"},
|
||||
imgMask = {},
|
||||
goRestock = {},
|
||||
txtRestock = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Mall_Package_SoldOut"
|
||||
},
|
||||
goCondition = {},
|
||||
txtCondition = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
ActivityShopGoodsItemCtrl._mapEventConfig = {}
|
||||
function ActivityShopGoodsItemCtrl:Refresh(mapData, nCurrencyItemId)
|
||||
self.mapData = mapData
|
||||
self.mapGoodsCfg = ConfigTable.GetData("ActivityGoods", mapData.nId)
|
||||
if not self.mapGoodsCfg then
|
||||
return
|
||||
end
|
||||
self:RefreshInfo()
|
||||
self:RefreshPrice(nCurrencyItemId)
|
||||
self:RefreshTime()
|
||||
self:RefreshLimit()
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:RefreshInfo()
|
||||
local mapItemCfg = ConfigTable.GetData_Item(self.mapGoodsCfg.ItemId)
|
||||
if not mapItemCfg then
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, self.mapGoodsCfg.Name)
|
||||
if mapItemCfg.Type == GameEnum.itemType.Disc then
|
||||
self:SetPngSprite(self._mapNode.imgIcon, mapItemCfg.Icon .. AllEnum.OutfitIconSurfix.Item)
|
||||
self._mapNode.imgElement.gameObject:SetActive(true)
|
||||
local mapDiscCfgData = ConfigTable.GetData("Disc", self.mapGoodsCfg.ItemId)
|
||||
self:SetAtlasSprite(self._mapNode.imgElement, "12_rare", AllEnum.Star_Element[mapDiscCfgData.EET].icon)
|
||||
else
|
||||
self:SetPngSprite(self._mapNode.imgIcon, mapItemCfg.Icon)
|
||||
self._mapNode.imgElement.gameObject:SetActive(false)
|
||||
end
|
||||
self._mapNode.imgExpire.gameObject:SetActive(mapItemCfg.ExpireType > 0)
|
||||
local sPath = "db_swimsuit_shop_" .. AllEnum.FrameColor_New[mapItemCfg.Rarity]
|
||||
self:SetActivityAtlasSprite(self._mapNode.imgRare, "Swim", sPath)
|
||||
local bLimit = 0 < self.mapData.nMaximumLimit
|
||||
if bLimit then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLeft, orderedFormat(ConfigTable.GetUIText("Shop_Left"), self.mapData.nMaximumLimit - self.mapData.nBoughtCount))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLeft, orderedFormat(ConfigTable.GetUIText("Shop_Left"), ConfigTable.GetUIText("Shop_Unlimited")))
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCount, orderedFormat(ConfigTable.GetUIText("Shop_GoodsItem_Count"), self.mapGoodsCfg.ItemQuantity))
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:RefreshPrice(nCurrencyItemId)
|
||||
self:SetSprite_Coin(self._mapNode.imgCoin, nCurrencyItemId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPrice, self.mapGoodsCfg.Price)
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:RefreshTime()
|
||||
local bTime = self.mapData.bPurchasTime and self.mapData.nNextRefreshTime > 0
|
||||
self._mapNode.imgTime:SetActive(bTime)
|
||||
if not bTime then
|
||||
return
|
||||
end
|
||||
local sTime = ""
|
||||
local nRemaining = self.mapData.nNextRefreshTime - CS.ClientManager.Instance.serverTimeStamp
|
||||
if nRemaining <= 3600 and 0 < nRemaining then
|
||||
sTime = ConfigTable.GetUIText("Shop_WithinHour")
|
||||
elseif 3600 < nRemaining and nRemaining <= 86400 then
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_Hour"), math.floor(nRemaining / 3600))
|
||||
elseif 86400 < nRemaining then
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_Day"), math.floor(nRemaining / 86400))
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLeftTime, sTime)
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:RefreshLimit()
|
||||
local bMask = not self.mapData.bPurchasable or not self.mapData.bPurchasTime or self.mapData.bSoldOut
|
||||
self._mapNode.imgMask:SetActive(bMask)
|
||||
if self.mapData.bSoldOut then
|
||||
self._mapNode.goRestock:SetActive(true)
|
||||
self._mapNode.goCondition:SetActive(false)
|
||||
return
|
||||
end
|
||||
self._mapNode.goRestock:SetActive(false)
|
||||
self._mapNode.goCondition:SetActive(true)
|
||||
if self.mapData.nUnlockPurchaseTime > 0 and self.mapData.nUnlockPurchaseTime == self.mapData.nNextRefreshTime then
|
||||
local sTime = ""
|
||||
local nRemaining = self.mapData.nNextRefreshTime - CS.ClientManager.Instance.serverTimeStamp
|
||||
if nRemaining <= 3600 and 0 < nRemaining then
|
||||
sTime = ConfigTable.GetUIText("Shop_WithinHourUnLock")
|
||||
elseif 3600 < nRemaining and nRemaining <= 86400 then
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_HourUnLock"), math.floor(nRemaining / 3600))
|
||||
elseif 86400 < nRemaining then
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("Shop_DayUnLock"), math.floor(nRemaining / 86400))
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCondition, sTime)
|
||||
return
|
||||
end
|
||||
if not self.mapData.bPurchasable then
|
||||
local sCond = ""
|
||||
if self.mapData.nPurchaseCondType == GameEnum.shopCond.WorldClassSpecific then
|
||||
sCond = orderedFormat(ConfigTable.GetUIText("Shop_Cond_WorldClass"), self.mapData.tbPurchaseCondParams[1])
|
||||
elseif self.mapData.nPurchaseCondType == GameEnum.shopCond.ShopPreGoodsSellOut or self.mapData.nPurchaseCondType == GameEnum.shopCond.ActivityShopPreGoodsSellOut then
|
||||
sCond = ConfigTable.GetUIText("Shop_Cond_PreGoodsSellOut")
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCondition, sCond)
|
||||
return
|
||||
end
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:Awake()
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:OnEnable()
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:OnDisable()
|
||||
end
|
||||
function ActivityShopGoodsItemCtrl:OnDestroy()
|
||||
end
|
||||
return ActivityShopGoodsItemCtrl
|
||||
@@ -0,0 +1,24 @@
|
||||
local ActivityShopPanel = class("ActivityShopPanel", BasePanel)
|
||||
ActivityShopPanel._sUIResRootPath = "UI_Activity/"
|
||||
ActivityShopPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Swim/Shop/ActivityShopPanel.prefab",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.Shop.ActivityShopCtrl"
|
||||
}
|
||||
}
|
||||
function ActivityShopPanel:Awake()
|
||||
self.nDefaultId = nil
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.nActId = tbParam[1]
|
||||
self.nDefaultId = tbParam[2]
|
||||
end
|
||||
self.actShopData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
end
|
||||
function ActivityShopPanel:OnEnable()
|
||||
end
|
||||
function ActivityShopPanel:OnDisable()
|
||||
end
|
||||
function ActivityShopPanel:OnDestroy()
|
||||
end
|
||||
return ActivityShopPanel
|
||||
@@ -0,0 +1,64 @@
|
||||
local ActivityShopPopupCtrl = class("ActivityShopPopupCtrl", BaseCtrl)
|
||||
ActivityShopPopupCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
blur = {
|
||||
sNodeName = "t_fullscreen_blur_blue"
|
||||
},
|
||||
aniBlur = {
|
||||
sNodeName = "t_fullscreen_blur_blue",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnCloseDatail = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_CloseDetail"
|
||||
},
|
||||
Detail = {
|
||||
sNodeName = "---Detail---",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.Shop.ActivityShopGoodsDetailCtrl"
|
||||
}
|
||||
}
|
||||
ActivityShopPopupCtrl._mapEventConfig = {
|
||||
ActivityShopCloseDetail = "OnBtnClick_CloseDetail"
|
||||
}
|
||||
function ActivityShopPopupCtrl:Open()
|
||||
local mapCfg = ConfigTable.GetData("ActivityShop", self.nShopId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
self._mapNode.TopBar:CreateCoin({
|
||||
mapCfg.CurrencyItemId
|
||||
}, true)
|
||||
self._mapNode.blur:SetActive(true)
|
||||
self._mapNode.Detail:Refresh(self.mapData, self.nShopId, self.nActId)
|
||||
end
|
||||
function ActivityShopPopupCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.mapData = tbParam[1]
|
||||
self.nShopId = tbParam[2]
|
||||
self.nActId = tbParam[3]
|
||||
end
|
||||
end
|
||||
function ActivityShopPopupCtrl:OnEnable()
|
||||
self:Open()
|
||||
end
|
||||
function ActivityShopPopupCtrl:OnDisable()
|
||||
end
|
||||
function ActivityShopPopupCtrl:OnDestroy()
|
||||
end
|
||||
function ActivityShopPopupCtrl:OnBtnClick_CloseDetail()
|
||||
if self._mapNode.Detail.gameObject.activeSelf == false then
|
||||
return
|
||||
end
|
||||
self._mapNode.Detail:PlayOutAni()
|
||||
self._mapNode.aniBlur:SetTrigger("tOut")
|
||||
self:AddTimer(1, 0.2, function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.SwimShopPopup)
|
||||
end, true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
end
|
||||
return ActivityShopPopupCtrl
|
||||
@@ -0,0 +1,18 @@
|
||||
local ActivityShopPopupPanel = class("ActivityShopPopupPanel", BasePanel)
|
||||
ActivityShopPopupPanel._sUIResRootPath = "UI_Activity/"
|
||||
ActivityShopPopupPanel._bIsMainPanel = false
|
||||
ActivityShopPopupPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Swim/Shop/ActivityShopPopupPanel.prefab",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.Shop.ActivityShopPopupCtrl"
|
||||
}
|
||||
}
|
||||
function ActivityShopPopupPanel:Awake()
|
||||
end
|
||||
function ActivityShopPopupPanel:OnEnable()
|
||||
end
|
||||
function ActivityShopPopupPanel:OnDisable()
|
||||
end
|
||||
function ActivityShopPopupPanel:OnDestroy()
|
||||
end
|
||||
return ActivityShopPopupPanel
|
||||
@@ -0,0 +1,260 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local SwimThemeStoryCtrl = class("SwimThemeStoryCtrl", BaseCtrl)
|
||||
local ActivityAvgData = PlayerData.ActivityAvg
|
||||
SwimThemeStoryCtrl._mapNodeConfig = {
|
||||
goActTime = {},
|
||||
txtYear = {sComponentName = "TMP_Text"},
|
||||
txtActivityDate = {sComponentName = "TMP_Text"},
|
||||
svStory = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
imgHead = {sComponentName = "Image"},
|
||||
txtPersonality = {sComponentName = "TMP_Text"},
|
||||
ctlAvgRoot = {
|
||||
sNodeName = "goAvgInfoRoot",
|
||||
sCtrlName = "Game.UI.ActivityTheme.ActivityAvgInfoExCtrl"
|
||||
},
|
||||
t_fullscreen_blur_black = {},
|
||||
btnsnapshot = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_ClickCloseLevelInfoPanel"
|
||||
},
|
||||
goPersonalityRoot = {
|
||||
sNodeName = "---Personality---"
|
||||
},
|
||||
goPersonality = {
|
||||
sNodeName = "goPersonality",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
goChapterComplete = {}
|
||||
}
|
||||
SwimThemeStoryCtrl._mapEventConfig = {
|
||||
CloseActivityAvgInfo = "OnEvent_CloseAvgInfoRoot",
|
||||
Activity_Story_Done = "OnEvent_Activity_Story_Done",
|
||||
ActivityStory_All_Complate = "OnEvent_ActivityStory_All_Complate",
|
||||
Activity_Story_RewardClosed = "OnEvent_Activity_Story_RewardClosed"
|
||||
}
|
||||
function SwimThemeStoryCtrl:Awake()
|
||||
local param = self:GetPanelParam()
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
end
|
||||
self.tbAllStory = ActivityAvgData:GetStoryIdListByActivityId(self.nActId)
|
||||
self.storyNodePos = {27, -30}
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnEnable()
|
||||
self._mapNode.goActTime.gameObject:SetActive(false)
|
||||
self:RefreshPanel()
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnDisable()
|
||||
end
|
||||
function SwimThemeStoryCtrl:RefreshPanel()
|
||||
self:RefreshDate()
|
||||
self:RefreshStoryList()
|
||||
self:RefreshPersonality()
|
||||
end
|
||||
function SwimThemeStoryCtrl:RefreshDate()
|
||||
local nOpenTime, nEndTime = PlayerData.ActivityAvg:GetActivityOpenTime(self.nActId)
|
||||
local nYear = tonumber(os.date("%Y", nOpenTime))
|
||||
local nOpenMonth = tonumber(os.date("%m", nOpenTime))
|
||||
local nOpenDay = tonumber(os.date("%d", nOpenTime))
|
||||
local nEndDay = tonumber(os.date("%d", nEndTime))
|
||||
local nEndMonth = tonumber(os.date("%m", nEndTime))
|
||||
NovaAPI.SetTMPText(self._mapNode.txtYear, nYear)
|
||||
local strOpenDay = string.format("%02d", nOpenDay)
|
||||
local strEndDay = string.format("%02d", nEndDay)
|
||||
local dateStr = string.format("%s/%s ~ %s/%s", nOpenMonth, strOpenDay, nEndMonth, strEndDay)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActivityDate, dateStr)
|
||||
end
|
||||
function SwimThemeStoryCtrl:RefreshPersonality()
|
||||
if self.tbAllStory == nil or #self.tbAllStory <= 0 then
|
||||
return
|
||||
end
|
||||
local cfg = ConfigTable.GetData("ActivityAvgLevel", self.tbAllStory[1])
|
||||
local personalityId = cfg.PersonalityId
|
||||
self._mapNode.goPersonalityRoot:SetActive(0 < personalityId)
|
||||
if personalityId <= 0 then
|
||||
return
|
||||
end
|
||||
local tbRetPercent, sTitle, sFace, tbPData, nTotalCount, sHead = PlayerData.ActivityAvg:CalcPersonality(personalityId)
|
||||
NovaAPI.SetPersonalityRing(self._mapNode.goPersonality, tbRetPercent)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPersonality, sTitle)
|
||||
local sIcon = "Icon/PlayerHead/" .. sHead
|
||||
self:SetPngSprite(self._mapNode.imgHead, sIcon)
|
||||
end
|
||||
function SwimThemeStoryCtrl:RefreshStoryList()
|
||||
if self.tbAllStory == nil or #self.tbAllStory <= 0 then
|
||||
return
|
||||
end
|
||||
self._mapNode.svStory:SetAnim(0.07)
|
||||
self._mapNode.svStory:Init(#self.tbAllStory, self, self.OnRefreshGrid, self.OnClickGrid)
|
||||
local recentIndex = PlayerData.ActivityAvg:GetRecentAcvitityIndex(self.nActId)
|
||||
if 2 < recentIndex then
|
||||
recentIndex = recentIndex - 3
|
||||
else
|
||||
recentIndex = 0
|
||||
end
|
||||
self._mapNode.svStory:SetScrollGridPos(recentIndex, 1)
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnRefreshGrid(grid, index)
|
||||
local gridIndex = index + 1
|
||||
local storyId = self.tbAllStory[gridIndex]
|
||||
local avgCfg = ConfigTable.GetData("ActivityAvgLevel", storyId)
|
||||
local RootNode = grid.transform:Find("btnGrid/AnimRoot/RootNode"):GetComponent("RectTransform")
|
||||
local pos = RootNode.anchoredPosition
|
||||
pos.y = gridIndex % 2 == 0 and self.storyNodePos[1] or self.storyNodePos[2]
|
||||
RootNode.anchoredPosition = pos
|
||||
local goUnlock = RootNode:Find("goUnlock")
|
||||
local goComplete = RootNode:Find("goComplete")
|
||||
local goLock = RootNode:Find("goLock")
|
||||
local reddot = RootNode:Find("RedDot")
|
||||
local isTimeUnlock, isPreReaded, nOpenTime = PlayerData.ActivityAvg:IsActivityAvgUnlock(self.nActId, storyId)
|
||||
local isReaded = PlayerData.ActivityAvg:IsActivityAvgReaded(self.nActId, storyId)
|
||||
local isNew = PlayerData.ActivityAvg:IsNew(self.nActId, storyId)
|
||||
local isUnlock = isTimeUnlock and isPreReaded
|
||||
goUnlock.gameObject:SetActive(isUnlock)
|
||||
goComplete.gameObject:SetActive(isReaded)
|
||||
goLock.gameObject:SetActive(not isUnlock)
|
||||
local bInActGroup, nActGroupId = PlayerData.Activity:IsActivityInActivityGroup(self.nActId)
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_GroupNew_Avg_Group, {
|
||||
nActGroupId,
|
||||
self.nActId,
|
||||
storyId
|
||||
}, reddot, nil, nil, true)
|
||||
local imgStory = RootNode:Find("imgStory"):GetComponent("Image")
|
||||
local txtIndex = goUnlock:Find("txtIndex"):GetComponent("TMP_Text")
|
||||
local txtTitle = goUnlock:Find("txtTitle"):GetComponent("TMP_Text")
|
||||
local txtComplete = goComplete:Find("imgBg/txtComplete"):GetComponent("TMP_Text")
|
||||
local sFullPath = Settings.AB_ROOT_PATH .. avgCfg.IconRes .. ".png"
|
||||
NovaAPI.SetImageSprite(imgStory, sFullPath)
|
||||
NovaAPI.SetTMPText(txtIndex, avgCfg.Index)
|
||||
NovaAPI.SetTMPText(txtTitle, avgCfg.Name)
|
||||
if isReaded then
|
||||
NovaAPI.SetTMPText(txtComplete, ConfigTable.GetUIText("RoguelikeBuild_Manage_FilterPass"))
|
||||
end
|
||||
if not isUnlock then
|
||||
local goLockBg = goLock:Find("goLockBg")
|
||||
local goTime = goLock:Find("imgTime")
|
||||
local txtTime = goLock:Find("imgTime/txtTime"):GetComponent("TMP_Text")
|
||||
local goLockState = goLock:Find("goLockState")
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = curTime - (nOpenTime + avgCfg.DayOpen * 86400)
|
||||
local blueMask = goLockState:Find("blueMask")
|
||||
if remainTime < 0 then
|
||||
goLockBg.gameObject:SetActive(true)
|
||||
goTime.gameObject:SetActive(true)
|
||||
local bPreTimeUnlock = true
|
||||
if avgCfg.PreLevelId ~= 0 then
|
||||
bPreTimeUnlock = PlayerData.ActivityAvg:IsActivityAvgUnlock(self.nActId, avgCfg.PreLevelId)
|
||||
end
|
||||
if not bPreTimeUnlock then
|
||||
goTime.gameObject:SetActive(false)
|
||||
goLockState.gameObject:SetActive(true)
|
||||
blueMask.gameObject:SetActive(false)
|
||||
else
|
||||
goLockState.gameObject:SetActive(false)
|
||||
local strTime = self:GetRemainTimeStr(nOpenTime, avgCfg.DayOpen)
|
||||
self:AddTimer(0, 1, function()
|
||||
local strTime, bLock = self:GetRemainTimeStr(nOpenTime, avgCfg.DayOpen)
|
||||
if bLock then
|
||||
NovaAPI.SetTMPText(txtTime, strTime)
|
||||
else
|
||||
self:RefreshStoryList()
|
||||
end
|
||||
end, true, true, true)
|
||||
NovaAPI.SetTMPText(txtTime, strTime)
|
||||
end
|
||||
else
|
||||
goLockBg.gameObject:SetActive(false)
|
||||
goTime.gameObject:SetActive(false)
|
||||
goLockState.gameObject:SetActive(true)
|
||||
blueMask.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnClickGrid(grid, index)
|
||||
local gridIndex = index + 1
|
||||
local storyId = self.tbAllStory[gridIndex]
|
||||
local isTimeUnlock, isPreReaded, nOpenTime = PlayerData.ActivityAvg:IsActivityAvgUnlock(self.nActId, storyId)
|
||||
local isUnlock = isTimeUnlock and isPreReaded
|
||||
local avgcfg = ConfigTable.GetData("ActivityAvgLevel", storyId)
|
||||
if not isUnlock then
|
||||
if isTimeUnlock and not isPreReaded then
|
||||
local cfg = ConfigTable.GetData("ActivityAvgLevel", avgcfg.PreLevelId)
|
||||
local lockTxt = orderedFormat(ConfigTable.GetUIText("Story_UnlockPreId") or "", cfg.Name)
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = lockTxt
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
elseif not isTimeUnlock then
|
||||
local remainTimeStr = self:GetRemainTimeStr(nOpenTime, avgcfg.DayOpen)
|
||||
EventManager.Hit(EventId.OpenMessageBox, remainTimeStr)
|
||||
end
|
||||
return
|
||||
end
|
||||
self._mapNode.ctlAvgRoot.gameObject:SetActive(true)
|
||||
self._mapNode.ctlAvgRoot:OpenLevelInfo(storyId, self.nActId)
|
||||
self._mapNode.t_fullscreen_blur_black:SetActive(true)
|
||||
LocalData.SetPlayerLocalData("Act_Story_New" .. self.nActId .. storyId, true)
|
||||
PlayerData.ActivityAvg:RefreshAvgRedDot()
|
||||
end
|
||||
function SwimThemeStoryCtrl: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 SwimThemeStoryCtrl:OnBtn_ClickBack()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.SwimThemeStory)
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnBtn_ClickHome()
|
||||
PanelManager.Home()
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnBtn_ClickCloseLevelInfoPanel()
|
||||
self._mapNode.t_fullscreen_blur_black:SetActive(false)
|
||||
self._mapNode.ctlAvgRoot.gameObject:SetActive(false)
|
||||
self._mapNode.goChapterComplete:SetActive(false)
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnEvent_CloseAvgInfoRoot()
|
||||
self._mapNode.t_fullscreen_blur_black:SetActive(false)
|
||||
self._mapNode.ctlAvgRoot.gameObject:SetActive(false)
|
||||
self._mapNode.goChapterComplete:SetActive(false)
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnEvent_Activity_Story_Done()
|
||||
self._mapNode.t_fullscreen_blur_black:SetActive(false)
|
||||
self._mapNode.ctlAvgRoot.gameObject:SetActive(false)
|
||||
self._mapNode.goChapterComplete:SetActive(false)
|
||||
self:RefreshPanel()
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnEvent_ActivityStory_All_Complate()
|
||||
self.bAllComplate = true
|
||||
end
|
||||
function SwimThemeStoryCtrl:OnEvent_Activity_Story_RewardClosed()
|
||||
if self.bAllComplate then
|
||||
self._mapNode.t_fullscreen_blur_black:SetActive(true)
|
||||
self._mapNode.goChapterComplete:SetActive(true)
|
||||
self.bAllComplate = false
|
||||
end
|
||||
end
|
||||
return SwimThemeStoryCtrl
|
||||
@@ -0,0 +1,20 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local SwimThemeStoryPanel = class("SwimThemeStoryPanel", BasePanel)
|
||||
SwimThemeStoryPanel._sUIResRootPath = "UI_Activity/"
|
||||
SwimThemeStoryPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Swim/Story/SwimThemeStoryPanel.prefab",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.Story.SwimThemeStoryCtrl"
|
||||
}
|
||||
}
|
||||
function SwimThemeStoryPanel:Awake()
|
||||
end
|
||||
function SwimThemeStoryPanel:OnEnable()
|
||||
end
|
||||
function SwimThemeStoryPanel:OnDisable()
|
||||
end
|
||||
function SwimThemeStoryPanel:OnDestroy()
|
||||
end
|
||||
function SwimThemeStoryPanel:OnRelease()
|
||||
end
|
||||
return SwimThemeStoryPanel
|
||||
@@ -0,0 +1,761 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local SwimThemeCtrl = class("SwimThemeCtrl", BaseCtrl)
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
SwimThemeCtrl._mapNodeConfig = {
|
||||
btnEntrance_ = {
|
||||
nCount = 5,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickActivityEntrance"
|
||||
},
|
||||
imgActivityTime = {},
|
||||
txtActivityTime = {sComponentName = "TMP_Text"},
|
||||
txtActivityDate = {sComponentName = "TMP_Text"},
|
||||
imgEnd = {},
|
||||
txtActivityEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
imgMiniGame = {sComponentName = "Image"},
|
||||
txtMiniGame = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Mini_Game"
|
||||
},
|
||||
imgMiniGameEnd = {},
|
||||
txtMiniGameEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Mini_Game"
|
||||
},
|
||||
txtMiniGame_End = {},
|
||||
txtTask = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Task"
|
||||
},
|
||||
txtTaskProgress = {sComponentName = "TMP_Text"},
|
||||
imgTaskActivityTime = {},
|
||||
txtTaskActivityTime = {sComponentName = "TMP_Text"},
|
||||
txtStory = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Story"
|
||||
},
|
||||
imgStory = {sComponentName = "Image"},
|
||||
imgStoryIcon = {sComponentName = "Image"},
|
||||
imgStoryEnd = {},
|
||||
goStoryEnd = {},
|
||||
txtStory_End = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Story"
|
||||
},
|
||||
imgStoryIconEnd = {},
|
||||
txtStoryEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
txtMiniGameEndState = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
txtTaskEndState = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
txtShopEndState = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
txtShop = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Shop"
|
||||
},
|
||||
imgShopActivityTime = {},
|
||||
txtShopActivityTime = {sComponentName = "TMP_Text"},
|
||||
imgLevel = {sComponentName = "Image"},
|
||||
txtLevel = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Level"
|
||||
},
|
||||
goLevelEnd = {},
|
||||
txtLevelEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_End"
|
||||
},
|
||||
imgLevelActivityUnlockTime = {},
|
||||
txtLevelActivityUnlockTime = {sComponentName = "TMP_Text"},
|
||||
txtLevel_End = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Level"
|
||||
},
|
||||
imgLevelEnd = {},
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
imgMiniGameActivityUnlockTime = {},
|
||||
txtMiniGameActivityUnlockTime = {sComponentName = "TMP_Text"},
|
||||
imgTaskBgEnd = {},
|
||||
imgTaskEnd = {},
|
||||
txtTaskEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Task"
|
||||
},
|
||||
txtTaskProgress_End = {},
|
||||
imgTaskActivityUnlockTime = {},
|
||||
txtTaskActivityUnlockTime = {sComponentName = "TMP_Text"},
|
||||
imgStoryActivityTime = {},
|
||||
txtStoryActivityTime = {sComponentName = "TMP_Text"},
|
||||
imgStoryActivityUnlockTime = {},
|
||||
txtStoyActivityUnlockTime = {sComponentName = "TMP_Text"},
|
||||
imgShopActivityUnlockTime = {},
|
||||
txtShopActivityUnlockTime = {sComponentName = "TMP_Text"},
|
||||
imgLevelActivityTime = {},
|
||||
txtLevelActivityTime = {sComponentName = "TMP_Text"},
|
||||
imgMiniGameActivityTime = {},
|
||||
txtMiniGameActivityTime = {sComponentName = "TMP_Text"},
|
||||
txtShopEnd = {},
|
||||
imgShopEnd = {},
|
||||
txtShop_End = {},
|
||||
txtTaskProgressEnd = {sComponentName = "TMP_Text"},
|
||||
redDotEntrance2 = {},
|
||||
storyRedDot = {},
|
||||
reddotLevel = {}
|
||||
}
|
||||
SwimThemeCtrl._mapEventConfig = {}
|
||||
SwimThemeCtrl._mapRedDotConfig = {}
|
||||
local ActivityState = {
|
||||
NotOpen = 1,
|
||||
Open = 2,
|
||||
Closed = 3
|
||||
}
|
||||
function SwimThemeCtrl:Awake()
|
||||
local param = self:GetPanelParam()
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
end
|
||||
self.SwimThemeData = PlayerData.Activity:GetActivityGroupDataById(self.nActId)
|
||||
if self.SwimThemeData ~= nil then
|
||||
self.ActivityGroupCfg = self.SwimThemeData.actGroupConfig
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:FadeIn()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
end
|
||||
function SwimThemeCtrl:OnEnable()
|
||||
self:RefreshPanel()
|
||||
for i = 1, 5 do
|
||||
local actData = self.SwimThemeData:GetActivityDataByIndex(i)
|
||||
if i == AllEnum.ActivityThemeFuncIndex.Task then
|
||||
local nActId = actData.ActivityId
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_Group_Task, {
|
||||
self.nActId,
|
||||
nActId
|
||||
}, self._mapNode.redDotEntrance2)
|
||||
elseif i == AllEnum.ActivityThemeFuncIndex.Story then
|
||||
local nActId = actData.ActivityId
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_GroupNew_Avg, {
|
||||
self.nActId,
|
||||
nActId
|
||||
}, self._mapNode.storyRedDot)
|
||||
elseif i == AllEnum.ActivityThemeFuncIndex.Level then
|
||||
local nActId = actData.ActivityId
|
||||
RedDotManager.RegisterNode(RedDotDefine.ActivityLevel, {
|
||||
self.nActId,
|
||||
nActId
|
||||
}, self._mapNode.reddotLevel)
|
||||
end
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:OnDisable()
|
||||
if nil ~= self.minigameRemainTimer then
|
||||
TimerManager.Remove(self.minigameRemainTimer)
|
||||
self.minigameRemainTimer = nil
|
||||
end
|
||||
if nil ~= self.remainTimer then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
end
|
||||
if nil ~= self.shopRemainTimer then
|
||||
TimerManager.Remove(self.shopRemainTimer)
|
||||
self.shopRemainTimer = nil
|
||||
end
|
||||
if nil ~= self.levelRemainTimer then
|
||||
TimerManager.Remove(self.levelRemainTimer)
|
||||
self.levelRemainTimer = nil
|
||||
end
|
||||
if nil ~= self.avgRemainTimer then
|
||||
TimerManager.Remove(self.avgRemainTimer)
|
||||
self.avgRemainTimer = nil
|
||||
end
|
||||
if nil ~= self.taskRemainTimer then
|
||||
TimerManager.Remove(self.taskRemainTimer)
|
||||
self.taskRemainTimer = nil
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RefreshPanel()
|
||||
if self.SwimThemeData == nil or self.ActivityGroupCfg == nil then
|
||||
return
|
||||
end
|
||||
self:RefreshTime()
|
||||
self:RefreshButtonState()
|
||||
end
|
||||
function SwimThemeCtrl:RefreshTime()
|
||||
local bOpen = self.SwimThemeData:CheckActivityGroupOpen()
|
||||
if bOpen then
|
||||
self:RefreshRemainTime(self.SwimThemeData:GetActGroupEndTime(), self._mapNode.txtActivityTime)
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, function()
|
||||
local remainTime = self:RefreshRemainTime(self.SwimThemeData:GetActGroupEndTime(), self._mapNode.txtActivityTime)
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
end
|
||||
self._mapNode.imgActivityTime:SetActive(bOpen)
|
||||
self._mapNode.imgEnd:SetActive(not bOpen)
|
||||
local nOpenMonth, nOpenDay, nEndMonth, nEndDay, nOpenYear, nEndYear = self.SwimThemeData:GetActGroupDate()
|
||||
local strOpenDay = string.format("%02d", nOpenDay)
|
||||
local strEndDay = string.format("%02d", nEndDay)
|
||||
local dateStr = string.format("%s/%s/%s ~ %s/%s/%s", nOpenYear, nOpenMonth, strOpenDay, nEndYear, nEndMonth, strEndDay)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActivityDate, dateStr)
|
||||
end
|
||||
function SwimThemeCtrl:RefreshRemainTime(endTime, txtComp)
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
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 = 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 = 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 = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(txtComp, sTimeStr)
|
||||
return remainTime
|
||||
end
|
||||
function SwimThemeCtrl:RefreshRemainOpenTime(openTime)
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = openTime - curTime
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Open_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Open_Time_Min") or "", min)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Open_Time") or "", hour)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Open_Time_Day") or "", day)
|
||||
end
|
||||
return sTimeStr
|
||||
end
|
||||
function SwimThemeCtrl:RefreshButtonState()
|
||||
self.tbActState = {}
|
||||
for i = 1, 5 do
|
||||
local actData = self.SwimThemeData:GetActivityDataByIndex(i)
|
||||
if i == AllEnum.ActivityThemeFuncIndex.MiniGame then
|
||||
self:RefreshMiniGameButtonState(actData)
|
||||
elseif i == AllEnum.ActivityThemeFuncIndex.Task then
|
||||
self:RefreshTaskButtonState(actData)
|
||||
elseif i == AllEnum.ActivityThemeFuncIndex.Story then
|
||||
self:RefreshStoryButtonState(actData)
|
||||
elseif i == AllEnum.ActivityThemeFuncIndex.Level then
|
||||
self:RefreshLevelButtonState(actData)
|
||||
elseif i == AllEnum.ActivityThemeFuncIndex.Shop then
|
||||
self:RefreshShopButtonState(actData)
|
||||
end
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RefreshMiniGameButtonState(actData)
|
||||
local activityId = actData.ActivityId
|
||||
local activityData = ConfigTable.GetData("Activity", activityId)
|
||||
if activityData ~= nil then
|
||||
local state = ActivityState.NotOpen
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local bShowCountDown = false
|
||||
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 = ActivityState.NotOpen
|
||||
elseif curTime >= openTime and curTime <= endTime then
|
||||
state = ActivityState.Open
|
||||
else
|
||||
state = ActivityState.Closed
|
||||
end
|
||||
elseif activityData.EndType == GameEnum.activityEndType.NoLimit then
|
||||
state = ActivityState.Open
|
||||
if activityData.StartTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
if curTime < openTime then
|
||||
state = ActivityState.NotOpen
|
||||
end
|
||||
end
|
||||
end
|
||||
if state == ActivityState.NotOpen then
|
||||
if nil == self.minigameRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtMiniGameActivityUnlockTime, sTimeStr)
|
||||
self.minigameRemainTimer = self:AddTimer(0, 1, function()
|
||||
curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = openTime - curTime
|
||||
if 0 < remainTime then
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtMiniGameActivityUnlockTime, sTimeStr)
|
||||
else
|
||||
self._mapNode.imgMiniGameActivityUnlockTime:SetActive(false)
|
||||
TimerManager.Remove(self.minigameRemainTimer)
|
||||
self.minigameRemainTimer = nil
|
||||
self.tbActState[activityId] = ActivityState.Open
|
||||
self:RefreshMiniGameButtonState(actData)
|
||||
self:RefreshActivityData()
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Open and activityData.StartTime ~= "" and activityData.EndTime ~= "" then
|
||||
local endTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.EndTime)
|
||||
if endTime > self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = curTime >= self.SwimThemeData:GetActGroupEndTime()
|
||||
elseif endTime < self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = endTime - curTime <= 259200
|
||||
end
|
||||
if nil == self.minigameRemainTimer and bShowCountDown then
|
||||
self:RefreshRemainTime(endTime, self._mapNode.txtMiniGameActivityTime)
|
||||
self.minigameRemainTimer = self:AddTimer(0, 1, function()
|
||||
local remainTime = self:RefreshRemainTime(endTime, self._mapNode.txtMiniGameActivityTime)
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.minigameRemainTimer)
|
||||
self.minigameRemainTimer = nil
|
||||
self:RefreshMiniGameButtonState(actData)
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
end
|
||||
self._mapNode.imgMiniGameActivityUnlockTime:SetActive(state == ActivityState.NotOpen)
|
||||
self._mapNode.imgMiniGameActivityTime.gameObject:SetActive(state == ActivityState.Open and bShowCountDown)
|
||||
self._mapNode.imgMiniGameEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtMiniGame_End:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtMiniGameEnd.gameObject:SetActive(state == ActivityState.Closed)
|
||||
self.tbActState[activityId] = state
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RefreshTaskButtonState(actData)
|
||||
local activityId = actData.ActivityId
|
||||
local actInsData = PlayerData.Activity:GetActivityDataById(activityId)
|
||||
local activityData = ConfigTable.GetData("Activity", activityId)
|
||||
if activityData ~= nil then
|
||||
local bShowCountDown = false
|
||||
local state = ActivityState.NotOpen
|
||||
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 = ActivityState.NotOpen
|
||||
elseif curTime >= openTime and curTime <= endTime then
|
||||
state = ActivityState.Open
|
||||
else
|
||||
state = ActivityState.Closed
|
||||
if actInsData ~= nil then
|
||||
actInsData:RefreshTaskRedDot()
|
||||
end
|
||||
end
|
||||
if endTime > self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = curTime >= self.SwimThemeData:GetActGroupEndTime()
|
||||
elseif endTime < self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = endTime - curTime <= 259200
|
||||
end
|
||||
elseif activityData.EndType == GameEnum.activityEndType.NoLimit then
|
||||
state = ActivityState.Open
|
||||
if activityData.StartTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
if curTime < openTime then
|
||||
state = ActivityState.NotOpen
|
||||
end
|
||||
end
|
||||
end
|
||||
if state == ActivityState.NotOpen then
|
||||
if nil == self.taskRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTaskActivityUnlockTime, sTimeStr)
|
||||
self.taskRemainTimer = self:AddTimer(0, 1, function()
|
||||
curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = openTime - curTime
|
||||
if 0 < remainTime then
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTaskActivityUnlockTime, sTimeStr)
|
||||
else
|
||||
self._mapNode.imgTaskActivityUnlockTime:SetActive(false)
|
||||
TimerManager.Remove(self.taskRemainTimer)
|
||||
self.taskRemainTimer = nil
|
||||
self.tbActState[activityId] = ActivityState.Open
|
||||
self:RefreshTaskButtonState(actData)
|
||||
self:RefreshActivityData()
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Open and nil == self.taskRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" and bShowCountDown then
|
||||
local endTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.EndTime)
|
||||
self:RefreshRemainTime(endTime, self._mapNode.txtTaskActivityTime)
|
||||
self.taskRemainTimer = self:AddTimer(0, 1, function()
|
||||
local remainTime = self:RefreshRemainTime(endTime, self._mapNode.txtTaskActivityTime)
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.taskRemainTimer)
|
||||
self.taskRemainTimer = nil
|
||||
if actInsData ~= nil then
|
||||
actInsData:RefreshTaskRedDot()
|
||||
end
|
||||
self:RefreshTaskButtonState(actData)
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
self._mapNode.imgTaskActivityTime:SetActive(state == ActivityState.Open and bShowCountDown)
|
||||
self._mapNode.txtTaskProgress_End:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtTaskProgressEnd.gameObject:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.imgTaskBgEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.imgTaskEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtTaskEnd.gameObject:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.imgTaskActivityUnlockTime:SetActive(state == ActivityState.NotOpen)
|
||||
self._mapNode.txtTaskProgress.gameObject:SetActive(state >= ActivityState.Open)
|
||||
self.tbActState[activityId] = state
|
||||
local ActivityTaskData = PlayerData.Activity:GetActivityDataById(activityId)
|
||||
local nDone, nTotal = 0, 0
|
||||
if ActivityTaskData ~= nil then
|
||||
nDone, nTotal = ActivityTaskData:CalcTotalProgress()
|
||||
end
|
||||
local progress = string.format("%d/%d", nDone, nTotal)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTaskProgress, progress)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTaskProgressEnd, progress)
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RefreshStoryButtonState(actData)
|
||||
local activityId = actData.ActivityId
|
||||
local activityData = ConfigTable.GetData("Activity", activityId)
|
||||
if activityData ~= nil then
|
||||
local bShowCountDown = false
|
||||
local state = ActivityState.NotOpen
|
||||
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 = ActivityState.NotOpen
|
||||
elseif curTime >= openTime and curTime <= endTime then
|
||||
state = ActivityState.Open
|
||||
else
|
||||
state = ActivityState.Closed
|
||||
end
|
||||
if endTime > self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = curTime >= self.SwimThemeData:GetActGroupEndTime()
|
||||
elseif endTime < self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = endTime - curTime <= 259200
|
||||
end
|
||||
elseif activityData.EndType == GameEnum.activityEndType.NoLimit then
|
||||
state = ActivityState.Open
|
||||
if activityData.StartTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
if curTime < openTime then
|
||||
state = ActivityState.NotOpen
|
||||
end
|
||||
end
|
||||
end
|
||||
if state == ActivityState.NotOpen then
|
||||
if nil == self.avgRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtStoyActivityUnlockTime, sTimeStr)
|
||||
self.avgRemainTimer = self:AddTimer(0, 1, function()
|
||||
curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = openTime - curTime
|
||||
if 0 < remainTime then
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtStoyActivityUnlockTime, sTimeStr)
|
||||
else
|
||||
self._mapNode.imgStoryActivityUnlockTime:SetActive(false)
|
||||
TimerManager.Remove(self.avgRemainTimer)
|
||||
self.avgRemainTimer = nil
|
||||
self.tbActState[activityId] = ActivityState.Open
|
||||
self:RefreshStoryButtonState(actData)
|
||||
self:RefreshActivityData()
|
||||
PlayerData.ActivityAvg:RefreshAvgRedDot()
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Open then
|
||||
if nil == self.avgRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" and bShowCountDown then
|
||||
local endTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.EndTime)
|
||||
self:RefreshRemainTime(endTime, self._mapNode.txtStoryActivityTime)
|
||||
self.avgRemainTimer = self:AddTimer(0, 1, function()
|
||||
local remainTime = self:RefreshRemainTime(endTime, self._mapNode.txtStoryActivityTime)
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.avgRemainTimer)
|
||||
self.avgRemainTimer = nil
|
||||
self:RefreshStoryButtonState(actData)
|
||||
PlayerData.ActivityAvg:RefreshAvgRedDot()
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Closed then
|
||||
PlayerData.ActivityAvg:RefreshAvgRedDot()
|
||||
end
|
||||
self._mapNode.imgStoryEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.imgStoryIconEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtStory_End.gameObject:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.goStoryEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.imgStoryActivityTime:SetActive(state == ActivityState.Open and bShowCountDown)
|
||||
self._mapNode.imgStoryActivityUnlockTime:SetActive(state == ActivityState.NotOpen)
|
||||
self.tbActState[activityId] = state
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RefreshLevelButtonState(actData)
|
||||
local activityId = actData.ActivityId
|
||||
local activityData = ConfigTable.GetData("Activity", activityId)
|
||||
if activityData ~= nil then
|
||||
local bShowCountDown = false
|
||||
local state = ActivityState.NotOpen
|
||||
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 = ActivityState.NotOpen
|
||||
elseif curTime >= openTime and curTime <= endTime then
|
||||
state = ActivityState.Open
|
||||
else
|
||||
state = ActivityState.Closed
|
||||
end
|
||||
if endTime > self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = curTime >= self.SwimThemeData:GetActGroupEndTime()
|
||||
elseif endTime < self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = endTime - curTime <= 259200
|
||||
end
|
||||
elseif activityData.EndType == GameEnum.activityEndType.NoLimit then
|
||||
state = ActivityState.Open
|
||||
if activityData.StartTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
if curTime < openTime then
|
||||
state = ActivityState.NotOpen
|
||||
end
|
||||
end
|
||||
end
|
||||
if state == ActivityState.NotOpen then
|
||||
if nil == self.levelRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLevelActivityUnlockTime, sTimeStr)
|
||||
self.levelRemainTimer = self:AddTimer(0, 1, function()
|
||||
curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = openTime - curTime
|
||||
if 0 < remainTime then
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLevelActivityUnlockTime, sTimeStr)
|
||||
else
|
||||
self._mapNode.imgLevelActivityUnlockTime:SetActive(false)
|
||||
TimerManager.Remove(self.levelRemainTimer)
|
||||
self.levelRemainTimer = nil
|
||||
self.tbActState[activityId] = ActivityState.Open
|
||||
self:RefreshLevelButtonState(actData)
|
||||
self:RefreshActivityData()
|
||||
local activityLevelsData = PlayerData.Activity:GetActivityDataById(activityId)
|
||||
if nil ~= activityLevelsData then
|
||||
activityLevelsData:ChangeAllRedHot()
|
||||
end
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Open then
|
||||
if nil == self.levelRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" and bShowCountDown then
|
||||
local endTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.EndTime)
|
||||
self:RefreshRemainTime(endTime, self._mapNode.txtLevelActivityTime)
|
||||
self.levelRemainTimer = self:AddTimer(0, 1, function()
|
||||
local remainTime = self:RefreshRemainTime(endTime, self._mapNode.txtLevelActivityTime)
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.levelRemainTimer)
|
||||
self.levelRemainTimer = nil
|
||||
self:RefreshLevelButtonState(actData)
|
||||
local activityLevelsData = PlayerData.Activity:GetActivityDataById(activityId)
|
||||
if activityLevelsData ~= nil then
|
||||
activityLevelsData:ChangeAllRedHot()
|
||||
end
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Closed then
|
||||
local activityLevelsData = PlayerData.Activity:GetActivityDataById(activityId)
|
||||
if activityLevelsData ~= nil then
|
||||
activityLevelsData:ChangeAllRedHot()
|
||||
end
|
||||
end
|
||||
self._mapNode.imgLevelActivityTime:SetActive(state == ActivityState.Open and bShowCountDown)
|
||||
self._mapNode.imgLevelActivityUnlockTime:SetActive(state == ActivityState.NotOpen)
|
||||
self._mapNode.imgLevelEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtLevel_End.gameObject:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.goLevelEnd:SetActive(state == ActivityState.Closed)
|
||||
self.tbActState[activityId] = state
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RefreshShopButtonState(actData)
|
||||
local activityId = actData.ActivityId
|
||||
local activityData = ConfigTable.GetData("Activity", activityId)
|
||||
if activityData ~= nil then
|
||||
local bShowCountDown = false
|
||||
local state = ActivityState.NotOpen
|
||||
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)
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
if openTime > curTime then
|
||||
state = ActivityState.NotOpen
|
||||
elseif openTime <= curTime and endTime >= curTime then
|
||||
state = ActivityState.Open
|
||||
else
|
||||
state = ActivityState.Closed
|
||||
end
|
||||
if endTime > self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = curTime >= self.SwimThemeData:GetActGroupEndTime()
|
||||
elseif endTime < self.SwimThemeData:GetActGroupEndTime() then
|
||||
bShowCountDown = endTime - curTime <= 259200
|
||||
end
|
||||
elseif activityData.EndType == GameEnum.activityEndType.NoLimit then
|
||||
state = ActivityState.Open
|
||||
if activityData.StartTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
if curTime < openTime then
|
||||
state = ActivityState.NotOpen
|
||||
end
|
||||
end
|
||||
end
|
||||
if state == ActivityState.NotOpen then
|
||||
if nil == self.shopRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" then
|
||||
local openTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.StartTime)
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtShopActivityUnlockTime, sTimeStr)
|
||||
self.shopRemainTimer = self:AddTimer(0, 1, function()
|
||||
curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = openTime - curTime
|
||||
if 0 < remainTime then
|
||||
local sTimeStr = self:RefreshRemainOpenTime(openTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtShopActivityUnlockTime, sTimeStr)
|
||||
else
|
||||
self._mapNode.imgShopActivityUnlockTime:SetActive(false)
|
||||
TimerManager.Remove(self.shopRemainTimer)
|
||||
self.shopRemainTimer = nil
|
||||
self.tbActState[activityId] = ActivityState.Open
|
||||
self:RefreshShopButtonState(actData)
|
||||
self:RefreshActivityData()
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
elseif state == ActivityState.Open and nil == self.shopRemainTimer and activityData.StartTime ~= "" and activityData.EndTime ~= "" and bShowCountDown then
|
||||
local endTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(activityData.EndTime)
|
||||
self:RefreshRemainTime(endTime, self._mapNode.txtShopActivityTime)
|
||||
self.shopRemainTimer = self:AddTimer(0, 1, function()
|
||||
local remainTime = self:RefreshRemainTime(endTime, self._mapNode.txtShopActivityTime)
|
||||
if remainTime <= 0 then
|
||||
TimerManager.Remove(self.shopRemainTimer)
|
||||
self.shopRemainTimer = nil
|
||||
self:RefreshShopButtonState(actData)
|
||||
end
|
||||
end, true, true, false)
|
||||
end
|
||||
self._mapNode.imgShopActivityTime:SetActive(state == ActivityState.Open and bShowCountDown)
|
||||
self._mapNode.imgShopActivityUnlockTime:SetActive(state == ActivityState.NotOpen)
|
||||
self._mapNode.txtShopEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.imgShopEnd:SetActive(state == ActivityState.Closed)
|
||||
self._mapNode.txtShop_End:SetActive(state == ActivityState.Closed)
|
||||
self.tbActState[activityId] = state
|
||||
end
|
||||
end
|
||||
function SwimThemeCtrl:RequireActiviyData()
|
||||
if self.bRequiredActData then
|
||||
return
|
||||
end
|
||||
local callFunc = function(mapMsgData)
|
||||
self.bRequireSucc = true
|
||||
PlayerData.Activity:CacheAllActivityData(mapMsgData)
|
||||
self:RefreshPanel()
|
||||
end
|
||||
HttpNetHandler.SendMsg(NetMsgId.Id.activity_detail_req, {}, nil, callFunc)
|
||||
self.bRequiredActData = true
|
||||
self:AddTimer(1, 1, function()
|
||||
self.bRequiredActData = false
|
||||
end, true, true, true)
|
||||
end
|
||||
function SwimThemeCtrl:RefreshActivityData()
|
||||
if self.bRequiredActData then
|
||||
return
|
||||
end
|
||||
self:AddTimer(1, 3, self.RequireActiviyData, true, true, true)
|
||||
end
|
||||
function SwimThemeCtrl:OnBtn_ClickActivityEntrance(btn, nIndex)
|
||||
local actData = self.SwimThemeData:GetActivityDataByIndex(nIndex)
|
||||
local state = self.tbActState[actData.ActivityId]
|
||||
if nil == state then
|
||||
return
|
||||
end
|
||||
if state == ActivityState.Closed then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_End_Notice"))
|
||||
return
|
||||
elseif state == ActivityState.NotOpen then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_Not_Open"))
|
||||
return
|
||||
elseif state == ActivityState.Open then
|
||||
local activityData = PlayerData.Activity:GetActivityDataById(actData.ActivityId)
|
||||
if activityData == nil then
|
||||
local bHint = true
|
||||
if nIndex == AllEnum.ActivityThemeFuncIndex.Story then
|
||||
bHint = not PlayerData.ActivityAvg:HasActivityData(actData.ActivityId)
|
||||
end
|
||||
if self.bRequiredActData and bHint then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_Data_Refreshing"))
|
||||
return
|
||||
end
|
||||
if bHint then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_Not_Open"))
|
||||
self:RequireActiviyData()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if actData.PanelId ~= nil and ActivityState.Open == state then
|
||||
if nIndex == AllEnum.ActivityThemeFuncIndex.MiniGame then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, actData.PanelId, actData.ActivityId)
|
||||
end
|
||||
local miniGameData = PlayerData.Activity:GetActivityDataById(actData.ActivityId)
|
||||
if miniGameData ~= nil then
|
||||
miniGameData:RequestLevelData(0, callback)
|
||||
end
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, actData.PanelId, actData.ActivityId)
|
||||
end
|
||||
end
|
||||
end
|
||||
return SwimThemeCtrl
|
||||
@@ -0,0 +1,20 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local SwimThemePanel = class("SwimThemePanel", BasePanel)
|
||||
SwimThemePanel._sUIResRootPath = "UI_Activity/"
|
||||
SwimThemePanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Swim/SwimThemePanel.prefab",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.SwimThemeCtrl"
|
||||
}
|
||||
}
|
||||
function SwimThemePanel:Awake()
|
||||
end
|
||||
function SwimThemePanel:OnEnable()
|
||||
end
|
||||
function SwimThemePanel:OnDisable()
|
||||
end
|
||||
function SwimThemePanel:OnDestroy()
|
||||
end
|
||||
function SwimThemePanel:OnRelease()
|
||||
end
|
||||
return SwimThemePanel
|
||||
@@ -0,0 +1,364 @@
|
||||
local SwimTaskCtrl = class("SwimTaskCtrl", BaseCtrl)
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
local PlayerActivityData = PlayerData.Activity
|
||||
local TabType = GameEnum.ActivityTaskTabType
|
||||
local ItemType = GameEnum.itemType
|
||||
local tbTabNameUITextId = {
|
||||
[TabType.Tab1] = "Quest_Normal",
|
||||
[TabType.Tab2] = "Quest_Story",
|
||||
[TabType.Tab3] = "Quest_Challenge",
|
||||
[TabType.Tab4] = "Quest_Play",
|
||||
[TabType.Tab5] = "Quest_Active"
|
||||
}
|
||||
SwimTaskCtrl._mapNodeConfig = {
|
||||
TopBarPanel = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
svList_Tab = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
svList_Task = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
svList_GroupReward = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
imgGroupDone = {},
|
||||
tmpGroupName = {sComponentName = "TMP_Text"},
|
||||
tmpGroupProgress = {sComponentName = "TMP_Text"},
|
||||
tmpGroupUndone = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_UnComplete"
|
||||
},
|
||||
btnGroupDone = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "onBtn_GroupDone"
|
||||
},
|
||||
tb_tmpReceived = {
|
||||
nCount = 3,
|
||||
sNodeName = "tmpReceived_",
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Received"
|
||||
},
|
||||
tmpUndone = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_UnComplete"
|
||||
},
|
||||
tmpDone = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Receive"
|
||||
},
|
||||
tmpJump = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Jump"
|
||||
},
|
||||
tmpGroupDone = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Receive"
|
||||
}
|
||||
}
|
||||
SwimTaskCtrl._mapEventConfig = {
|
||||
onClick_RewardItem = "onEvent_ClickRewardItem",
|
||||
onClick_TaskDone = "onEvent_ClickTaskDone",
|
||||
onClick_TaskJump = "onEvent_ClickTaskJump"
|
||||
}
|
||||
SwimTaskCtrl._mapRedDotConfig = {}
|
||||
function SwimTaskCtrl:OnEnable()
|
||||
local tbParam = self:GetPanelParam()
|
||||
self.nActivityId = type(tbParam) == "table" and tbParam[1] or nil
|
||||
self.nCurGroupIndex = tbParam[2] or 1
|
||||
if type(self.nActivityId) ~= "number" then
|
||||
self.nActivityId = nil
|
||||
end
|
||||
self:BuildData(self.nActivityId)
|
||||
self:refresh_Tab()
|
||||
self:refresh_Task()
|
||||
self:refresh_Group()
|
||||
end
|
||||
function SwimTaskCtrl:BuildData(nActivityId)
|
||||
if self.tbData == nil then
|
||||
self.tbData = {}
|
||||
end
|
||||
if self.tbGroupId == nil then
|
||||
self.tbGroupId = {}
|
||||
end
|
||||
if self.nCurGroupIndex == nil then
|
||||
self.nCurGroupIndex = 1
|
||||
end
|
||||
if type(nActivityId) ~= "number" then
|
||||
return
|
||||
end
|
||||
self.ins_ActivityTaskData = PlayerActivityData:GetActivityDataById(nActivityId)
|
||||
if self.ins_ActivityTaskData == nil then
|
||||
return
|
||||
end
|
||||
local func_Parse_ActivityTaskGroup = function(mapData)
|
||||
if mapData.ActivityId == nActivityId then
|
||||
local _nGroupId = mapData.Id
|
||||
local nIdx = table.indexof(self.tbGroupId, _nGroupId)
|
||||
if nIdx <= 0 then
|
||||
local _mapData = {
|
||||
nGroupId = _nGroupId,
|
||||
nGroupOrder = mapData.Order,
|
||||
nTabType = mapData.TaskTabType,
|
||||
tbGroupRewardId = {},
|
||||
tbGroupRewardNum = {},
|
||||
tbTaskId = {},
|
||||
tbTaskData = {},
|
||||
nTaskDoneNum = 0,
|
||||
nTaskOKNum = 0
|
||||
}
|
||||
for i = 1, 6 do
|
||||
local nRewardId = mapData["Reward" .. tostring(i)]
|
||||
local nRewardNum = mapData["RewardQty" .. tostring(i)]
|
||||
if 0 < nRewardId and 0 < nRewardNum then
|
||||
table.insert(_mapData.tbGroupRewardId, nRewardId)
|
||||
table.insert(_mapData.tbGroupRewardNum, nRewardNum)
|
||||
end
|
||||
end
|
||||
table.insert(self.tbData, _mapData)
|
||||
table.insert(self.tbGroupId, _nGroupId)
|
||||
else
|
||||
local _mapData = self.tbData[nIdx]
|
||||
_mapData.nTaskDoneNum = 0
|
||||
_mapData.nTaskOKNum = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.ActivityTaskGroup, func_Parse_ActivityTaskGroup)
|
||||
local func_Parse_ActivityTask = function(mapData)
|
||||
local nIdx = table.indexof(self.tbGroupId, mapData.ActivityTaskGroupId)
|
||||
if 0 < nIdx then
|
||||
local _mapData = self.tbData[nIdx]
|
||||
local _tbTaskId = _mapData.tbTaskId
|
||||
local _tbTaskData = _mapData.tbTaskData
|
||||
local _nTaskId = mapData.Id
|
||||
local taskData = self.ins_ActivityTaskData.mapActivityTaskDatas[_nTaskId]
|
||||
local nIndex = table.indexof(_tbTaskId, _nTaskId)
|
||||
if nIndex <= 0 then
|
||||
local _mapTaskData = {
|
||||
nTaskId = _nTaskId,
|
||||
nStatus = taskData.nStatus,
|
||||
sDesc = mapData.Desc,
|
||||
nRarity = mapData.Rarity,
|
||||
nJumpTo = mapData.JumpTo,
|
||||
nCur = taskData.nCur,
|
||||
nMax = taskData.nMax,
|
||||
tbTaskRewardId = {},
|
||||
tbTaskRewardNum = {}
|
||||
}
|
||||
if taskData.nStatus == AllEnum.ActQuestStatus.Received then
|
||||
_mapData.nTaskDoneNum = _mapData.nTaskDoneNum + 1
|
||||
end
|
||||
if taskData.nStatus ~= AllEnum.ActQuestStatus.UnComplete then
|
||||
_mapData.nTaskOKNum = _mapData.nTaskOKNum + 1
|
||||
end
|
||||
for i = 1, 2 do
|
||||
local nRewardId = mapData["Tid" .. tostring(i)]
|
||||
local nRewardNum = mapData["Qty" .. tostring(i)]
|
||||
if 0 < nRewardId and 0 < nRewardNum then
|
||||
table.insert(_mapTaskData.tbTaskRewardId, nRewardId)
|
||||
table.insert(_mapTaskData.tbTaskRewardNum, nRewardNum)
|
||||
end
|
||||
end
|
||||
table.insert(_tbTaskId, _nTaskId)
|
||||
table.insert(_tbTaskData, _mapTaskData)
|
||||
else
|
||||
local _mapTaskData = _tbTaskData[nIndex]
|
||||
_mapTaskData.nStatus = taskData.nStatus
|
||||
_mapTaskData.nCur = taskData.nCur
|
||||
_mapTaskData.nMax = taskData.nMax
|
||||
if taskData.nStatus == AllEnum.ActQuestStatus.Received then
|
||||
_mapData.nTaskDoneNum = _mapData.nTaskDoneNum + 1
|
||||
end
|
||||
if taskData.nStatus ~= AllEnum.ActQuestStatus.UnComplete then
|
||||
_mapData.nTaskOKNum = _mapData.nTaskOKNum + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.ActivityTask, func_Parse_ActivityTask)
|
||||
table.sort(self.tbData, function(a, b)
|
||||
return a.nGroupOrder < b.nGroupOrder
|
||||
end)
|
||||
for i, v in ipairs(self.tbData) do
|
||||
self.tbGroupId[i] = v.nGroupId
|
||||
end
|
||||
for i, mapData in ipairs(self.tbData) do
|
||||
local tbTaskData = mapData.tbTaskData
|
||||
table.sort(tbTaskData, function(a, b)
|
||||
if a.nStatus == b.nStatus then
|
||||
return a.nTaskId < b.nTaskId
|
||||
else
|
||||
return a.nStatus < b.nStatus
|
||||
end
|
||||
end)
|
||||
for ii, vv in ipairs(tbTaskData) do
|
||||
mapData.tbTaskId[ii] = vv.nTaskId
|
||||
end
|
||||
end
|
||||
end
|
||||
function SwimTaskCtrl:refresh_Tab()
|
||||
self._mapNode.svList_Tab:Init(#self.tbData, self, self.onGridRefresh_Tab, self.onGridBtnClick_Tab)
|
||||
end
|
||||
function SwimTaskCtrl:onGridRefresh_Tab(go)
|
||||
local nIndex = tonumber(go.name) + 1
|
||||
local mapData = self.tbData[nIndex]
|
||||
local mapCfgData_ActivityTaskGroup = ConfigTable.GetData("ActivityTaskGroup", mapData.nGroupId)
|
||||
local nDone = mapData.nTaskDoneNum
|
||||
local nTotal = #mapData.tbTaskData
|
||||
local sProgress = string.format("%s/%s", tostring(nDone), tostring(nTotal))
|
||||
local tr = go.transform
|
||||
tr:Find("scale_on_click/imgDb_on").localScale = self.nCurGroupIndex == nIndex and Vector3.one or Vector3.zero
|
||||
NovaAPI.SetTMPText(tr:Find("scale_on_click/tmpTabName"):GetComponent("TMP_Text"), ConfigTable.GetUIText(tbTabNameUITextId[mapCfgData_ActivityTaskGroup.TaskTabType]))
|
||||
NovaAPI.SetTMPText(tr:Find("scale_on_click/imgDb_off/tmpTabProgress_off"):GetComponent("TMP_Text"), sProgress)
|
||||
NovaAPI.SetTMPText(tr:Find("scale_on_click/imgDb_on/tmpTabProgress_on"):GetComponent("TMP_Text"), sProgress)
|
||||
local goRedDot = tr:Find("scale_on_click/redDotTab")
|
||||
local bInActGroup, nActGroupId = PlayerData.Activity:IsActivityInActivityGroup(self.nActivityId)
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_Group_Task_Group, {
|
||||
nActGroupId,
|
||||
self.nActivityId,
|
||||
mapData.nGroupId
|
||||
}, goRedDot, nil, nil, true)
|
||||
end
|
||||
function SwimTaskCtrl:onGridBtnClick_Tab(go)
|
||||
local nIndex = tonumber(go.name) + 1
|
||||
if self.nCurGroupIndex ~= nIndex then
|
||||
go.transform.parent:GetChild(self.nCurGroupIndex - 1):Find("scale_on_click/imgDb_on").localScale = Vector3.zero
|
||||
self.nCurGroupIndex = nIndex
|
||||
self:refresh_Tab()
|
||||
self:refresh_Task(true)
|
||||
self:refresh_Group()
|
||||
end
|
||||
end
|
||||
function SwimTaskCtrl:refresh_Task(bPlayAnim)
|
||||
local mapData = self.tbData[self.nCurGroupIndex]
|
||||
if bPlayAnim == true then
|
||||
self._mapNode.svList_Task:SetAnim(0.05)
|
||||
end
|
||||
self._mapNode.svList_Task:Init(#mapData.tbTaskData, self, self.onGridRefresh_Task, nil)
|
||||
end
|
||||
function SwimTaskCtrl:onGridRefresh_Task(go)
|
||||
local nIndex = tonumber(go.name) + 1
|
||||
local mapData = self.tbData[self.nCurGroupIndex]
|
||||
local mapTask = mapData.tbTaskData[nIndex]
|
||||
local tr = go.transform:GetChild(0)
|
||||
for i = 1, 5 do
|
||||
tr:Find("imgRare_" .. tostring(i)).localScale = i == mapTask.nRarity and Vector3.one or Vector3.zero
|
||||
end
|
||||
local nCur = mapTask.nCur
|
||||
local nMax = mapTask.nMax
|
||||
if nMax <= 0 then
|
||||
nMax = 0 < nCur and nCur or 1
|
||||
end
|
||||
if nCur > nMax then
|
||||
nCur = nMax
|
||||
end
|
||||
if mapTask.nStatus == AllEnum.ActQuestStatus.Complete or mapTask.nStatus == AllEnum.ActQuestStatus.Received then
|
||||
nCur = nMax
|
||||
end
|
||||
local rt = tr:Find("imgProgessDb"):GetComponent("RectTransform")
|
||||
local nWidth = nCur / nMax * rt.rect.width
|
||||
if 0 < nWidth and nWidth < 40 then
|
||||
nWidth = 40
|
||||
end
|
||||
tr:Find("imgProgessBar"):GetComponent("RectTransform").sizeDelta = Vector2(nWidth, rt.rect.height)
|
||||
NovaAPI.SetTMPText(tr:Find("tmpTaskDesc"):GetComponent("TMP_Text"), mapTask.sDesc)
|
||||
NovaAPI.SetTMPText(tr:Find("tmpTaskProgress"):GetComponent("TMP_Text"), string.format("%s/%s", tostring(nCur), tostring(nMax)))
|
||||
local nCount = #mapTask.tbTaskRewardId
|
||||
for i = 1, 2 do
|
||||
local _tr = tr:Find("goTaskReward" .. tostring(i))
|
||||
if i <= nCount then
|
||||
_tr.localScale = Vector3.one
|
||||
local nId = mapTask.tbTaskRewardId[i]
|
||||
local mapCfgData_Item = ConfigTable.GetData("Item", nId)
|
||||
self:SetSprite_FrameColor(_tr:Find("scale_on_click/imgRare").gameObject:GetComponent("Image"), mapCfgData_Item.Rarity, AllEnum.FrameType_New.Item, false)
|
||||
self:SetPngSprite(_tr:Find("scale_on_click/imgIcon").gameObject:GetComponent("Image"), mapCfgData_Item.Icon)
|
||||
_tr:Find("scale_on_click/goReceived").localScale = mapTask.nStatus == AllEnum.ActQuestStatus.Received and Vector3.one or Vector3.zero
|
||||
local nNum = mapTask.tbTaskRewardNum[i]
|
||||
local sNum = mapCfgData_Item.Type ~= ItemType.Char and mapCfgData_Item.Type ~= ItemType.Disc and "×" .. tostring(nNum) or ""
|
||||
NovaAPI.SetTMPText(_tr:Find("scale_on_click/tmpCount").gameObject:GetComponent("TMP_Text"), sNum)
|
||||
_tr:GetChild(0).name = tostring(nId)
|
||||
_tr:Find("scale_on_click/goTimeLimit").localScale = 0 < mapCfgData_Item.ExpireType and Vector3.one or Vector3.zero
|
||||
else
|
||||
_tr.localScale = Vector3.zero
|
||||
end
|
||||
end
|
||||
tr:Find("tmpUndone").localScale = mapTask.nStatus == AllEnum.ActQuestStatus.UnComplete and 0 >= mapTask.nJumpTo and Vector3.one or Vector3.zero
|
||||
tr:Find("btnDone").localScale = mapTask.nStatus == AllEnum.ActQuestStatus.Complete and Vector3.one or Vector3.zero
|
||||
tr:Find("btnDone"):GetChild(0).name = tostring(mapTask.nTaskId)
|
||||
tr:Find("btnJump").localScale = mapTask.nStatus == AllEnum.ActQuestStatus.UnComplete and 0 < mapTask.nJumpTo and Vector3.one or Vector3.zero
|
||||
tr:Find("btnJump"):GetChild(0).name = tostring(mapTask.nJumpTo)
|
||||
tr:Find("goDone").localScale = mapTask.nStatus == AllEnum.ActQuestStatus.Received and Vector3.one or Vector3.zero
|
||||
end
|
||||
function SwimTaskCtrl:onEvent_ClickRewardItem(goBtn)
|
||||
local nItemId = tonumber(goBtn.transform:GetChild(0).name)
|
||||
if nItemId ~= nil then
|
||||
UTILS.ClickItemGridWithTips(nItemId, goBtn.transform, true, true, true)
|
||||
end
|
||||
end
|
||||
function SwimTaskCtrl:onEvent_ClickTaskDone(goBtn)
|
||||
local nTaskId = tonumber(goBtn.transform:GetChild(0).name)
|
||||
if nTaskId ~= nil then
|
||||
local cb = function()
|
||||
self:BuildData(self.nActivityId)
|
||||
self:refresh_Tab()
|
||||
self:refresh_Task(true)
|
||||
self:refresh_Group()
|
||||
end
|
||||
local mapData = self.tbData[self.nCurGroupIndex]
|
||||
self.ins_ActivityTaskData:SendMsg_ActivityTaskRewardReceiveReq(mapData.nGroupId, 0, mapData.nTabType, cb)
|
||||
end
|
||||
end
|
||||
function SwimTaskCtrl:onEvent_ClickTaskJump(goBtn)
|
||||
local nJumpId = tonumber(goBtn.transform:GetChild(0).name)
|
||||
if 0 < nJumpId then
|
||||
JumpUtil.JumpTo(nJumpId)
|
||||
end
|
||||
end
|
||||
function SwimTaskCtrl:refresh_Group()
|
||||
local mapData = self.tbData[self.nCurGroupIndex]
|
||||
local nGroupId = mapData.nGroupId
|
||||
local tbTaskData = mapData.tbTaskData
|
||||
self.bGot = table.indexof(self.ins_ActivityTaskData.tbActivityTaskGroupIds, nGroupId) > 0
|
||||
local nDone = mapData.nTaskDoneNum
|
||||
local nOK = mapData.nTaskOKNum
|
||||
local nTotal = #tbTaskData
|
||||
local bDone = nOK == nTotal
|
||||
local mapCfgData_ActivityTaskGroup = ConfigTable.GetData("ActivityTaskGroup", nGroupId)
|
||||
NovaAPI.SetTMPText(self._mapNode.tmpGroupName, ConfigTable.GetUIText(tbTabNameUITextId[mapCfgData_ActivityTaskGroup.TaskTabType]))
|
||||
NovaAPI.SetTMPText(self._mapNode.tmpGroupProgress, string.format("%s/%s", tostring(nDone), tostring(nTotal)))
|
||||
self._mapNode.tmpGroupUndone.transform.localScale = bDone == true and Vector3.zero or Vector3.one
|
||||
self._mapNode.btnGroupDone.transform.localScale = bDone == true and self.bGot == false and Vector3.one or Vector3.zero
|
||||
self._mapNode.imgGroupDone.transform.localScale = self.bGot == true and Vector3.one or Vector3.zero
|
||||
self.tbCurGroupRewardId = mapData.tbGroupRewardId
|
||||
self.tbCurGroupRewardNum = mapData.tbGroupRewardNum
|
||||
self._mapNode.svList_GroupReward:Init(#self.tbCurGroupRewardId, self, self.onGridRefresh_GroupRewardItem, self.onGridBtnClick_GroupRewardItem)
|
||||
end
|
||||
function SwimTaskCtrl:onGridRefresh_GroupRewardItem(go)
|
||||
local nIndex = tonumber(go.name) + 1
|
||||
local mapCfgData_Item = ConfigTable.GetData("Item", self.tbCurGroupRewardId[nIndex])
|
||||
local tr = go.transform
|
||||
self:SetSprite_FrameColor(tr:Find("scale_on_click/imgRare").gameObject:GetComponent("Image"), mapCfgData_Item.Rarity, AllEnum.FrameType_New.Item, false)
|
||||
self:SetPngSprite(tr:Find("scale_on_click/imgIcon").gameObject:GetComponent("Image"), mapCfgData_Item.Icon)
|
||||
tr:Find("scale_on_click/goReceived").localScale = self.bGot == true and Vector3.one or Vector3.zero
|
||||
local nNum = self.tbCurGroupRewardNum[nIndex]
|
||||
local sNum = mapCfgData_Item.Type ~= ItemType.Char and mapCfgData_Item.Type ~= ItemType.Disc and "×" .. tostring(nNum) or ""
|
||||
NovaAPI.SetTMPText(tr:Find("scale_on_click/tmpCount").gameObject:GetComponent("TMP_Text"), sNum)
|
||||
tr:Find("scale_on_click/goTimeLimit").localScale = mapCfgData_Item.ExpireType > 0 and Vector3.one or Vector3.zero
|
||||
end
|
||||
function SwimTaskCtrl:onGridBtnClick_GroupRewardItem(go)
|
||||
local nIndex = tonumber(go.name) + 1
|
||||
UTILS.ClickItemGridWithTips(self.tbCurGroupRewardId[nIndex], go.transform, true, true, true)
|
||||
end
|
||||
function SwimTaskCtrl:onBtn_GroupDone()
|
||||
local mapData = self.tbData[self.nCurGroupIndex]
|
||||
local cb = function()
|
||||
self:BuildData(self.nActivityId)
|
||||
self:refresh_Tab()
|
||||
self:refresh_Group()
|
||||
end
|
||||
self.ins_ActivityTaskData:SendMsg_ActivityTaskGroupRewardReceiveReq(mapData.nGroupId, cb)
|
||||
end
|
||||
return SwimTaskCtrl
|
||||
@@ -0,0 +1,9 @@
|
||||
local SwimTaskPanel = class("SwimTaskPanel", BasePanel)
|
||||
SwimTaskPanel._sUIResRootPath = "UI_Activity/"
|
||||
SwimTaskPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Swim/Task.prefab",
|
||||
sCtrlName = "Game.UI.ActivityTheme.Swim.Task.SwimTaskCtrl"
|
||||
}
|
||||
}
|
||||
return SwimTaskPanel
|
||||
Reference in New Issue
Block a user