Initial version - 1.2.0.60

EN: 1.2.0.60
CN: 1.2.0.61
JP: 1.2.0.63
KR: 1.2.0.67
This commit is contained in:
SL1900
2025-12-03 01:00:00 +09:00
commit 5e0d58cfad
3595 changed files with 9373562 additions and 0 deletions
@@ -0,0 +1,235 @@
local BattlePassBuyLevelCtrl = class("BattlePassBuyLevelCtrl", BaseCtrl)
BattlePassBuyLevelCtrl._mapNodeConfig = {
TMPHintLevelBuy = {sComponentName = "TMP_Text"},
TMP_costCount = {sComponentName = "TMP_Text"},
TMPBuyLevel = {sComponentName = "TMP_Text"},
TMPLevelTitle = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuyTitle"
},
goQuantitySelector = {
sNodeName = "tc_quantity_selector",
sCtrlName = "Game.UI.TemplateEx.TemplateQuantitySelectorCtrl"
},
imgCostIcon = {sComponentName = "Image"},
srItemList = {
sComponentName = "LoopScrollView"
},
btnConfirm1 = {
sComponentName = "UIButton",
callback = "OnBtnClick_Buy"
},
btnCancel = {sComponentName = "UIButton", callback = "ClosePanel"},
btnClose = {sComponentName = "UIButton", callback = "ClosePanel"},
BtnCloseScreen = {sComponentName = "UIButton", callback = "ClosePanel"},
txtTitleBuyLevel2 = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuy"
},
txtStock = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuy"
},
TMP_costTitle = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuyCost"
},
txtBtnConfirm = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuyConfirm"
},
txtBtnCancel = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuyCancel"
},
AnimRoot = {
sNodeName = "t_window_04",
sComponentName = "Animator"
}
}
BattlePassBuyLevelCtrl._mapEventConfig = {}
BattlePassBuyLevelCtrl._mapRedDotConfig = {}
function BattlePassBuyLevelCtrl:Awake()
self._mapGridCtrl = {}
self.upgradeCostId = ConfigTable.GetData("BattlePassLevel", 1).Tid
self:SetSprite_Coin(self._mapNode.imgCostIcon, self.upgradeCostId)
end
function BattlePassBuyLevelCtrl:FadeIn()
end
function BattlePassBuyLevelCtrl:FadeOut()
end
function BattlePassBuyLevelCtrl:OnEnable()
self.gameObject:SetActive(false)
end
function BattlePassBuyLevelCtrl:OnDisable()
self:UnbindAllCtrl()
end
function BattlePassBuyLevelCtrl:OnDestroy()
end
function BattlePassBuyLevelCtrl:OnRelease()
end
function BattlePassBuyLevelCtrl:UnbindAllCtrl()
for _, mapCtrl in pairs(self._mapGridCtrl) do
self:UnbindCtrlByNode(mapCtrl)
end
self._mapGridCtrl = {}
end
function BattlePassBuyLevelCtrl:ClosePanel()
local waitCallback = function()
self:UnbindAllCtrl()
self.gameObject:SetActive(false)
end
self._mapNode.AnimRoot:Play("t_window_04_t_out")
self:AddTimer(1, 0.2, waitCallback, true, true, true, nil)
end
function BattlePassBuyLevelCtrl:ShowPanel(nCurLevel, tbReward, nSeasonId, bPremium)
self.gameObject:SetActive(true)
self._mapNode.TMPHintLevelBuy.gameObject:SetActive(false)
self._mapNode.srItemList.gameObject:SetActive(false)
self.curAddLevel = 1
self.curCost = 0
self.tbReward = tbReward
self.curLevel = nCurLevel
self.bPremium = bPremium
self.rewards = {}
self._mapNode.srItemList:SetAnim(0.08)
self:RefreshAddCount()
local callback = function(nCount)
self.curAddLevel = nCount
self:RefreshAddCount()
end
local nMaxLevel = #self.tbReward
self._mapNode.goQuantitySelector:Init(callback, 1, nMaxLevel - nCurLevel)
self._mapNode.AnimRoot:Play("t_window_04_t_in")
end
function BattlePassBuyLevelCtrl:OnGridRefresh(goGrid, gridIndex)
if self._mapGridCtrl[goGrid] == nil then
local mapCtrl = self:BindCtrlByNode(goGrid, "Game.UI.BattlePass.BattlePassBuyLevelItemGridCtrl")
self._mapGridCtrl[goGrid] = mapCtrl
end
local nIdx = gridIndex
if nIdx == nil then
return
end
nIdx = nIdx + 1
self._mapGridCtrl[goGrid]:Refresh(self.rewards[nIdx][1], self.rewards[nIdx][2])
end
function BattlePassBuyLevelCtrl:RefreshAddCount()
local mapReward = {}
self.curCost = 0
for i = self.curLevel + 1, self.curLevel + self.curAddLevel do
local mapRewardData = self.tbReward[i]
if mapRewardData ~= nil then
local mapLevel = ConfigTable.GetData("BattlePassLevel", i)
if mapLevel == nil then
return
end
self.curCost = self.curCost + mapLevel.Qty
if 0 < mapRewardData.nNormalTid then
if mapReward[mapRewardData.nNormalTid] == nil then
mapReward[mapRewardData.nNormalTid] = 0
end
mapReward[mapRewardData.nNormalTid] = mapReward[mapRewardData.nNormalTid] + mapRewardData.nNormalQty
end
if self.bPremium then
if 0 < mapRewardData.nVipTid1 then
if mapReward[mapRewardData.nVipTid1] == nil then
mapReward[mapRewardData.nVipTid1] = 0
end
mapReward[mapRewardData.nVipTid1] = mapReward[mapRewardData.nVipTid1] + mapRewardData.nVipQty1
end
if 0 < mapRewardData.nVipTid2 then
if mapReward[mapRewardData.nVipTid2] == nil then
mapReward[mapRewardData.nVipTid2] = 0
end
mapReward[mapRewardData.nVipTid2] = mapReward[mapRewardData.nVipTid2] + mapRewardData.nVipQty2
end
end
end
end
NovaAPI.SetTMPText(self._mapNode.TMP_costCount, self.curCost)
local nDefaultCount = PlayerData.Item:GetItemCountByID(self.upgradeCostId)
if nDefaultCount < self.curCost then
NovaAPI.SetTMPColor(self._mapNode.TMP_costCount, Red_Unable)
else
NovaAPI.SetTMPColor(self._mapNode.TMP_costCount, Blue_Normal)
end
self.rewards = {}
for nTid, nCount in pairs(mapReward) do
table.insert(self.rewards, {nTid, nCount})
end
if 0 < #self.rewards then
self._mapNode.srItemList.gameObject:SetActive(true)
self._mapNode.srItemList:Init(#self.rewards, self, self.OnGridRefresh, nil, true, nil)
self._mapNode.TMPHintLevelBuy.gameObject:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.TMPHintLevelBuy, orderedFormat(ConfigTable.GetUIText("BattlePassLevelBuyInfo") or "", self.curLevel + self.curAddLevel))
NovaAPI.SetTMPText(self._mapNode.TMPBuyLevel, self.curAddLevel)
else
self._mapNode.TMPHintLevelBuy.gameObject:SetActive(false)
self._mapNode.srItemList.gameObject:SetActive(false)
end
end
function BattlePassBuyLevelCtrl:OnBtnClick_Buy()
self:BuyOrExchangeCoin()
end
function BattlePassBuyLevelCtrl:BuyOrExchangeCoin()
local ConfirmPanel = function(sTip, confirmCallback)
local msg = {
nType = AllEnum.MessageBox.Confirm,
sContent = sTip,
callbackConfirm = confirmCallback,
callbackCancel = nil,
bBlur = false
}
EventManager.Hit(EventId.OpenMessageBox, msg)
end
local mapCostCfgData = ConfigTable.GetData_Item(AllEnum.CoinItemId.STONE)
local mapJadeCfgData = ConfigTable.GetData_Item(AllEnum.CoinItemId.Jade)
if mapJadeCfgData == nil then
return
end
if mapCostCfgData == nil then
return
end
local BuyCallback = function(mapData)
self:ClosePanel()
end
local nDefaultCount = PlayerData.Item:GetItemCountByID(self.upgradeCostId)
if nDefaultCount >= self.curCost then
local confirmCallback = function()
PlayerData.BattlePass:NetMsg_BuyBattlePassLevel(self.curAddLevel, BuyCallback)
end
local sTips = orderedFormat(ConfigTable.GetUIText("Shop_BuyComfirm") or "", self.curCost, mapJadeCfgData.Title, ConfigTable.GetUIText("BattlePassLevelTitle"))
ConfirmPanel(sTips, confirmCallback)
elseif self.upgradeCostId == AllEnum.CoinItemId.Jade then
local nNeedCount = self.curCost - nDefaultCount
local sTips1 = orderedFormat(ConfigTable.GetUIText("Recruit_ExchangeGemZero") or "", mapJadeCfgData.Id, nNeedCount, mapCostCfgData.Id)
local confirmCallbackStone = function()
EventManager.Hit("TopRes", false, self.nTopBarId, self.tbCurTabCoin)
local nCurStoneCount = PlayerData.Item:GetItemCountByID(AllEnum.CoinItemId.STONE)
nCurStoneCount = nCurStoneCount + PlayerData.Item:GetItemCountByID(AllEnum.CoinItemId.FREESTONE)
if nCurStoneCount >= nNeedCount then
local convertCallback = function()
local nDefaultCountAfter = PlayerData.Item:GetItemCountByID(self.upgradeCostId)
if nDefaultCountAfter < self.curCost then
NovaAPI.SetTMPColor(self._mapNode.TMP_costCount, Red_Unable)
else
NovaAPI.SetTMPColor(self._mapNode.TMP_costCount, Blue_Normal)
end
end
PlayerData.Coin:SendGemConvertReqReq(nNeedCount, convertCallback)
else
local sTips2 = orderedFormat(ConfigTable.GetUIText("Recruit_Charge") or "", mapCostCfgData.Id)
local confirmCallbackExchange = function()
EventManager.Hit("TopRes", false, self.nTopBarId, self.tbCurTabCoin)
EventManager.Hit(EventId.OpenPanel, PanelId.Mall, AllEnum.MallToggle.Gem)
end
ConfirmPanel(sTips2, confirmCallbackExchange)
end
end
ConfirmPanel(sTips1, confirmCallbackStone)
else
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("NotEnoughItem"))
end
end
return BattlePassBuyLevelCtrl
@@ -0,0 +1,20 @@
local BattlePassBuyLevelItemGridCtrl = class("BattlePassBuyLevelItemGridCtrl", BaseCtrl)
BattlePassBuyLevelItemGridCtrl._mapNodeConfig = {
rtItem = {
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
btnGrid = {
sComponentName = "UIButton",
callback = "OnBtnClick_Grid"
}
}
BattlePassBuyLevelItemGridCtrl._mapEventConfig = {}
BattlePassBuyLevelItemGridCtrl._mapRedDotConfig = {}
function BattlePassBuyLevelItemGridCtrl:Refresh(nTid, nCount)
self.nTid = nTid
self._mapNode.rtItem:SetItem(nTid, nil, nCount, nil, false, false, false, true, false)
end
function BattlePassBuyLevelItemGridCtrl:OnBtnClick_Grid(btn)
UTILS.ClickItemGridWithTips(self.nTid, btn.gameObject.transform, true, true, false)
end
return BattlePassBuyLevelItemGridCtrl
@@ -0,0 +1,42 @@
local BattlePassBuyLevelItemGridCtrl = class("BattlePassBuyLevelItemGridCtrl", BaseCtrl)
BattlePassBuyLevelItemGridCtrl._mapNodeConfig = {
tcItem = {
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
btnGrid = {sComponentName = "UIButton"},
TMPDesc = {sComponentName = "TMP_Text"}
}
BattlePassBuyLevelItemGridCtrl._mapEventConfig = {}
BattlePassBuyLevelItemGridCtrl._mapRedDotConfig = {}
function BattlePassBuyLevelItemGridCtrl:OnEnable()
local rtShow = self.gameObject.transform:Find("btnGrid/AnimRoot/rtTopInfo")
if rtShow ~= nil then
local tmpHint = rtShow:Find("TMPRewardHintSPremium")
NovaAPI.SetTMPText(tmpHint:GetComponent("TMP_Text"), ConfigTable.GetUIText("BattlePassRewardPremiumTopGridHint"))
end
end
function BattlePassBuyLevelItemGridCtrl:Refresh(nTid)
local rtShow = self.gameObject.transform:Find("btnGrid/AnimRoot/rtTopInfo")
if nTid == nil then
self._mapNode.TMPDesc.gameObject:SetActive(false)
self._mapNode.tcItem.gameObject:SetActive(false)
if rtShow ~= nil then
rtShow.gameObject:SetActive(true)
end
return
else
self._mapNode.TMPDesc.gameObject:SetActive(true)
self._mapNode.tcItem.gameObject:SetActive(true)
if rtShow ~= nil then
rtShow.gameObject:SetActive(false)
end
end
self.nTid = nTid
local mapItemCfgData = ConfigTable.GetData_Item(self.nTid)
if mapItemCfgData == nil then
return
end
NovaAPI.SetTMPText(self._mapNode.TMPDesc, mapItemCfgData.Title)
self._mapNode.tcItem:SetItem(nTid, nil, nil, nil, false, false, false, true, false)
end
return BattlePassBuyLevelItemGridCtrl
+651
View File
@@ -0,0 +1,651 @@
local BattlePassCtrl = class("BattlePassCtrl", BaseCtrl)
local nExpBarLength = 560
local nExpBarHeight = 25
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
local LocalData = require("GameCore.Data.LocalData")
BattlePassCtrl._mapNodeConfig = {
rtMainContent = {sComponentName = "Animator"},
rtCoverRootAnim = {
sNodeName = "rtCoverRoot",
sComponentName = "Animator"
},
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
rtBuyLevel = {
sCtrlName = "Game.UI.BattlePass.BattlePassBuyLevelCtrl"
},
rtBuyPremiumBattlepass = {
sCtrlName = "Game.UI.BattlePass.BattlePassPremiumBuyCtrl"
},
rtSkinPopup = {
sCtrlName = "Game.UI.BattlePass.BattlePassPopupSkinCtrl"
},
rtCoverRoot = {sComponentName = "Transform"},
panelRoot = {
sNodeName = "rtMainContent",
sComponentName = "Transform"
},
btnLevelDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_BuyLevel"
},
rt_RewardList = {
sCtrlName = "Game.UI.BattlePass.BattlePassRewardCtrl"
},
rt_QuestList = {
sCtrlName = "Game.UI.BattlePass.BattlePassQuestCtrl"
},
CGReward = {
sNodeName = "rt_RewardList",
sComponentName = "CanvasGroup"
},
CGQuest = {
sNodeName = "rt_QuestList",
sComponentName = "CanvasGroup"
},
btnLeft = {
sComponentName = "UIButton",
callback = "OnBtnClick_Reward"
},
btnRight = {
sComponentName = "UIButton",
callback = "OnBtnClick_Quest"
},
TMPLevel = {sComponentName = "TMP_Text"},
TMPProgress = {sComponentName = "TMP_Text"},
imgProgressBarFillMask = {
sComponentName = "RectTransform"
},
imgProgressBarFillHighLight = {sComponentName = "Image"},
btnUnlockVip = {
sComponentName = "UIButton",
callback = "OnBtnClick_BuyPremium",
nCount = 2
},
txtbtnUnlockVip = {
sComponentName = "TMP_Text",
nCount = 2,
sLanguageId = "BattlePassPremiumBuy"
},
rtToggleTop = {
sCtrlName = "Game.UI.TemplateEx.TemplateTogTabCtrl"
},
redDotReward = {},
redDotQuest = {},
TMPLevelTitleHome = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelTitle"
},
TMPProgressTitle = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelProgressTitle"
},
txtBtnLevelDetail = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassLevelBuyTitle"
},
TMPRewardDesc = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_RewardDesc"
},
TMPRewardTitle = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_RewardTitle"
},
TMPSeasonTImeTitle = {sComponentName = "TMP_Text"},
txtBtnRewardDetail = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_BtnRewardDetail"
},
TMPLevelMax = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassQusetLevelMax"
},
btnRewardDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_OutfitInfo"
},
imgDiscCover = {sComponentName = "Image", nCount = 2},
imgCoverDiscRare = {sComponentName = "Image", nCount = 2}
}
BattlePassCtrl._mapEventConfig = {
[EventId.UIBackConfirm] = "OnEvent_Back",
[EventId.UIHomeConfirm] = "OnEvent_Home",
BattlePassQuestReceive = "OnEvent_BattlePassQuestReceive",
UpdateBattlePassReward = "OnEvent_UpdateBattlePassReward",
BattlePassBuyLevel = "OnEvent_BattlePassBuyLevel",
BattlePassPremiumSuccess = "OnEvent_BattlePassPremiumSuccess",
BattlePassLevelUpPanelClose = "OnEvent_LevelUpPanelClose",
BattlePassOpenDiscInfo = "OnBtnClick_OutfitInfo",
BattlePassNeedRefresh = "OnEvent_BattlePassNeedRefresh"
}
BattlePassCtrl._mapRedDotConfig = {
[RedDotDefine.BattlePass_Reward] = {
sNodeName = "redDotReward"
},
[RedDotDefine.BattlePass_Quest] = {
sNodeName = "redDotQuest"
}
}
function BattlePassCtrl:Awake()
self.curShowDiscIdx = 1
end
function BattlePassCtrl:FadeIn()
end
function BattlePassCtrl:FadeOut()
end
function BattlePassCtrl:OnEnable()
self.nAnimState = 1
self._mapNode.rtCoverRootAnim:Play("rtCoverRoot_switch1_loop")
NovaAPI.SetImageColor(self._mapNode.imgProgressBarFillHighLight, Color(1, 1, 1, 0))
self._mapNode.panelRoot.gameObject:SetActive(false)
local callback = function(mapData)
self.mapBattlePassInfo = mapData
self._mapNode.panelRoot.gameObject:SetActive(true)
local bHasComplete, nQuestIdx = self:Refresh()
EventManager.Hit(EventId.SetTransition)
self._mapNode.rtMainContent:Play("BattlePassPanel_in")
self._mapNode.rt_RewardList:PlayInAnim()
self._mapNode.rtCoverRoot.localScale = Vector3.one
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.mapBattlePassInfo.nSeasonId)
if mapBattlePassCfgData ~= nil then
local sSeasonId = LocalData.GetPlayerLocalData("BattlePass_ShowPopUp")
local nLocalSeasonId = tonumber(sSeasonId)
if nLocalSeasonId == nil or nLocalSeasonId ~= self.mapBattlePassInfo.nSeasonId then
local waitTransion = function()
self._mapNode.rtSkinPopup:ShowPanel(mapBattlePassCfgData)
LocalData.SetPlayerLocalData("BattlePass_ShowPopUp", self.mapBattlePassInfo.nSeasonId)
end
self:AddTimer(1, 0.4, waitTransion, true, true, true)
end
end
if nQuestIdx ~= 0 then
self._mapNode.rt_QuestList:SetToggle(nQuestIdx)
end
if bHasComplete or self._panel.tog == 2 then
self.curTog = 2
self._panel.tog = 2
self._mapNode.rtToggleTop:SetState(true)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGReward, 0)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGReward, false)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGQuest, 1)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGQuest, true)
else
self.curTog = 1
self._mapNode.rtToggleTop:SetState(false)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGReward, 1)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGReward, true)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGQuest, 0)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGQuest, false)
end
self._mapNode.rt_RewardList:SetLevelPos()
if self._panel.bOpenPremium then
self:OnBtnClick_BuyPremium()
else
self._mapNode.rtBuyPremiumBattlepass.gameObject:SetActive(false)
end
end
PlayerData.BattlePass:GetBattlePassInfo(callback)
self._mapNode.rtToggleTop:SetText(ConfigTable.GetUIText("BattlePassTogQuest"), ConfigTable.GetUIText("BattlePassTogReward"))
self.tbShowRewardIdx = {}
self.timerShowDisc = self:AddTimer(0, 5, self.SwitchShowDiscAnim, true, true, true)
end
function BattlePassCtrl:OnDisable()
end
function BattlePassCtrl:OnDestroy()
end
function BattlePassCtrl:OnRelease()
end
function BattlePassCtrl:Refresh()
self.tbDisc = {}
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.mapBattlePassInfo.nSeasonId)
if mapBattlePassCfgData == nil then
printError("BattlePassCfgData missing:" .. self.mapBattlePassInfo.nSeasonId)
return
end
local sTimeStr = PlayerData.BattlePass:GetRefreshTime()
NovaAPI.SetTMPText(self._mapNode.TMPSeasonTImeTitle, orderedFormat(ConfigTable.GetUIText("BattlePass_RemainTimeTitle") or "", sTimeStr))
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.mapBattlePassInfo.nSeasonId)
if mapBattlePassCfgData ~= nil then
local nPackageId = mapBattlePassCfgData.OutfitPackageShowItem
local mapItemCfgData = ConfigTable.GetData_Item(nPackageId)
if not mapItemCfgData then
return
end
local mapItemUseCfg = decodeJson(mapItemCfgData.UseArgs)
for sTid, nCount in pairs(mapItemUseCfg) do
local nItemTid = tonumber(sTid)
if nItemTid ~= nil then
local mapDisc = PlayerData.Disc:GenerateLocalDiscData(nItemTid)
table.insert(self.tbDisc, mapDisc)
end
end
local sort = function(a, b)
return a.nRarity < b.nRarity or a.nRarity == b.nRarity and a.nEET < b.nEET or a.nRarity == b.nRarity and a.nEET == b.nEET and a.nId < b.nId
end
table.sort(self.tbDisc, sort)
end
NovaAPI.SetTMPText(self._mapNode.TMPLevel, self.mapBattlePassInfo.nLevel)
local bFullLevel = false
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) == nil then
bFullLevel = true
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, self.mapBattlePassInfo.nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(false)
self._mapNode.TMPLevelMax.gameObject:SetActive(true)
else
local nExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength * self.mapBattlePassInfo.nExp / nExp, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(true)
self._mapNode.TMPLevelMax.gameObject:SetActive(false)
end
if self.tbDisc ~= nil and #self.tbDisc > 0 then
self._mapNode.rtCoverRoot.localScale = Vector3.one
local mapItemCfgData = ConfigTable.GetData_Item(self.tbDisc[self.curShowDiscIdx].nId)
if mapItemCfgData ~= nil then
self:SetPngSprite(self._mapNode.imgDiscCover[self.nAnimState], mapItemCfgData.Icon)
self:SetPngSprite(self._mapNode.imgCoverDiscRare[self.curShowDiscIdx], "UI/big_sprites/rare_scenery_" .. AllEnum.FrameColor[mapItemCfgData.Rarity])
end
else
self._mapNode.rtCoverRoot.localScale = Vector3.zero
end
local bHasComplete, nQuestIdx = self._mapNode.rt_QuestList:Refresh(self.mapBattlePassInfo.nExpThisWeek, self.mapBattlePassInfo.nLevel, true)
self._mapNode.rt_RewardList:Refresh(self.mapBattlePassInfo.tbReward, 0 < self.mapBattlePassInfo.nCurMode, self.mapBattlePassInfo.nLevel)
return bHasComplete and not bFullLevel, nQuestIdx
end
function BattlePassCtrl:SwitchShowDiscAnim()
if self.tbDisc ~= nil and #self.tbDisc > 0 then
self.curShowDiscIdx = self.curShowDiscIdx % #self.tbDisc + 1
self.nAnimState = self.nAnimState % 2 + 1
local mapItemCfgData = ConfigTable.GetData_Item(self.tbDisc[self.curShowDiscIdx].nId)
if mapItemCfgData ~= nil then
self:SetPngSprite(self._mapNode.imgDiscCover[self.nAnimState], mapItemCfgData.Icon)
self:SetPngSprite(self._mapNode.imgCoverDiscRare[self.nAnimState], "UI/big_sprites/rare_scenery_" .. AllEnum.FrameColor[mapItemCfgData.Rarity])
end
local sAnimName = "rtCoverRoot_switch" .. self.nAnimState
self._mapNode.rtCoverRootAnim:Play(sAnimName)
end
end
function BattlePassCtrl:OnEvent_Back(nPanelId)
if self._panel._nPanelId ~= nPanelId then
return
end
if self._panel.bOpenPremium then
self._mapNode.rtBuyPremiumBattlepass:ClosePanel()
self._mapNode.panelRoot.gameObject:SetActive(true)
self._panel.bOpenPremium = false
self:OnEvent_LevelUpPanelClose()
self._mapNode.rtMainContent:Play("BattlePassPanel_in1")
self._mapNode.rtCoverRoot.localScale = Vector3.one
self._mapNode.TopBar:SetTitleTxt(ConfigTable.GetData("TopBar", "BattlePass").Title)
else
self._panel.tog = 1
self._panel.questTab = 1
EventManager.Hit(EventId.CloesCurPanel)
end
end
function BattlePassCtrl:OnEvent_Home(nPanelId)
if self._panel._nPanelId ~= nPanelId then
return
end
self._panel.tog = 1
self._panel.questTab = 1
PanelManager.Home()
end
function BattlePassCtrl:OnBtnClick_Reward()
self._panel.tog = 1
if self.curTog == 1 then
return
end
self.curTog = 1
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGReward, 1)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGReward, true)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGQuest, 0)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGQuest, false)
self._mapNode.rtToggleTop:SetState(false)
if #self.tbShowRewardIdx ~= 0 then
self._mapNode.rt_RewardList:PlayUnlockAnim(self.tbShowRewardIdx)
self.tbShowRewardIdx = {}
end
end
function BattlePassCtrl:OnBtnClick_Quest()
self._panel.tog = 2
if self.curTog == 2 then
return
end
self.curTog = 2
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGReward, 0)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGReward, false)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.CGQuest, 1)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.CGQuest, true)
self._mapNode.rtToggleTop:SetState(true)
self._mapNode.rt_QuestList:PlayListInAnim()
end
function BattlePassCtrl:OnBtnClick_BuyLevel()
self._mapNode.rtBuyLevel:ShowPanel(self.mapBattlePassInfo.nLevel, self.mapBattlePassInfo.tbReward, self.mapBattlePassInfo.nSeasonId, self.mapBattlePassInfo.nCurMode > 0)
end
function BattlePassCtrl:OnBtnClick_BuyPremium()
self._mapNode.TopBar:SetTitleTxt(ConfigTable.GetUIText("BattlePassPremiumBuy"))
self._mapNode.rtBuyPremiumBattlepass:OpenPanel(self.mapBattlePassInfo.nCurMode, self.mapBattlePassInfo.nSeasonId, self.mapBattlePassInfo.nVersion)
self._mapNode.panelRoot.gameObject:SetActive(false)
self._mapNode.rtCoverRoot.localScale = Vector3.zero
self._panel.bOpenPremium = true
end
function BattlePassCtrl:OnBtnClick_OutfitInfo()
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.mapBattlePassInfo.nSeasonId)
if mapBattlePassCfgData == nil then
return
end
local nPackageId = mapBattlePassCfgData.OutfitPackageShowItem
EventManager.Hit(EventId.OpenPanel, PanelId.DiscPreview, nPackageId, true)
end
function BattlePassCtrl:OnBtnClick_ButtonTest1()
local callback = function()
end
local mapBefore = {
nLevel = 0,
nExp = 0,
nMaxLevel = 60,
nMaxExp = 1000
}
local mapAfter = {
nLevel = 0,
nExp = 900,
nMaxLevel = 60,
nMaxExp = 1000
}
self:ExpBarAnim(mapBefore, mapAfter, callback, self._mapNode.TMPLevel)
end
function BattlePassCtrl:OnBtnClick_ButtonTest2()
local callback = function()
end
local mapBefore = {
nLevel = 0,
nExp = 0,
nMaxLevel = 60,
nMaxExp = 1000
}
local mapAfter = {
nLevel = 5,
nExp = 900,
nMaxLevel = 60,
nMaxExp = 1000
}
self:ExpBarAnim(mapBefore, mapAfter, callback, self._mapNode.TMPLevel)
end
function BattlePassCtrl:OnEvent_BattlePassQuestReceive()
local beforeLevel = self.mapBattlePassInfo.nLevel
local beforeExp = self.mapBattlePassInfo.nExp
local mapBefore = {
nLevel = beforeLevel,
nExp = beforeExp,
nMaxLevel = -1,
nMaxExp = 0
}
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) ~= nil then
mapBefore.nMaxExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
end
local callback = function(mapData)
self.mapBattlePassInfo = mapData
self.mapBattlePassInfo = mapData
local afterLevel = self.mapBattlePassInfo.nLevel
local afterExp = self.mapBattlePassInfo.nExp
local mapAfter = {
nLevel = afterLevel,
nExp = afterExp,
nMaxLevel = -1,
nMaxExp = 0
}
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) == nil then
mapAfter.nExp = 1
mapAfter.nMaxExp = 1
mapAfter.nMaxLevel = afterLevel
else
mapAfter.nMaxExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
end
local animCallback = function()
if beforeLevel ~= afterLevel then
local mapLevelData = {
nOldLevel = beforeLevel,
nOldExp = beforeExp,
nLevel = afterLevel,
nExp = afterExp
}
local callabck = function()
EventManager.Hit("BattlePassLevelUpPanelClose")
end
EventManager.Hit(EventId.OpenPanel, PanelId.BattlePassUpgrade, callabck, mapLevelData)
end
NovaAPI.SetTMPText(self._mapNode.TMPLevel, self.mapBattlePassInfo.nLevel)
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) == nil then
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, self.mapBattlePassInfo.nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(false)
self._mapNode.TMPLevelMax.gameObject:SetActive(true)
else
local nExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength * self.mapBattlePassInfo.nExp / nExp, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(true)
self._mapNode.TMPLevelMax.gameObject:SetActive(false)
end
if beforeLevel ~= self.mapBattlePassInfo.nLevel then
self.tbShowRewardIdx = {}
for i = beforeLevel + 1, self.mapBattlePassInfo.nLevel do
if #self.tbShowRewardIdx < 5 then
table.insert(self.tbShowRewardIdx, i)
end
end
self._mapNode.rt_RewardList:Refresh(self.mapBattlePassInfo.tbReward, self.mapBattlePassInfo.nCurMode > 0, self.mapBattlePassInfo.nLevel)
self._mapNode.rt_QuestList:Refresh(self.mapBattlePassInfo.nExpThisWeek, self.mapBattlePassInfo.nLevel)
end
end
self:ExpBarAnim(mapBefore, mapAfter, animCallback, self._mapNode.TMPLevel)
end
PlayerData.BattlePass:GetBattlePassInfo(callback)
end
function BattlePassCtrl:ExpBarAnim(mapBefore, mapAfter, callback, txt)
local bMaxLv = mapAfter.nLevel == mapAfter.nMaxLevel
local nAddLevel = mapAfter.nLevel - mapBefore.nLevel
local nAddCount = 0
if nAddLevel == 0 then
nAddCount = 1
elseif 0 < mapAfter.nExp then
nAddCount = nAddLevel + 1
else
nAddCount = nAddLevel
end
local nAniTime = 0.4
if nAddCount < 6 then
nAniTime = 0.4
elseif 6 <= nAddCount then
nAniTime = 0.2
end
local nBeforeToMaxTime = nAniTime * (1 - mapBefore.nExp / mapBefore.nMaxExp)
local nBeforeToAfterTime = nAniTime * ((mapAfter.nExp - mapBefore.nExp) / mapAfter.nMaxExp)
local nZeroToAfterTime = nAniTime * mapAfter.nExp / mapAfter.nMaxExp
local nAllTime = 0
local sequence = DOTween.Sequence()
for i = 1, nAddCount - 1 do
local nTime = i == 1 and nBeforeToMaxTime or nAniTime
nAllTime = nAllTime + nTime
sequence:AppendCallback(function()
WwiseAudioMgr:PlaySound("ui_common_levelUp")
end)
sequence:Append(self._mapNode.imgProgressBarFillMask:DOSizeDelta(Vector2(nExpBarLength, nExpBarHeight), nTime))
sequence:AppendCallback(function()
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(0, nExpBarHeight)
NovaAPI.SetTMPText(txt, mapBefore.nLevel + i)
end)
end
if bMaxLv then
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
nAllTime = nAllTime + nTime
sequence:AppendCallback(function()
WwiseAudioMgr:PlaySound("ui_common_levelUp")
end)
sequence:Append(self._mapNode.imgProgressBarFillMask:DOSizeDelta(Vector2(nExpBarLength, nExpBarHeight), nTime))
elseif mapAfter.nExp > 0 then
local nTime = 1 < nAddCount and nZeroToAfterTime or nBeforeToAfterTime
nAllTime = nAllTime + nTime
sequence:AppendCallback(function()
WwiseAudioMgr:PlaySound("ui_common_levelUp")
end)
sequence:Append(self._mapNode.imgProgressBarFillMask:DOSizeDelta(Vector2(mapAfter.nExp / mapAfter.nMaxExp * nExpBarLength, nExpBarHeight), nTime))
elseif mapAfter.nExp == 0 then
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
nAllTime = nAllTime + nTime
sequence:AppendCallback(function()
WwiseAudioMgr:PlaySound("ui_common_levelUp")
end)
sequence:Append(self._mapNode.imgProgressBarFillMask:DOSizeDelta(Vector2(nExpBarLength, nExpBarHeight), nTime))
sequence:AppendCallback(function()
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(0, nExpBarHeight)
end)
end
NovaAPI.SetImageColor(self._mapNode.imgProgressBarFillHighLight, Color(1, 1, 1, 1))
local tweener = NovaAPI.ImageDoFade(self._mapNode.imgProgressBarFillHighLight, 0, nAllTime * 0.5)
tweener:SetDelay(nAllTime * 0.5)
sequence:SetUpdate(true)
local _cb = function()
if callback then
callback()
end
NovaAPI.SetTMPText(txt, mapAfter.nLevel)
end
sequence.onComplete = dotween_callback_handler(self, _cb)
EventManager.Hit(EventId.TemporaryBlockInput, nAllTime)
end
function BattlePassCtrl:OnEvent_UpdateBattlePassReward(mapData)
local mapReward = PlayerData.Item:ProcessRewardChangeInfo(mapData)
local rewardCallback = function()
local tbSelectedItem = {}
for _, mapItemData in ipairs(mapReward.tbReward) do
local mapItemCfgData = ConfigTable.GetData_Item(mapItemData.id)
if mapItemCfgData == nil then
return
end
if mapItemCfgData.Stype == GameEnum.itemStype.OutfitCYO then
table.insert(tbSelectedItem, mapItemData.id)
end
end
if 0 < #tbSelectedItem then
EventManager.Hit(EventId.OpenPanel, PanelId.Consumable, tbSelectedItem)
end
end
UTILS.OpenReceiveByReward(mapReward, rewardCallback)
local callback = function(mapBattlePassData)
self.mapBattlePassInfo = mapBattlePassData
self._mapNode.rt_RewardList:Refresh(self.mapBattlePassInfo.tbReward, self.mapBattlePassInfo.nCurMode > 0, self.mapBattlePassInfo.nLevel)
end
PlayerData.BattlePass:GetBattlePassInfo(callback)
end
function BattlePassCtrl:OnEvent_BattlePassBuyLevel()
local beforeLevel = self.mapBattlePassInfo.nLevel
local beforeExp = self.mapBattlePassInfo.nExp
local mapBefore = {
nLevel = beforeLevel,
nExp = beforeExp,
nMaxLevel = -1,
nMaxExp = 0
}
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) == nil then
mapBefore.nMaxExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
end
local callback = function(mapData)
self.mapBattlePassInfo = mapData
local afterLevel = self.mapBattlePassInfo.nLevel
local afterExp = self.mapBattlePassInfo.nExp
local mapAfter = {
nLevel = afterLevel,
nExp = afterExp,
nMaxLevel = -1,
nMaxExp = 0
}
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) ~= nil then
mapAfter.nMaxExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
else
mapAfter.nExp = 1
mapAfter.nMaxExp = 1
mapAfter.nMaxLevel = afterLevel
end
local animCallback = function()
self.mapBattlePassInfo = mapData
NovaAPI.SetTMPText(self._mapNode.TMPLevel, self.mapBattlePassInfo.nLevel)
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) == nil then
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, self.mapBattlePassInfo.nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(false)
self._mapNode.TMPLevelMax.gameObject:SetActive(true)
else
local nExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength * self.mapBattlePassInfo.nExp / nExp, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(true)
self._mapNode.TMPLevelMax.gameObject:SetActive(false)
end
if beforeLevel ~= self.mapBattlePassInfo.nLevel then
self.tbShowRewardIdx = {}
for i = beforeLevel + 1, self.mapBattlePassInfo.nLevel do
if #self.tbShowRewardIdx < 5 then
table.insert(self.tbShowRewardIdx, i)
end
end
self._mapNode.rt_RewardList:Refresh(self.mapBattlePassInfo.tbReward, self.mapBattlePassInfo.nCurMode > 0, self.mapBattlePassInfo.nLevel)
self._mapNode.rt_QuestList:Refresh(self.mapBattlePassInfo.nExpThisWeek, self.mapBattlePassInfo.nLevel)
end
end
animCallback()
end
PlayerData.BattlePass:GetBattlePassInfo(callback)
end
function BattlePassCtrl:OnEvent_BattlePassPremiumSuccess()
local beforeLevel = self.mapBattlePassInfo.nLevel
local callback = function(mapData)
self.mapBattlePassInfo = mapData
NovaAPI.SetTMPText(self._mapNode.TMPLevel, self.mapBattlePassInfo.nLevel)
if ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1) == nil then
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, self.mapBattlePassInfo.nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(false)
self._mapNode.TMPLevelMax.gameObject:SetActive(true)
else
local nExp = ConfigTable.GetData("BattlePassLevel", self.mapBattlePassInfo.nLevel + 1).Exp
NovaAPI.SetTMPText(self._mapNode.TMPProgress, string.format("%d/%d", self.mapBattlePassInfo.nExp, nExp))
self._mapNode.imgProgressBarFillMask.sizeDelta = Vector2(nExpBarLength * self.mapBattlePassInfo.nExp / nExp, nExpBarHeight)
self._mapNode.btnLevelDetail.gameObject:SetActive(true)
self._mapNode.TMPLevelMax.gameObject:SetActive(false)
end
self._mapNode.rt_RewardList:Refresh(self.mapBattlePassInfo.tbReward, self.mapBattlePassInfo.nCurMode > 0, self.mapBattlePassInfo.nLevel)
self._mapNode.rt_QuestList:Refresh(self.mapBattlePassInfo.nExpThisWeek, self.mapBattlePassInfo.nLevel)
if self._panel.bOpenPremium then
self.tbShowRewardIdx = {}
if beforeLevel ~= self.mapBattlePassInfo.nLevel then
for i = beforeLevel, self.mapBattlePassInfo.nLevel do
if #self.tbShowRewardIdx < 5 then
table.insert(self.tbShowRewardIdx, i)
end
end
else
for i = 1, 5 do
table.insert(self.tbShowRewardIdx, i)
end
end
self._mapNode.rtBuyPremiumBattlepass:Refresh(self.mapBattlePassInfo.nCurMode, self.mapBattlePassInfo.nSeasonId, self.mapBattlePassInfo.nVersion)
end
end
PlayerData.BattlePass:GetBattlePassInfo(callback)
end
function BattlePassCtrl:OnEvent_LevelUpPanelClose()
if #self.tbShowRewardIdx ~= 0 and self.curTog == 1 then
self._mapNode.rt_RewardList:PlayUnlockAnim(self.tbShowRewardIdx)
self.tbShowRewardIdx = {}
end
end
function BattlePassCtrl:OnEvent_BattlePassNeedRefresh()
EventManager.Hit(EventId.CloesCurPanel)
end
return BattlePassCtrl
@@ -0,0 +1,20 @@
local BattlePassPanel = class("BattlePassPanel", BasePanel)
BattlePassPanel._tbDefine = {
{
sPrefabPath = "BattlePass/BattlePassPanel.prefab",
sCtrlName = "Game.UI.BattlePass.BattlePassCtrl"
}
}
function BattlePassPanel:Awake()
end
function BattlePassPanel:OnEnable()
end
function BattlePassPanel:OnAfterEnter()
end
function BattlePassPanel:OnDisable()
end
function BattlePassPanel:OnDestroy()
end
function BattlePassPanel:OnRelease()
end
return BattlePassPanel
@@ -0,0 +1,67 @@
local BattlePassPopupSkinCtrl = class("BattlePassPopupSkinCtrl", BaseCtrl)
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
BattlePassPopupSkinCtrl._mapNodeConfig = {
Actor2D_PNG_Popup = {sComponentName = "Transform"},
imgBattlePassLogo = {sComponentName = "Image"},
TMPSeasonTImeTitle_popup = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_SeasonTImeTitle"
},
TMPSeasonTIme_popup = {sComponentName = "TMP_Text"},
TMPPopupHint = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_SkinHint"
},
txtBtnClosePopup = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_SkinHintOpenBP"
},
btnClosePopup = {
sComponentName = "UIButton",
callback = "OnBtnClick_Close"
}
}
BattlePassPopupSkinCtrl._mapEventConfig = {}
BattlePassPopupSkinCtrl._mapRedDotConfig = {}
function BattlePassPopupSkinCtrl:Awake()
self.animRoot = self.gameObject:GetComponent("Animator")
end
function BattlePassPopupSkinCtrl:FadeIn()
end
function BattlePassPopupSkinCtrl:FadeOut()
end
function BattlePassPopupSkinCtrl:OnEnable()
end
function BattlePassPopupSkinCtrl:OnDisable()
end
function BattlePassPopupSkinCtrl:OnDestroy()
end
function BattlePassPopupSkinCtrl:OnRelease()
end
function BattlePassPopupSkinCtrl:ShowPanel(mapBattlePassCfg)
self.gameObject:SetActive(true)
self.animRoot:Play("rtSkinPopup_in")
local nSkinId = mapBattlePassCfg.Cover
local mapSkinCfg = ConfigTable.GetData("CharacterSkin", nSkinId)
if mapSkinCfg ~= nil then
self._mapNode.Actor2D_PNG_Popup.gameObject:SetActive(true)
local nCharId = mapSkinCfg.CharId
Actor2DManager.SetActor2D_PNG(self._mapNode.Actor2D_PNG_Popup, PanelId.MainView, nCharId, nSkinId)
else
self._mapNode.Actor2D_PNG_Popup.gameObject:SetActive(false)
end
local nOpenTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(mapBattlePassCfg.StartTime)
local nCloseTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(mapBattlePassCfg.EndTime)
local sOpenTime = os.date("%Y.%m.%d", nOpenTime)
local sCloseTime = os.date("%Y.%m.%d", nCloseTime)
NovaAPI.SetTMPText(self._mapNode.TMPSeasonTIme_popup, string.format("%s-%s", sOpenTime, sCloseTime))
self:SetPngSprite(self._mapNode.imgBattlePassLogo, "Icon/ArtText/CharSkin_ArtText_" .. mapBattlePassCfg.Cover)
end
function BattlePassPopupSkinCtrl:OnBtnClick_Close()
local callback = function()
self.gameObject:SetActive(false)
end
self.animRoot:Play("rtSkinPopup_out")
self:AddTimer(1, 0.85, callback, true, true, true)
end
return BattlePassPopupSkinCtrl
@@ -0,0 +1,175 @@
local BattlePassPremiumBuyCtrl = class("BattlePassPremiumBuyCtrl", BaseCtrl)
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
BattlePassPremiumBuyCtrl._mapNodeConfig = {
srRewardListPremium = {
sComponentName = "LoopScrollView"
},
srRewardListSPremium = {
sComponentName = "LoopScrollView"
},
btnBuySPremium = {
sComponentName = "UIButton",
callback = "OnBtnClick_SPremium"
},
btnBuyPremium = {
sComponentName = "UIButton",
callback = "OnBtnClick_Premium"
},
txtBtnbtnBuyPremium = {sComponentName = "TMP_Text"},
txtBtnbtnBuySPremium = {sComponentName = "TMP_Text"},
txtBtnbtnBuySPremiumDiscount = {sComponentName = "TMP_Text"},
TMPUnlockSPremium = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassPremiumUnlocked"
},
TMPUnlockPremium = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassPremiumUnlocked"
},
TMPTitlePremium = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassRewardPremium"
},
TMPTitleSPremium = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassRewardLuxury"
},
TMPRewardDescPremium = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_SkinHint"
},
btnRewardDetailPremium = {
sComponentName = "UIButton",
callback = "OnBtnClick_OutfitInfo"
},
Actor2D_PNG_Buy = {sComponentName = "Transform"},
imgBattlePassLogo = {sComponentName = "Image"}
}
BattlePassPremiumBuyCtrl._mapEventConfig = {}
BattlePassPremiumBuyCtrl._mapRedDotConfig = {}
function BattlePassPremiumBuyCtrl:Awake()
self._mapGridCtrl = {}
end
function BattlePassPremiumBuyCtrl:FadeIn()
end
function BattlePassPremiumBuyCtrl:FadeOut()
end
function BattlePassPremiumBuyCtrl:OnEnable()
end
function BattlePassPremiumBuyCtrl:OnDisable()
self:UnbindAllCtrl()
end
function BattlePassPremiumBuyCtrl:OnDestroy()
end
function BattlePassPremiumBuyCtrl:OnRelease()
end
function BattlePassPremiumBuyCtrl:OpenPanel(nCurType, nSeasonId, nVersion)
self.nCurType = nCurType
self.nSeasonId = nSeasonId
self.nVersion = nVersion
self.gameObject:SetActive(true)
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.nSeasonId)
if mapBattlePassCfgData == nil then
return
end
self.tbRewardPremium = mapBattlePassCfgData.PremiumShowItems
self.tbRewardSPremium = mapBattlePassCfgData.LuxuryShowItems
self._mapNode.srRewardListPremium:Init(#self.tbRewardPremium, self, self.OnGridRefreshPremium, nil, true, nil)
self._mapNode.srRewardListSPremium:Init(#self.tbRewardSPremium + 1, self, self.OnGridRefreshSPremium, nil, true, nil)
self.sPremiumProductId = mapBattlePassCfgData.PremiumProductId
self.sLuxuryProductId = mapBattlePassCfgData.LuxuryProductId
self.sComplementaryProductId = mapBattlePassCfgData.ComplementaryProductId
NovaAPI.SetTMPText(self._mapNode.txtBtnbtnBuyPremium, tostring(mapBattlePassCfgData.PremiumShowPrice))
local nSPremiumPrice = nCurType == 0 and mapBattlePassCfgData.LuxuryPrice or mapBattlePassCfgData.ComplementaryPrice
self:SetPngSprite(self._mapNode.imgBattlePassLogo, "Icon/ArtText/CharSkin_ArtText_" .. mapBattlePassCfgData.Cover)
local sSPremiumPrice = nCurType == 0 and mapBattlePassCfgData.LuxuryShowPrice or mapBattlePassCfgData.ComplementaryShowPrice
NovaAPI.SetTMPText(self._mapNode.txtBtnbtnBuySPremium, tostring(sSPremiumPrice))
NovaAPI.SetTMPText(self._mapNode.txtBtnbtnBuySPremiumDiscount, tostring(mapBattlePassCfgData.OriginShowPrice))
self._mapNode.txtBtnbtnBuySPremiumDiscount.gameObject:SetActive(nCurType == 0)
self._mapNode.TMPUnlockPremium.gameObject:SetActive(1 <= nCurType)
self._mapNode.TMPUnlockSPremium.gameObject:SetActive(2 <= nCurType)
self._mapNode.btnBuyPremium.gameObject:SetActive(nCurType < 1)
self._mapNode.btnBuySPremium.gameObject:SetActive(nCurType < 2)
local nSkinId = mapBattlePassCfgData.Cover
local mapSkinCfg = ConfigTable.GetData("CharacterSkin", nSkinId)
if mapSkinCfg ~= nil then
self._mapNode.Actor2D_PNG_Buy.gameObject:SetActive(true)
local nCharId = mapSkinCfg.CharId
Actor2DManager.SetActor2D_PNG(self._mapNode.Actor2D_PNG_Buy, PanelId.MainView, nCharId, nSkinId)
else
self._mapNode.Actor2D_PNG_Buy.gameObject:SetActive(false)
end
end
function BattlePassPremiumBuyCtrl:Refresh(nCurType, nSeasonId, nVersion)
self.nCurType = nCurType
self.nSeasonId = nSeasonId
self.nVersion = nVersion
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.nSeasonId)
if mapBattlePassCfgData == nil then
printError("BattlePassCfgData missing:" .. self.nSeasonId)
return
end
NovaAPI.SetTMPText(self._mapNode.txtBtnbtnBuyPremium, tostring(mapBattlePassCfgData.PremiumShowPrice))
local nSPremiumPrice = nCurType == 0 and mapBattlePassCfgData.LuxuryPrice or mapBattlePassCfgData.ComplementaryPrice
local sSPremiumPrice = nCurType == 0 and mapBattlePassCfgData.LuxuryShowPrice or mapBattlePassCfgData.ComplementaryShowPrice
NovaAPI.SetTMPText(self._mapNode.txtBtnbtnBuySPremium, tostring(sSPremiumPrice))
NovaAPI.SetTMPText(self._mapNode.txtBtnbtnBuySPremiumDiscount, tostring(mapBattlePassCfgData.OriginShowPrice))
self._mapNode.txtBtnbtnBuySPremiumDiscount.gameObject:SetActive(nCurType == 0)
self._mapNode.TMPUnlockPremium.gameObject:SetActive(1 <= nCurType)
self._mapNode.TMPUnlockSPremium.gameObject:SetActive(2 <= nCurType)
self._mapNode.btnBuyPremium.gameObject:SetActive(nCurType < 1)
self._mapNode.btnBuySPremium.gameObject:SetActive(nCurType < 2)
end
function BattlePassPremiumBuyCtrl:UnbindAllCtrl()
for _, mapCtrl in pairs(self._mapGridCtrl) do
self:UnbindCtrlByNode(mapCtrl)
end
self._mapGridCtrl = {}
end
function BattlePassPremiumBuyCtrl:OnGridRefreshPremium(goGrid, gridIndex)
if self._mapGridCtrl[goGrid] == nil then
local mapCtrl = self:BindCtrlByNode(goGrid, "Game.UI.BattlePass.BattlePassBuyPremiumItemGridCtrl")
self._mapGridCtrl[goGrid] = mapCtrl
end
local nIdx = gridIndex
if nIdx == nil then
return
end
nIdx = nIdx + 1
self._mapGridCtrl[goGrid]:Refresh(self.tbRewardPremium[nIdx])
end
function BattlePassPremiumBuyCtrl:OnGridRefreshSPremium(goGrid, gridIndex)
if self._mapGridCtrl[goGrid] == nil then
local mapCtrl = self:BindCtrlByNode(goGrid, "Game.UI.BattlePass.BattlePassBuyPremiumItemGridCtrl")
self._mapGridCtrl[goGrid] = mapCtrl
end
local nIdx = gridIndex
if nIdx == nil then
return
end
self._mapGridCtrl[goGrid]:Refresh(self.tbRewardSPremium[nIdx])
end
function BattlePassPremiumBuyCtrl:ClosePanel()
self.gameObject:SetActive(false)
self:UnbindAllCtrl()
end
function BattlePassPremiumBuyCtrl:OnBtnClick_Premium()
PlayerData.Mall:BuyBattlePass(1, self.nVersion, self.sPremiumProductId, "BattlePassPremium")
end
function BattlePassPremiumBuyCtrl:OnBtnClick_SPremium()
local sId = self.nCurType == 0 and self.sLuxuryProductId or self.sComplementaryProductId
local sStatistical = self.nCurType == 0 and "BattlePassOrigin_Luxury" or "BattlePassOrigin_Complement"
PlayerData.Mall:BuyBattlePass(2, self.nVersion, sId, sStatistical)
end
function BattlePassPremiumBuyCtrl:OnBtnClick_OutfitInfo()
local mapBattlePassCfgData = ConfigTable.GetData("BattlePass", self.nSeasonId)
if mapBattlePassCfgData == nil then
return
end
local nSkinId = mapBattlePassCfgData.Cover
local func = function()
EventManager.Hit(EventId.OpenPanel, PanelId.SkinPreviewPanel, {nSkinId}, 1)
end
EventManager.Hit(EventId.SetTransition, 5, func)
end
return BattlePassPremiumBuyCtrl
@@ -0,0 +1,315 @@
local BattlePassQuestCtrl = class("BattlePassQuestCtrl", BaseCtrl)
BattlePassQuestCtrl._mapNodeConfig = {
srQuestDaily = {
sComponentName = "LoopScrollView"
},
srQuestWeekly = {
sComponentName = "LoopScrollView"
},
togDaily = {
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
},
togWeek = {
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
},
btnDaily = {
sNodeName = "togDaily",
sComponentName = "UIButton",
callback = "OnBtnClick_Daily"
},
btnWeek = {
sNodeName = "togWeek",
sComponentName = "UIButton",
callback = "OnBtnClick_Weekly"
},
btnAllReceive = {
sComponentName = "UIButton",
callback = "OnBtnClick_AllReceive"
},
TMPWeekLimit = {sComponentName = "TMP_Text"},
txtBtnAllReceive = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassReceiveAll"
},
redDotDailyQuest = {},
redDotWeekQuest = {}
}
BattlePassQuestCtrl._mapEventConfig = {
BattlePassQuestReceive = "OnEvent_QuestReceive",
ShowQuestReward = "ShowQuestReward"
}
BattlePassQuestCtrl._mapRedDotConfig = {
[RedDotDefine.BattlePass_Quest_Daily] = {
sNodeName = "redDotDailyQuest"
},
[RedDotDefine.BattlePass_Quest_Week] = {
sNodeName = "redDotWeekQuest"
}
}
function BattlePassQuestCtrl:Awake()
self.mapQuestsGrids = {}
end
function BattlePassQuestCtrl:FadeIn()
end
function BattlePassQuestCtrl:FadeOut()
end
function BattlePassQuestCtrl:OnEnable()
self._mapNode.togDaily:SetText(ConfigTable.GetUIText("BattlePassRewardDaily"))
if self._panel.questTab == 1 then
self.curTab = 1
self._mapNode.togDaily:SetDefault(true)
self._mapNode.togWeek:SetDefault(false)
self._mapNode.srQuestDaily.gameObject:SetActive(true)
self._mapNode.srQuestWeekly.gameObject:SetActive(false)
else
self.curTab = 2
self._mapNode.togDaily:SetDefault(false)
self._mapNode.togWeek:SetDefault(true)
self._mapNode.srQuestDaily.gameObject:SetActive(false)
self._mapNode.srQuestWeekly.gameObject:SetActive(true)
end
self.togRefreshTimer = nil
end
function BattlePassQuestCtrl:OnDisable()
self:UnbindAllCtrl()
if self.togRefreshTimer ~= nil then
self.togRefreshTimer:Cancel(false)
end
end
function BattlePassQuestCtrl:OnDestroy()
end
function BattlePassQuestCtrl:OnRelease()
end
function BattlePassQuestCtrl:Refresh(nExpThisWeek, nCurLevel)
local mapDailyQuest, mapWeeklyQuest = PlayerData.Quest:GetBattlePassQuestData()
local nExpLimit = ConfigTable.GetConfigNumber("BattlePassWeeklyExpLimit")
local bMaxLevel = ConfigTable.GetData("BattlePassLevel", nCurLevel + 1) == nil
if bMaxLevel then
NovaAPI.SetTMPText(self._mapNode.TMPWeekLimit, ConfigTable.GetUIText("BattlePassQusetMax"))
else
NovaAPI.SetTMPText(self._mapNode.TMPWeekLimit, orderedFormat(ConfigTable.GetUIText("BattlePassQusetExpLimit"), nExpThisWeek, nExpLimit))
end
local bFullExp = nExpThisWeek >= nExpLimit
self.tbDaily = {}
self.tbWeekly = {}
local statusOrder = {
[0] = 1,
[1] = 2,
[2] = 0
}
local sort = function(a, b)
if a.nStatus ~= b.nStatus then
return statusOrder[a.nStatus] > statusOrder[b.nStatus]
end
return a.nTid < b.nTid
end
local bHasComplete = false
local nIdx = 0
for _, mapQuestData in pairs(mapDailyQuest) do
if mapQuestData.nStatus == 1 then
bHasComplete = true
nIdx = 1
end
table.insert(self.tbDaily, mapQuestData)
end
for _, mapQuestData in pairs(mapWeeklyQuest) do
if mapQuestData.nStatus == 1 then
bHasComplete = true
if nIdx < 1 then
nIdx = 2
end
end
table.insert(self.tbWeekly, mapQuestData)
end
self:SetWeeklyTogText()
table.sort(self.tbDaily, sort)
table.sort(self.tbWeekly, sort)
self.enableQuest = not bMaxLevel and not bFullExp
self._mapNode.srQuestDaily:Init(#self.tbDaily, self, self.OnGridRefreshDaily)
self._mapNode.srQuestWeekly:Init(#self.tbWeekly, self, self.OnGridRefreshWeekly)
self._mapNode.btnAllReceive.gameObject:SetActive(bHasComplete and not bMaxLevel and not bFullExp)
if self.togRefreshTimer == nil then
self.togRefreshTimer = self:AddTimer(0, 60, "SetWeeklyTogText", true, true, true, nil)
end
return bHasComplete, nIdx
end
function BattlePassQuestCtrl:SetToggle(nIdx)
if nIdx == 1 then
self.curTab = 1
self._mapNode.togDaily:SetDefault(true)
self._mapNode.togWeek:SetDefault(false)
self._mapNode.srQuestDaily.gameObject:SetActive(true)
self._mapNode.srQuestWeekly.gameObject:SetActive(false)
else
self.curTab = 2
self._mapNode.togDaily:SetDefault(false)
self._mapNode.togWeek:SetDefault(true)
self._mapNode.srQuestDaily.gameObject:SetActive(false)
self._mapNode.srQuestWeekly.gameObject:SetActive(true)
end
end
function BattlePassQuestCtrl:UnbindAllCtrl()
for _, mapCtrl in pairs(self.mapQuestsGrids) do
self:UnbindCtrlByNode(mapCtrl)
end
self.mapQuestsGrids = {}
end
function BattlePassQuestCtrl:PlayListInAnim()
if self.curTab == 1 then
self._mapNode.srQuestDaily:SetAnim(0.07)
self._mapNode.srQuestDaily:Init(#self.tbDaily, self, self.OnGridRefreshDaily)
else
self._mapNode.srQuestWeekly:SetAnim(0.07)
self._mapNode.srQuestWeekly:Init(#self.tbWeekly, self, self.OnGridRefreshWeekly)
end
EventManager.Hit(EventId.TemporaryBlockInput, 0.5)
end
function BattlePassQuestCtrl:OnGridRefreshDaily(goGrid, gridIndex)
if self.mapQuestsGrids[goGrid] == nil then
self.mapQuestsGrids[goGrid] = self:BindCtrlByNode(goGrid, "Game.UI.BattlePass.BattlePassQusetGridCtrl")
end
local nIdx = gridIndex + 1
local mapQuestData = self.tbDaily[nIdx]
if mapQuestData == nil then
printError("GuideQuestData missing" .. nIdx)
self.mapQuestsGrids[goGrid]:Refresh(nil, nil)
return
end
local mapQuestCfgData = ConfigTable.GetData("BattlePassQuest", mapQuestData.nTid)
self.mapQuestsGrids[goGrid]:Refresh(mapQuestData, mapQuestCfgData, self.enableQuest)
end
function BattlePassQuestCtrl:OnGridRefreshWeekly(goGrid, gridIndex)
if self.mapQuestsGrids[goGrid] == nil then
self.mapQuestsGrids[goGrid] = self:BindCtrlByNode(goGrid, "Game.UI.BattlePass.BattlePassQusetGridCtrl")
end
local nIdx = gridIndex + 1
local mapQuestData = self.tbWeekly[nIdx]
if mapQuestData == nil then
printError("GuideQuestData missing" .. nIdx)
self.mapQuestsGrids[goGrid]:Refresh(nil, nil)
return
end
local mapQuestCfgData = ConfigTable.GetData("BattlePassQuest", mapQuestData.nTid)
self.mapQuestsGrids[goGrid]:Refresh(mapQuestData, mapQuestCfgData, self.enableQuest)
end
function BattlePassQuestCtrl:OnEvent_QuestReceive(mapData)
local mapDailyQuest, mapWeeklyQuest = PlayerData.Quest:GetBattlePassQuestData()
local nExpLimit = ConfigTable.GetConfigNumber("BattlePassWeeklyExpLimit")
local bMaxLevel = ConfigTable.GetData("BattlePassLevel", mapData.Level + 1) == nil
local bFullExp = nExpLimit <= mapData.ExpThisWeek
if bMaxLevel then
NovaAPI.SetTMPText(self._mapNode.TMPWeekLimit, ConfigTable.GetUIText("BattlePassQusetMax"))
else
NovaAPI.SetTMPText(self._mapNode.TMPWeekLimit, orderedFormat(ConfigTable.GetUIText("BattlePassQusetExpLimit"), mapData.ExpThisWeek, nExpLimit))
end
self.tbDaily = {}
self.tbWeekly = {}
local statusOrder = {
[0] = 1,
[1] = 2,
[2] = 0
}
local sort = function(a, b)
if a.nStatus ~= b.nStatus then
return statusOrder[a.nStatus] > statusOrder[b.nStatus]
end
return a.nTid < b.nTid
end
local bHasComplete = false
for _, mapQuestData in pairs(mapDailyQuest) do
table.insert(self.tbDaily, mapQuestData)
if mapQuestData.nStatus == 1 then
bHasComplete = true
end
end
for _, mapQuestData in pairs(mapWeeklyQuest) do
table.insert(self.tbWeekly, mapQuestData)
if mapQuestData.nStatus == 1 then
bHasComplete = true
end
end
local mapWeeklyQuestData = self.tbWeekly[1]
if mapWeeklyQuestData ~= nil then
local nBattlePassEndTS = PlayerData.BattlePass.nDeadlineTS
if nBattlePassEndTS < 1 then
nBattlePassEndTS = mapWeeklyQuestData.nExpire
end
local curTime = CS.ClientManager.Instance.serverTimeStamp
local sumTime = math.min(mapWeeklyQuestData.nExpire, nBattlePassEndTS) - curTime
local nDay = math.floor(sumTime / 86400)
local nHour = math.floor((sumTime - nDay * 86400) / 3600)
local nHourReal = (sumTime - nDay * 86400) / 3600
if 0 < nDay then
self._mapNode.togWeek:SetText(orderedFormat(ConfigTable.GetUIText("BattlePassQusetWeekly"), nDay, nHour))
elseif 1 < nHourReal then
self._mapNode.togWeek:SetText(orderedFormat(ConfigTable.GetUIText("BattlePassQusetWeeklyHour"), nHour))
else
self._mapNode.togWeek:SetText(ConfigTable.GetUIText("Depot_LeftTime_LessThenHour"))
end
else
self._mapNode.togWeek.gameObject:SetActive(false)
end
table.sort(self.tbDaily, sort)
table.sort(self.tbWeekly, sort)
self.enableQuest = not bMaxLevel and not bFullExp
self._mapNode.btnAllReceive.gameObject:SetActive(bHasComplete and not bMaxLevel and not bFullExp)
self._mapNode.srQuestDaily:Init(#self.tbDaily, self, self.OnGridRefreshDaily, nil, true, nil)
self._mapNode.srQuestWeekly:Init(#self.tbWeekly, self, self.OnGridRefreshWeekly, nil, true, nil)
end
function BattlePassQuestCtrl:OnBtnClick_Daily(btn)
self._panel.questTab = 1
if self.curTab == 1 then
return
end
self._mapNode.togDaily:SetTrigger(true)
self._mapNode.togWeek:SetTrigger(false)
self.curTab = 1
self._mapNode.srQuestDaily.gameObject:SetActive(true)
self._mapNode.srQuestWeekly.gameObject:SetActive(false)
end
function BattlePassQuestCtrl:OnBtnClick_Weekly(btn)
self._panel.questTab = 2
if self.curTab == 2 then
return
end
self._mapNode.togDaily:SetTrigger(false)
self._mapNode.togWeek:SetTrigger(true)
self.curTab = 2
self._mapNode.srQuestDaily.gameObject:SetActive(false)
self._mapNode.srQuestWeekly.gameObject:SetActive(true)
end
function BattlePassQuestCtrl:OnBtnClick_AllReceive(btn)
PlayerData.Quest:ReceiveBattlePassQuestData(0, nil)
end
function BattlePassQuestCtrl:ShowQuestReward(grid)
local nIdx = tonumber(grid.name)
if self.curTab == 1 then
self._mapNode.srQuestDaily:SetScrollGridPos(nIdx, 0, 1)
else
self._mapNode.srQuestWeekly:SetScrollGridPos(nIdx, 0, 1)
end
end
function BattlePassQuestCtrl:SetWeeklyTogText()
local mapWeeklyQuestData = self.tbWeekly[1]
if mapWeeklyQuestData ~= nil then
local nBattlePassEndTS = PlayerData.BattlePass.nDeadlineTS
if nBattlePassEndTS < 1 then
nBattlePassEndTS = mapWeeklyQuestData.nExpire
end
local curTime = CS.ClientManager.Instance.serverTimeStamp
local sumTime = math.min(mapWeeklyQuestData.nExpire, nBattlePassEndTS) - curTime
local nDay = math.floor(sumTime / 86400)
local nHour = math.floor((sumTime - nDay * 86400) / 3600)
local nHourReal = (sumTime - nDay * 86400) / 3600
if 0 < nDay then
self._mapNode.togWeek:SetText(orderedFormat(ConfigTable.GetUIText("BattlePassQusetWeekly"), nDay, nHour))
elseif 1 < nHourReal then
self._mapNode.togWeek:SetText(orderedFormat(ConfigTable.GetUIText("BattlePassQusetWeeklyHour"), nHour))
else
self._mapNode.togWeek:SetText(ConfigTable.GetUIText("Depot_LeftTime_LessThenHour"))
end
else
self._mapNode.togWeek.gameObject:SetActive(false)
end
end
return BattlePassQuestCtrl
@@ -0,0 +1,108 @@
local BattlePassQusetGridCtrl = class("BattlePassQusetGridCtrl", BaseCtrl)
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
local totalLength = 755
local totalHeight = 37
local JumpUtil = require("Game.Common.Utils.JumpUtil")
BattlePassQusetGridCtrl._mapNodeConfig = {
rtTitle = {
sComponentName = "RectTransform"
},
TMPTitle = {sComponentName = "TMP_Text"},
TMPUncomplete = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_undone"
},
txtBtnReceive = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_Receive"
},
txtBtnJump = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_JumpTo"
},
rtBarFill = {
sComponentName = "RectTransform"
},
TMPProcess = {sComponentName = "TMP_Text"},
btnReceive = {
sComponentName = "UIButton",
callback = "OnBtnClick_Receive"
},
btnJump = {
sComponentName = "UIButton",
callback = "OnBtnClick_JumpTo"
},
rtReward = {
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
imgComplete = {},
imgCompleteMask = {},
btnReward = {
sComponentName = "UIButton",
callback = "OnBtnClick_Reward"
},
TMPClose = {
sComponentName = "TMP_Text",
sLanguageId = "Quest_Closed"
}
}
BattlePassQusetGridCtrl._mapEventConfig = {}
function BattlePassQusetGridCtrl:OnEnable()
self.gameObject:SetActive(false)
local waitOpen = function()
self.gameObject:SetActive(true)
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTitle)
end
cs_coroutine.start(waitOpen)
end
function BattlePassQusetGridCtrl:Refresh(mapQuest, mapQuestCfgData, bEnable)
if mapQuest == nil then
self.gameObject:SetActive(false)
return
end
if mapQuestCfgData == nil then
printError("quest data missing:" .. mapQuest.nTid)
self.gameObject:SetActive(false)
return
end
self.mapQuestCfgData = mapQuestCfgData
self.mapQuest = mapQuest
NovaAPI.SetTMPText(self._mapNode.TMPTitle, mapQuestCfgData.Title)
self.nRewardId = 22
self._mapNode.rtReward:SetItem(self.nRewardId, nil, mapQuestCfgData.Exp, nil, nil, nil, nil, true)
if not bEnable then
NovaAPI.SetTMPText(self._mapNode.TMPProcess, "-/-")
elseif mapQuest.nStatus ~= 2 then
NovaAPI.SetTMPText(self._mapNode.TMPProcess, string.format("%d/%d", mapQuest.nCurProgress, mapQuest.nGoal))
else
NovaAPI.SetTMPText(self._mapNode.TMPProcess, ConfigTable.GetUIText("Quest_Complete"))
end
if not bEnable then
self._mapNode.rtBarFill.sizeDelta = Vector2(0, totalHeight)
else
self._mapNode.rtBarFill.sizeDelta = Vector2(mapQuest.nCurProgress / mapQuest.nGoal * totalLength, totalHeight)
end
self._mapNode.imgComplete:SetActive(mapQuest.nStatus == 2 and bEnable)
self._mapNode.imgCompleteMask:SetActive(mapQuest.nStatus == 2 or not bEnable)
self._mapNode.TMPUncomplete.gameObject:SetActive(mapQuest.nStatus == 0 and mapQuestCfgData.JumpTo == 0 and bEnable)
self._mapNode.btnJump.gameObject:SetActive(mapQuest.nStatus == 0 and mapQuestCfgData.JumpTo ~= 0 and bEnable)
self._mapNode.btnReceive.gameObject:SetActive(mapQuest.nStatus == 1 and bEnable)
self._mapNode.TMPClose.gameObject:SetActive(not bEnable)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTitle)
end
function BattlePassQusetGridCtrl:ShowItemDetail(id, rtIcon)
UTILS.ClickItemGridWithTips(id, rtIcon.transform, true, false, false)
end
function BattlePassQusetGridCtrl:OnBtnClick_Receive()
PlayerData.Quest:ReceiveBattlePassQuestData(self.mapQuest.nTid, nil)
end
function BattlePassQusetGridCtrl:OnBtnClick_JumpTo()
local nJumptoId = self.mapQuestCfgData.JumpTo
JumpUtil.JumpTo(nJumptoId)
end
function BattlePassQusetGridCtrl:OnBtnClick_Reward()
EventManager.Hit("ShowQuestReward", self.gameObject)
self:ShowItemDetail(self.nRewardId, self._mapNode.btnReward)
end
return BattlePassQusetGridCtrl
@@ -0,0 +1,148 @@
local BattlePassRewardCtrl = class("BattlePassRewardCtrl", BaseCtrl)
BattlePassRewardCtrl._mapNodeConfig = {
svRewardList = {
sComponentName = "LoopScrollView"
},
imgPrevReward = {
sCtrlName = "Game.UI.BattlePass.BattlePassRewardGridCtrl"
},
iimgIconTitleVipLock = {},
btnAllReceive = {
sComponentName = "UIButton",
callback = "OnBtnClick_AllReceive"
},
Content = {sComponentName = "Transform"},
TMPTitleVip = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassRewardPremium"
},
TMPTitleBase = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassRewardNormal"
},
txtbtnAllReceive = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePassReceiveAll"
},
UIParticleVipIcon = {}
}
BattlePassRewardCtrl._mapEventConfig = {}
BattlePassRewardCtrl._mapRedDotConfig = {}
function BattlePassRewardCtrl:Awake()
self._mapGrid = {}
end
function BattlePassRewardCtrl:FadeIn()
end
function BattlePassRewardCtrl:FadeOut()
end
function BattlePassRewardCtrl:OnEnable()
self.anim = self.gameObject:GetComponent("Animator")
end
function BattlePassRewardCtrl:OnDisable()
self:UnbindAllCtrl()
end
function BattlePassRewardCtrl:OnDestroy()
end
function BattlePassRewardCtrl:OnRelease()
end
function BattlePassRewardCtrl:Refresh(tbReward, bPremium, nBattlePassLevel)
self.tbReward = tbReward
self.bPremium = bPremium
self.nBattlePassLevel = nBattlePassLevel
self.tbFocus = {}
self.curFocus = 0
self.bAllReceive = false
for idx, mapReward in pairs(tbReward) do
if mapReward.bFocus then
table.insert(self.tbFocus, idx)
end
if not mapReward.bNormalReceive and idx <= nBattlePassLevel then
self.bAllReceive = true
end
if self.bPremium and not mapReward.bVipReceive and idx <= nBattlePassLevel then
self.bAllReceive = true
end
end
self._mapNode.UIParticleVipIcon:SetActive(bPremium)
self._mapNode.iimgIconTitleVipLock:SetActive(not bPremium)
self._mapNode.svRewardList:Init(#self.tbReward, self, self.OnGridRefresh, nil, true, nil)
self._mapNode.btnAllReceive.gameObject:SetActive(self.bAllReceive)
end
function BattlePassRewardCtrl:SetLevelPos()
if self.nBattlePassLevel ~= nil then
self._mapNode.svRewardList:SetScrollGridPos(self.nBattlePassLevel - 1)
end
end
function BattlePassRewardCtrl:PlayUnlockAnim(tbShowRewardIdx)
if 0 < #tbShowRewardIdx then
local nFirstIdx = tbShowRewardIdx[1]
self._mapNode.svRewardList:SetScrollGridPos(nFirstIdx - 1, 0.1, 0)
local wait = function()
local nDelay = 0
for _, nIdx in ipairs(tbShowRewardIdx) do
local nName = tostring(nIdx - 1)
local rtItem = self._mapNode.Content:Find(nName)
if rtItem ~= nil and self._mapGrid[rtItem.gameObject] ~= nil then
self._mapGrid[rtItem.gameObject]:BattlePassRewardShowEnableEffect(self.bPremium, nDelay)
nDelay = nDelay + 0.1
end
end
self._mapNode.imgPrevReward:BattlePassRewardShowEnableEffect(self.bPremium, nDelay)
end
self:AddTimer(1, 0.1, wait, true, true, true, nil)
EventManager.Hit(EventId.TemporaryBlockInput, 0.6)
end
end
function BattlePassRewardCtrl:UnbindAllCtrl()
for _, mapCtrl in pairs(self._mapGrid) do
self:UnbindCtrlByNode(mapCtrl)
end
self._mapGrid = {}
end
function BattlePassRewardCtrl:OnGridRefresh(goGrid, gridIndex)
if self._mapGrid[goGrid] == nil then
local mapCtrl = self:BindCtrlByNode(goGrid, "Game.UI.BattlePass.BattlePassRewardGridCtrl")
self._mapGrid[goGrid] = mapCtrl
end
local nIdx = gridIndex + 1
local rewardData = self.tbReward[nIdx]
if rewardData ~= nil then
self._mapGrid[goGrid]:Refresh(rewardData, self.bPremium, self.nBattlePassLevel)
end
local nMaxIdx = self._mapNode.svRewardList:GetMaxUseGridIndex()
if #self.tbFocus > 0 then
for i = 1, #self.tbFocus do
if nMaxIdx < self.tbFocus[i] then
if self.tbFocus[i] ~= self.curFocus then
local rewardDataPrev = self.tbReward[self.tbFocus[i]]
if rewardDataPrev ~= nil then
self._mapNode.imgPrevReward:Refresh(rewardDataPrev, self.bPremium, self.nBattlePassLevel)
self.curFocus = self.tbFocus[i]
end
end
return
end
end
local nIdxPrev = #self.tbFocus
if self.tbFocus[nIdxPrev] ~= self.curFocus then
local rewardDataPrev = self.tbReward[nIdxPrev]
if rewardDataPrev ~= nil then
self._mapNode.imgPrevReward:Refresh(rewardDataPrev, self.bPremium, self.nBattlePassLevel)
self.curFocus = self.tbFocus[nIdxPrev]
end
end
else
self._mapNode.imgPrevReward.gameObject:SetActive(false)
end
end
function BattlePassRewardCtrl:OnBtnClick_AllReceive()
local callback = function()
end
PlayerData.BattlePass:NetMsg_BattlePassRewardReceive(true, 0, false, callback)
end
function BattlePassRewardCtrl:PlayInAnim()
if self.anim ~= nil then
self.anim:Play("rt_RewardList_switch")
end
end
return BattlePassRewardCtrl
@@ -0,0 +1,138 @@
local BattlePassRewardGridCtrl = class("BattlePassRewardGridCtrl", BaseCtrl)
BattlePassRewardGridCtrl._mapNodeConfig = {
TMPGridLevel = {sComponentName = "TMP_Text"},
btnItemNormal = {
sComponentName = "UIButton",
callback = "OnBtnClick_NormalItem"
},
btnItemVip1 = {
sComponentName = "UIButton",
callback = "OnBtnClick_VipItem1"
},
btnItemVip2 = {
sComponentName = "UIButton",
callback = "OnBtnClick_VipItem2"
},
btnReceIveNormal = {
sComponentName = "UIButton",
callback = "OnBtnClick_NormalReward"
},
btnReceIveVip = {
sComponentName = "UIButton",
callback = "OnBtnClick_VipReward"
},
tcRewardItemNormal = {
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
tcRewardItemVip = {
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl",
nCount = 2
},
imgLockNormalVip = {nCount = 2},
imgLockNormalNormal = {},
tcRewardItemFXNormal = {},
tcRewardItemFXVip = {nCount = 2},
tcRewardItemReplaceVip = {nCount = 2, sComponentName = "Animator"},
tcRewardItemReplaceNormal = {sComponentName = "Animator"}
}
BattlePassRewardGridCtrl._mapEventConfig = {}
BattlePassRewardGridCtrl._mapRedDotConfig = {}
function BattlePassRewardGridCtrl:Awake()
end
function BattlePassRewardGridCtrl:FadeIn()
end
function BattlePassRewardGridCtrl:FadeOut()
end
function BattlePassRewardGridCtrl:OnEnable()
end
function BattlePassRewardGridCtrl:OnDisable()
end
function BattlePassRewardGridCtrl:OnDestroy()
end
function BattlePassRewardGridCtrl:OnRelease()
end
function BattlePassRewardGridCtrl:Refresh(mapReward, bPremium, nBattlePassLevel)
self.mapReward = mapReward
self.nBattlePassLevel = nBattlePassLevel
NovaAPI.SetTMPText(self._mapNode.TMPGridLevel, orderedFormat(ConfigTable.GetUIText("BattlePass_RewardLevel"), mapReward.nLevel))
if mapReward.nNormalTid ~= 0 then
self._mapNode.btnItemNormal.gameObject:SetActive(true)
self._mapNode.tcRewardItemNormal:SetItem(mapReward.nNormalTid, nil, mapReward.nNormalQty, nil, mapReward.bNormalReceive, false, false, false, false)
self._mapNode.imgLockNormalNormal:SetActive(nBattlePassLevel < mapReward.nLevel)
else
self._mapNode.btnItemNormal.gameObject:SetActive(false)
end
if mapReward.nVipTid1 ~= 0 then
self._mapNode.btnItemVip1.gameObject:SetActive(true)
self._mapNode.tcRewardItemVip[1]:SetItem(mapReward.nVipTid1, nil, mapReward.nVipQty1, nil, mapReward.bVipReceive, false, false, false, false)
self._mapNode.imgLockNormalVip[1]:SetActive(nBattlePassLevel < mapReward.nLevel or not bPremium)
else
self._mapNode.btnItemVip1.gameObject:SetActive(false)
end
if mapReward.nVipTid2 ~= 0 then
self._mapNode.btnItemVip2.gameObject:SetActive(true)
self._mapNode.tcRewardItemVip[2]:SetItem(mapReward.nVipTid2, nil, mapReward.nVipQty2, nil, mapReward.bVipReceive, false, false, false, false)
self._mapNode.imgLockNormalVip[2]:SetActive(nBattlePassLevel < mapReward.nLevel or not bPremium)
else
self._mapNode.btnItemVip2.gameObject:SetActive(false)
end
self._mapNode.tcRewardItemFXNormal.gameObject:SetActive(nBattlePassLevel >= mapReward.nLevel and not mapReward.bNormalReceive)
self._mapNode.tcRewardItemFXVip[1].gameObject:SetActive(nBattlePassLevel >= mapReward.nLevel and not mapReward.bVipReceive and bPremium and (mapReward.nVipTid1 ~= 0 or mapReward.nVipTid2 ~= 0))
self._mapNode.tcRewardItemFXVip[2].gameObject:SetActive(nBattlePassLevel >= mapReward.nLevel and not mapReward.bVipReceive and bPremium and (mapReward.nVipTid1 ~= 0 or mapReward.nVipTid2 ~= 0))
self._mapNode.btnReceIveNormal.gameObject:SetActive(nBattlePassLevel >= mapReward.nLevel and not mapReward.bNormalReceive)
self._mapNode.btnReceIveVip.gameObject:SetActive(nBattlePassLevel >= mapReward.nLevel and not mapReward.bVipReceive and bPremium and (mapReward.nVipTid1 ~= 0 or mapReward.nVipTid2 ~= 0))
end
function BattlePassRewardGridCtrl:OnBtnClick_NormalReward()
local callback = function()
end
PlayerData.BattlePass:NetMsg_BattlePassRewardReceive(false, self.mapReward.nLevel, true, callback)
end
function BattlePassRewardGridCtrl:OnBtnClick_VipReward()
local callback = function()
end
PlayerData.BattlePass:NetMsg_BattlePassRewardReceive(false, self.mapReward.nLevel, false, callback)
end
function BattlePassRewardGridCtrl:OnBtnClick_NormalItem()
if self.mapReward == nil then
return
end
if self.mapReward.nNormalTid ~= 0 then
UTILS.ClickItemGridWithTips(self.mapReward.nNormalTid, self._mapNode.tcRewardItemNormal.gameObject.transform, true, true, false)
end
end
function BattlePassRewardGridCtrl:OnBtnClick_VipItem1()
if self.mapReward == nil then
return
end
if self.mapReward.nVipTid1 ~= 0 then
UTILS.ClickItemGridWithTips(self.mapReward.nVipTid1, self._mapNode.tcRewardItemVip[1].gameObject.transform, true, true, false)
end
end
function BattlePassRewardGridCtrl:OnBtnClick_VipItem2()
if self.mapReward == nil then
return
end
if self.mapReward.nVipTid2 ~= 0 then
UTILS.ClickItemGridWithTips(self.mapReward.nVipTid2, self._mapNode.tcRewardItemVip[2].gameObject.transform, true, true, false)
end
end
function BattlePassRewardGridCtrl:BattlePassRewardShowEnableEffect(bPremium, nDelay)
local waitDelay = function()
if bPremium then
local bEnableVip1 = self.nBattlePassLevel >= self.mapReward.nLevel and not self.mapReward.bVipReceive and bPremium and self.mapReward.nVipTid1 ~= 0
local bEnableVip2 = self.nBattlePassLevel >= self.mapReward.nLevel and not self.mapReward.bVipReceive and bPremium and self.mapReward.nVipTid2 ~= 0
if bEnableVip1 then
self._mapNode.tcRewardItemReplaceVip[1]:Play("tcRewardItemReplace_in")
end
if bEnableVip2 then
self._mapNode.tcRewardItemReplaceVip[2]:Play("tcRewardItemReplace_in")
end
end
local bNormal = self.nBattlePassLevel >= self.mapReward.nLevel and not self.mapReward.bNormalReceive
if bNormal then
self._mapNode.tcRewardItemReplaceNormal:Play("tcRewardItemReplace_in")
end
end
self:AddTimer(1, nDelay, waitDelay, true, true, true, nil)
end
return BattlePassRewardGridCtrl
@@ -0,0 +1,77 @@
local BattlePassUpgradeCtrl = class("BattlePassUpgradeCtrl", BaseCtrl)
BattlePassUpgradeCtrl._mapNodeConfig = {
imgBlurredBg = {},
btnMaskClose = {
sComponentName = "UIButton",
callback = "OnBtnClick_Close"
},
goRoot = {
sNodeName = "----SafeAreaRoot----"
},
txtRankNum = {sComponentName = "TMP_Text"},
txtRankText = {
sComponentName = "TMP_Text",
sLanguageId = "MainView_RANK"
},
txtHint = {
sComponentName = "TMP_Text",
sLanguageId = "BattlePass_Upgrade_Hint"
}
}
BattlePassUpgradeCtrl._mapEventConfig = {}
function BattlePassUpgradeCtrl:SetOldWorldClass()
local nOldBattlePassClass = self.mapBattlePassClass.nOldLevel
local nOldBattlePassExp = self.mapBattlePassClass.nOldExp
local mapOldCfg = ConfigTable.GetData("BattlePassLevel", nOldBattlePassClass + 1)
local nOldFullExp = 0
if mapOldCfg then
nOldFullExp = mapOldCfg.Exp
end
NovaAPI.SetTMPText(self._mapNode.txtRankNum, nOldBattlePassClass)
local nBattlePassClass = self.mapBattlePassClass.nLevel
local nCurExp = self.mapBattlePassClass.nExp
local mapCfg = ConfigTable.GetData("BattlePassLevel", nBattlePassClass + 1)
local nFullExp = 0
if mapCfg then
nFullExp = mapCfg.Exp
end
local callback = function()
self:Refresh()
end
self:AddTimer(1, 0.6, callback, true, true, true)
end
function BattlePassUpgradeCtrl:Refresh()
local nBattlePassClass = self.mapBattlePassClass.nLevel
NovaAPI.SetTMPText(self._mapNode.txtRankNum, nBattlePassClass)
end
function BattlePassUpgradeCtrl:FadeIn()
EventManager.Hit(EventId.TemporaryBlockInput, 0.5)
end
function BattlePassUpgradeCtrl:Awake()
end
function BattlePassUpgradeCtrl:OnEnable()
local tbParam = self:GetPanelParam()
if nil ~= tbParam then
self.cbClose = tbParam[1]
self.mapBattlePassClass = tbParam[2]
end
self._mapNode.imgBlurredBg.gameObject:SetActive(true)
self._mapNode.goRoot.gameObject:SetActive(false)
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self._mapNode.goRoot.gameObject:SetActive(true)
self:SetOldWorldClass()
end
cs_coroutine.start(wait)
end
function BattlePassUpgradeCtrl:OnDisable()
end
function BattlePassUpgradeCtrl:OnDestroy()
end
function BattlePassUpgradeCtrl:OnBtnClick_Close()
EventManager.Hit(EventId.ClosePanel, PanelId.BattlePassUpgrade)
if nil ~= self.cbClose then
self.cbClose()
end
end
return BattlePassUpgradeCtrl
@@ -0,0 +1,18 @@
local BattlePassUpgradePanel = class("BattlePassUpgradePanel", BasePanel)
BattlePassUpgradePanel._bIsMainPanel = false
BattlePassUpgradePanel._sSortingLayerName = AllEnum.SortingLayerName.UI_Top
BattlePassUpgradePanel._tbDefine = {
{
sPrefabPath = "BattlePass/BattlePassUpgradePanel.prefab",
sCtrlName = "Game.UI.BattlePass.BattlePassUpgradeCtrl"
}
}
function BattlePassUpgradePanel:Awake()
end
function BattlePassUpgradePanel:OnEnable()
end
function BattlePassUpgradePanel:OnDisable()
end
function BattlePassUpgradePanel:OnDestroy()
end
return BattlePassUpgradePanel
+530
View File
@@ -0,0 +1,530 @@
local SkinPreviewCtrl = class("SkinPreviewCtrl", BaseCtrl)
local PlayerCharData = PlayerData.Char
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local SkinData = require("GameCore.Data.DataClass.SkinData")
local Animator = CS.UnityEngine.Animator
local typeof = typeof
local ClientManager = CS.ClientManager.Instance
SkinPreviewCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
rawImgActor2D = {
sNodeName = "----Actor2D----",
sComponentName = "RawImage"
},
rtRawImgActor2D = {
sNodeName = "----Actor2D----",
sComponentName = "RectTransform"
},
eventSkinDrag = {
sNodeName = "btnSkin",
sComponentName = "UIDrag",
callback = "OnUIDrag_Drag"
},
eventSkinZoom = {
sNodeName = "btnSkin",
sComponentName = "UIZoom",
callback = "OnUIZoom_Skin"
},
btnSkin = {
sComponentName = "Button",
callback = "OnBtnClick_Skin"
},
goSkinDesc = {},
txtSkinDesc = {sComponentName = "TMP_Text"},
goTheme = {},
imgTheme = {sComponentName = "Image"},
txtTheme = {sComponentName = "TMP_Text"},
goPreview = {},
btnFullScene = {
sComponentName = "UIButton",
callback = "OnBtnClick_FullScene"
},
btnSwitchModel = {
sComponentName = "UIButton",
callback = "OnBtnClick_SwitchModel"
},
goPortrait = {},
go3D = {},
sv = {
sComponentName = "LoopScrollView"
},
trSv = {sNodeName = "sv", sComponentName = "Transform"},
txtSkinName = {sComponentName = "TMP_Text"},
imgRoleBg = {},
txtRoleName = {sComponentName = "TMP_Text"},
btnReplace = {
sComponentName = "UIButton",
callback = "OnBtnClick_Replace"
},
txtBtnReplace = {
sComponentName = "TMP_Text",
sLanguageId = "Skin_Replace"
},
btnBuy = {sComponentName = "UIButton"},
txtSaleTip = {sComponentName = "TMP_Text"},
goCurrency = {},
imgCurrency = {sComponentName = "Image"},
txtPrice = {sComponentName = "TMP_Text"},
txtSalePrice = {sComponentName = "TMP_Text"},
imgEquipped = {},
txtSkinEquipped = {
sComponentName = "TMP_Text",
sLanguageId = "Skin_Equipped"
},
txtSkinHas = {sComponentName = "TMP_Text", sLanguageId = "Skin_Has"},
txtTips = {
sComponentName = "TMP_Text",
sLanguageId = "Skin_UnUsed_Tip"
},
btnSwitchHalf = {
sComponentName = "UIButton",
callback = "OnBtnClick_SwitchHalf"
},
txtPortrait = {
sComponentName = "TMP_Text",
sLanguageId = "CharacterSkin_Portrait"
},
txt3D = {
sComponentName = "TMP_Text",
sLanguageId = "CharacterSkin_3D"
},
goLeft = {sNodeName = "---Left---"},
goRight = {
sNodeName = "---Right---"
},
canvasGroupRight = {
sNodeName = "---Right---",
sComponentName = "CanvasGroup"
},
UIParallax3DStage = {
sComponentName = "UIParallaxStageCameraController"
},
aniSafeAreaRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "Animator"
},
aniArrow = {sNodeName = "goArrow", sComponentName = "Animator"},
topBarAnim = {sNodeName = "goBack", sComponentName = "Animator"}
}
SkinPreviewCtrl._mapEventConfig = {
[EventId.UIBackConfirm] = "OnBtnClick_Back",
[EventId.UIHomeConfirm] = "OnBtnClick_Home",
MallOrderClear = "OnEvent_BuyMallPackageSuccess"
}
local show_mode_2d = 1
local show_mode_3d = 2
function SkinPreviewCtrl:SortSkinList()
table.sort(self.tbSkinList, function(a, b)
return a.nId < b.nId
end)
end
function SkinPreviewCtrl:GetTimeStr(nRemainTime)
local str = ""
if nRemainTime <= 3600 then
str = ConfigTable.GetUIText("Mall_Package_WithinHour")
elseif 3600 < nRemainTime and nRemainTime <= 86400 then
str = orderedFormat(ConfigTable.GetUIText("Mall_Package_Hour") or "", math.floor(nRemainTime / 3600))
elseif 86400 < nRemainTime then
str = orderedFormat(ConfigTable.GetUIText("Mall_Package_Day") or "", math.floor(nRemainTime / 86400))
end
return str
end
function SkinPreviewCtrl:RefreshSelectSkinInfo()
local skinData = self.tbSkinList[self.nSelectIndex]
if nil == skinData then
return
end
self._mapNode.txtSaleTip.gameObject:SetActive(false)
self.nSkinId = skinData.nId
self.nCharId = 0
local bUsed = false
local bCharUnlock = false
local bUnlock = PlayerData.CharSkin:CheckSkinUnlock(self.nSkinId)
local mapSkinCfg = ConfigTable.GetData_CharacterSkin(self.nSkinId)
if mapSkinCfg ~= nil then
self.nCharId = mapSkinCfg.CharId
local usingSkinId = PlayerCharData:GetCharUsedSkinId(self.nCharId)
bUsed = usingSkinId == self.nSkinId
bCharUnlock = PlayerData.Char:CheckCharUnlock(self.nCharId)
self._mapNode.goSkinDesc:SetActive(mapSkinCfg.Desc ~= "")
NovaAPI.SetTMPText(self._mapNode.txtSkinDesc, mapSkinCfg.Desc)
NovaAPI.SetTMPText(self._mapNode.txtSkinName, mapSkinCfg.Name)
self._mapNode.imgRoleBg.gameObject:SetActive(false)
local mapCharCfg = ConfigTable.GetData_Character(self.nCharId)
if mapCharCfg ~= nil then
self._mapNode.imgRoleBg.gameObject:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtRoleName, mapCharCfg.Name)
end
end
self._mapNode.btnBuy.gameObject:SetActive(false)
self._mapNode.btnReplace.gameObject:SetActive(false)
self._mapNode.imgEquipped.gameObject:SetActive(false)
self._mapNode.txtSkinEquipped.gameObject:SetActive(false)
self._mapNode.txtSkinHas.gameObject:SetActive(false)
self._mapNode.goCurrency:SetActive(false)
self._mapNode.txtSalePrice.gameObject:SetActive(false)
self._mapNode.txtSaleTip.gameObject:SetActive(false)
self._mapNode.goTheme.gameObject:SetActive(mapSkinCfg.SkinTheme ~= 0)
if mapSkinCfg.SkinTheme ~= 0 then
local themeCfg = ConfigTable.GetData("CharacterSkinTheme", mapSkinCfg.SkinTheme)
if nil ~= themeCfg then
self:SetPngSprite(self._mapNode.imgTheme, themeCfg.Icon)
NovaAPI.SetTMPText(self._mapNode.txtTheme, themeCfg.Name)
end
end
if self.nShowMode == show_mode_2d then
self:RefreshActor2D()
elseif self.nShowMode == show_mode_3d then
self:LoadCharacter()
end
end
function SkinPreviewCtrl:RefreshActor2D()
Actor2DManager.SetActor2D(self:GetPanelId(), self._mapNode.rawImgActor2D, self.nCharId, self.nSkinId)
end
function SkinPreviewCtrl:RefreshPreviewMode(bPreview)
self.bPreview = bPreview
self._mapNode.goPreview.gameObject:SetActive(true)
self._mapNode.btnSkin.gameObject:SetActive(bPreview)
self._mapNode.eventSkinZoom:SetZoomLock(not bPreview)
if not bPreview then
self:RefreshSelectSkinInfo()
if self.nShowMode == show_mode_3d then
self._mapNode.aniArrow:Play("CharacterSkin_3D_Out")
self.curShowModel.transform.localEulerAngles = Vector3(0, 180, 0)
end
self._mapNode.aniSafeAreaRoot:Play("CharacterSkin_preview_in")
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.canvasGroupRight, true)
Actor2DManager.ResetActor2DDragOffset(self.v3Offset)
else
if self.bUseFull then
self:OnBtnClick_SwitchHalf()
self:AddTimer(1, 0.7, function()
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.canvasGroupRight, false)
self.v3Offset = Actor2DManager.SwitchActor2DDragOffset()
end, true, true, true)
EventManager.Hit(EventId.TemporaryBlockInput, 0.7)
else
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.canvasGroupRight, false)
self.v3Offset = Actor2DManager.SwitchActor2DDragOffset()
if self.nShowMode == show_mode_3d and self.bDragValid then
self._mapNode.aniArrow:Play("CharacterSkin_3D_In")
end
end
self._mapNode.aniSafeAreaRoot:Play("CharacterSkin_preview_out")
end
end
function SkinPreviewCtrl:RefreshFullScene(bFullScene)
self._mapNode.TopBar.gameObject:SetActive(not bFullScene)
if not bFullScene then
self._mapNode.aniSafeAreaRoot:Play("CharacterSkin_preview_in")
else
self._mapNode.aniSafeAreaRoot:Play("CharacterSkin_preview_out")
end
end
function SkinPreviewCtrl:OnGridRefresh(goGrid, gridIndex)
local nIndex = gridIndex + 1
local nInstanceId = goGrid:GetInstanceID()
if not self.tbGridCtrl[nInstanceId] then
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.TemplateEx.TemplateSkinCtrl")
end
local skinData = self.tbSkinList[nIndex].skinData
self.tbGridCtrl[nInstanceId]:SetSkinData(skinData, false, true)
if nIndex == self.nSelectIndex then
self.tbGridCtrl[nInstanceId]:SetSelect(true)
end
end
function SkinPreviewCtrl:OnGridBtnClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
local nInstanceId = goGrid:GetInstanceID()
local goSelect = self._mapNode.trSv:Find("Viewport/Content/" .. self.nSelectIndex - 1)
if goSelect then
self.tbGridCtrl[goSelect.gameObject:GetInstanceID()]:SetSelect(false)
end
self.tbGridCtrl[nInstanceId]:SetSelect(true)
self._mapNode.sv:SetScrollGridPos(nIndex - 1, 0.1, 0)
self.nSelectIndex = nIndex
self:RefreshSelectSkinInfo()
end
function SkinPreviewCtrl:LoadCharacter()
if self.nShowModelSkinId == self.nSkinId then
return
end
self.nShowModelSkinId = self.nSkinId
local bNeedLoad = true
for skinId, v in pairs(self.tbModelList) do
if skinId == self.nSkinId then
bNeedLoad = false
v.gameObject:SetActive(true)
v.transform.localEulerAngles = Vector3(0, 180, 0)
self.nModelDragRot = v.transform.localEulerAngles.y
self.curShowModel = v
self:WaitReadyClipFinish()
else
v.gameObject:SetActive(false)
end
end
if bNeedLoad then
local mapSkin = ConfigTable.GetData_CharacterSkin(self.nSkinId)
local sFullPath = string.format("%s.prefab", mapSkin.Model_Show)
local LoadModelCallback = function(obj)
local idx = 1
NovaAPI.UnbindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, idx - 1)
local go = instantiate(obj, self.rtSceneOriginPos)
self.tbModelList[self.nSkinId] = go
self.curShowModel = go
self:WaitReadyClipFinish()
NovaAPI.BindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, idx - 1, go)
if self.rtSceneOriginPos ~= nil then
go.transform.position = self.rtSceneOriginPos.position
go.transform.localEulerAngles = Vector3(0, 180, 0)
self.nModelDragRot = go.transform.localEulerAngles.y
go.transform.localScale = Vector3.zero
local animator = go:GetComponent(typeof(Animator))
if animator ~= nil and animator:IsNull() == false then
animator:SetBool("standby", true)
end
GameUIUtils.SetCustomModelMaterialVariant(go, CS.CustomModelMaterialVariantComponent.VariantNames.FormationView)
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
go.transform.localScale = Vector3.one * (mapSkin.ModelShowScale / 10000)
end
cs_coroutine.start(wait)
end
EventManager.Hit(EventId.BlockInput, false)
end
self:LoadAssetAsync(sFullPath, typeof(GameObject), LoadModelCallback)
EventManager.Hit(EventId.BlockInput, true)
end
end
function SkinPreviewCtrl:WaitReadyClipFinish()
if self.waitReadyClipCor ~= nil then
cs_coroutine.stop(self.waitReadyClipCor)
end
if self.curShowModel == nil then
return
end
local director = self.curShowModel:GetComponent("PlayableDirector")
if director == nil then
return
end
local readyClipName = self.nCharId .. "_Ready"
local wait = function()
while CS.AdventureModuleHelper.CheckTimelineClipFinish(director, readyClipName) == false do
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
end
self.bDragValid = true
if self.bPreview and self.nShowMode == show_mode_3d then
self._mapNode.aniArrow:Play("CharacterSkin_3D_In")
end
end
self.bDragValid = false
self.waitReadyClipCor = cs_coroutine.start(wait)
end
function SkinPreviewCtrl:DestroyCharacter()
local sSceneName = ConfigTable.GetConfigValue("CharacterSkin_Scene")
local callback = function()
end
CS.MainMenuModuleHelper.DeActiveScene(sSceneName, callback)
NovaAPI.UnbindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, 1)
for _, v in pairs(self.tbModelList) do
destroy(v)
end
self.tbModelList = {}
self.curShowModel = nil
self.nModelDragRot = 0
if nil ~= self.goSelectRolePrefab then
destroy(self.goSelectRolePrefab)
end
self.goSelectRolePrefab = nil
end
function SkinPreviewCtrl:Awake()
self.canvas = self.gameObject:GetComponent("Canvas")
self.gameObject:SetActive(false)
self.tbGridCtrl = {}
self.nSelectIndex = nil
self.nShowModelSkinId = 0
self.tbModelList = {}
self.curShowModel = nil
self.nModelDragRot = 0
self.v3Offset = Vector3.zero
self.nShowMode = show_mode_2d
self.tbZoomRange = ConfigTable.GetConfigArray("SkinZoomRange")
self.bUseFull = false
end
function SkinPreviewCtrl:OnEnable()
self.bPreview = false
self.bStartDrag = false
self.bDragValid = true
local tbParam = self:GetPanelParam()
local tbSkinList = tbParam[1]
self.nSkinId = 0
self.nSelectIndex = tbParam[2]
self.tbSkinList = {}
if tbSkinList ~= nil and 0 < #tbSkinList then
self.nSkinId = tbSkinList[1]
end
for _, v in ipairs(tbSkinList) do
local skinData = SkinData.new(v, 0, false)
table.insert(self.tbSkinList, {nId = v, skinData = skinData})
end
self._mapNode.eventSkinZoom:SetZoomLock(true)
self._mapNode.eventSkinZoom:SetZoomLimitValue(tonumber(self.tbZoomRange[1]), tonumber(self.tbZoomRange[2]))
for insId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[insId] = nil
end
if self.nSelectIndex == nil then
for k, v in ipairs(self.tbSkinList) do
if v.nId == self.nSkinId then
self.nSelectIndex = k
break
end
end
end
if self.nSelectIndex == nil then
self.nSelectIndex = 1
end
self._mapNode.sv:Init(#self.tbSkinList, self, self.OnGridRefresh, self.OnGridBtnClick)
self._mapNode.sv:SetScrollGridPos(self.nSelectIndex - 1, 0)
self._mapNode.goPreview.gameObject:SetActive(true)
self._mapNode.btnSkin.gameObject:SetActive(false)
self._mapNode.go3D.gameObject:SetActive(self.nShowMode == show_mode_3d)
self._mapNode.goPortrait.gameObject:SetActive(self.nShowMode == show_mode_2d)
local sSceneName = ConfigTable.GetConfigValue("CharacterSkin_Scene")
NovaAPI.SetComponentEnable(self.canvas, false)
local callback = function(bSuccess)
NovaAPI.SetComponentEnable(self.canvas, true)
if bSuccess == true then
local sceneRoot = CS.MainMenuModuleHelper.GetMainMenuSceneRoot(sSceneName)
self.rtSceneOriginPos = sceneRoot.transform:Find("==== Scene ====")
self.goSelectRolePrefab = self:CreatePrefabInstance("UI/CharacterSkin/CharSkin3DShowPrefab.prefab", self.rtSceneOriginPos)
local goSelectRoleCam = self.goSelectRolePrefab.transform:Find("Camera"):GetComponent("Camera")
NovaAPI.SetupUIParallaxStageCameraControllerForModelView(self._mapNode.UIParallax3DStage, goSelectRoleCam)
else
self._mapNode.UIParallax3DStage.gameObject:SetActive(false)
end
self.gameObject:SetActive(true)
self:RefreshSelectSkinInfo()
EventManager.Hit(EventId.SetTransition)
end
CS.MainMenuModuleHelper.GetActiveScene(sSceneName, callback)
end
function SkinPreviewCtrl:OnDisable()
self.tbSkinList = nil
for insId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[insId] = nil
end
self.tbGridCtrl = {}
self.bStartDrag = nil
self.bDragValid = nil
if self.waitReadyClipCor ~= nil then
cs_coroutine.stop(self.waitReadyClipCor)
end
Actor2DManager.UnsetActor2D()
self:DestroyCharacter()
end
function SkinPreviewCtrl:OnDestroy()
end
function SkinPreviewCtrl:OnBtnClick_FullScene()
self:RefreshPreviewMode(true)
self:RefreshFullScene(true)
end
function SkinPreviewCtrl:OnBtnClick_SwitchModel()
self.nShowMode = self.nShowMode == show_mode_2d and show_mode_3d or show_mode_2d
self._mapNode.btnSwitchHalf.gameObject:SetActive(self.nShowMode == show_mode_2d)
self._mapNode.go3D.gameObject:SetActive(self.nShowMode == show_mode_3d)
self._mapNode.goPortrait.gameObject:SetActive(self.nShowMode == show_mode_2d)
if self.nShowMode == show_mode_2d then
local tweener = NovaAPI.DoRawImageColor(self._mapNode.rawImgActor2D, Color(1, 1, 1, 1), 0.5)
tweener:SetUpdate(true)
self._mapNode.rtRawImgActor2D:DOScale(1, 0.5):SetUpdate(true)
elseif self.nShowMode == show_mode_3d then
local tweener = NovaAPI.DoRawImageColor(self._mapNode.rawImgActor2D, Color(1, 1, 1, 0), 0.5)
tweener:SetUpdate(true)
self._mapNode.rtRawImgActor2D:DOScale(1.5, 0.5):SetUpdate(true)
end
self:RefreshSelectSkinInfo()
end
function SkinPreviewCtrl:OnBtnClick_SkinPreview()
self:RefreshPreviewMode(true)
end
function SkinPreviewCtrl:OnBtnClick_Skin()
if not self.bStartDrag then
self:RefreshFullScene(false)
self:RefreshPreviewMode(false)
end
end
function SkinPreviewCtrl:OnBtnClick_Replace()
local func_callback = function()
PlayerData.Char:SetCharSkinId(self.nCharId, self.nSkinId)
self:RefreshSelectSkinInfo()
end
local msgSend = {}
msgSend.CharId = self.nCharId
msgSend.SkinId = self.nSkinId
HttpNetHandler.SendMsg(NetMsgId.Id.char_skin_set_req, msgSend, nil, func_callback)
end
function SkinPreviewCtrl:OnBtnClick_Back(nPanelId)
if self._panel._nPanelId ~= nPanelId then
return
end
if self.bPreview then
self:RefreshPreviewMode(false)
if self.timerFullScene ~= nil then
self.timerFullScene:Cancel()
self.timerFullScene = nil
end
else
EventManager.Hit(EventId.CloesCurPanel)
end
end
function SkinPreviewCtrl:OnBtnClick_Home(nPanelId)
if self._panel._nPanelId ~= nPanelId then
return
end
PanelManager.Home()
end
function SkinPreviewCtrl:OnEvent_BuyMallPackageSuccess(bMoney)
if not bMoney then
PlayerData.CharSkin:TryOpenSkinShowPanel()
end
self:RefreshSelectSkinInfo()
end
function SkinPreviewCtrl:OnBtnClick_SwitchHalf()
self.bUseFull = not self.bUseFull
Actor2DManager.SwitchFullHalf()
end
function SkinPreviewCtrl:OnUIDrag_Drag(mDrag)
if not self.bDragValid then
return
end
if mDrag.DragEventType == AllEnum.UIDragType.DragStart then
self.bStartDrag = true
elseif mDrag.DragEventType == AllEnum.UIDragType.Drag then
if true == self.bStartDrag then
if self.nShowMode == show_mode_2d then
Actor2DManager.SyncLocalPos(mDrag.EventData.delta.x, mDrag.EventData.delta.y, nil, self._mapNode.rtRawImgActor2D)
elseif self.nShowMode == show_mode_3d and nil ~= self.curShowModel then
self.nModelDragRot = self.nModelDragRot - mDrag.EventData.delta.x * 0.5
self.curShowModel.transform.localEulerAngles = Vector3(0, self.nModelDragRot, 0)
end
end
elseif mDrag.DragEventType == AllEnum.UIDragType.DragEnd then
self.bStartDrag = false
end
end
function SkinPreviewCtrl:OnUIZoom_Skin(mZoom)
if mZoom.InZoom then
if mZoom.ZoomValue ~= 0 then
self.bDragValid = false
Actor2DManager.SyncLocalScale(mZoom.ZoomValue)
end
else
self.bDragValid = true
end
end
return SkinPreviewCtrl
@@ -0,0 +1,8 @@
local SkinPreviewPanel = class("SkinPreviewPanel", BasePanel)
SkinPreviewPanel._tbDefine = {
{
sPrefabPath = "Mall/MallSkinPreviewPanel.prefab",
sCtrlName = "Game.UI.BattlePass.SkinPreviewCtrl"
}
}
return SkinPreviewPanel