331 lines
8.0 KiB
Lua
331 lines
8.0 KiB
Lua
local phaseBase = require_ex('Phase/Core/PhaseBase')
|
|
local PHASE_ID = PhaseId.BattlePass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass = HL.Class('PhaseBattlePass', phaseBase.PhaseBase)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass.s_messages = HL.StaticField(HL.Table) << {
|
|
|
|
}
|
|
|
|
|
|
|
|
PhaseBattlePass.m_panelItemDic = HL.Field(HL.Table)
|
|
|
|
|
|
PhaseBattlePass.m_basePanel = HL.Field(HL.Forward("PhasePanelItem"))
|
|
|
|
|
|
PhaseBattlePass.m_curPanel = HL.Field(HL.Forward("PhasePanelItem"))
|
|
|
|
|
|
PhaseBattlePass.m_transCoroutine = HL.Field(HL.Thread)
|
|
|
|
|
|
PhaseBattlePass.m_isChanging = HL.Field(HL.Boolean) << false
|
|
|
|
|
|
PhaseBattlePass.m_bpEndTimer = HL.Field(HL.Number) << 0
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._OnInit = HL.Override() << function(self)
|
|
PhaseBattlePass.Super._OnInit(self)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass.PrepareTransition = HL.Override(HL.Number, HL.Boolean, HL.Opt(HL.Number)) << function(self, transitionType, fastMode, anotherPhaseId)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._DoPhaseTransitionIn = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
self.m_panelItemDic = {}
|
|
if self:_TryOpenBattlePassDisplay() then
|
|
return
|
|
end
|
|
self.m_basePanel = self:CreatePhasePanelItem(PanelId.BattlePass, self.arg)
|
|
self:_TryPopPanel()
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._DoPhaseTransitionOut = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
Notify(MessageConst.HIDE_COMMON_HOVER_TIP)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._DoPhaseTransitionBehind = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
if UIManager:IsOpen(PanelId.BattlePassAdvancedPlanBuy) and
|
|
not BattlePassUtils.CheckBattlePassPurchaseBlock() then
|
|
CashShopUtils.HidePsStore()
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._DoPhaseTransitionBackToTop = HL.Override(HL.Boolean, HL.Opt(HL.Table)) << function(self, fastMode, args)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._OnActivated = HL.Override() << function(self)
|
|
local timeToEnd = BattlePassUtils.GetSeasonLeftTime()
|
|
self.m_bpEndTimer = TimerManager:StartTimer(timeToEnd, function()
|
|
Notify(MessageConst.SHOW_POP_UP, {
|
|
content = Language.LUA_BATTLE_PASS_END_POPUP,
|
|
onConfirm = function()
|
|
self:CloseSelf()
|
|
end,
|
|
hideCancel = true,
|
|
})
|
|
TimerManager:ClearTimer(self.m_bpEndTimer)
|
|
self.m_bpEndTimer = 0
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
PhaseBattlePass._OnDeActivated = HL.Override() << function(self)
|
|
if self.m_bpEndTimer > 0 then
|
|
TimerManager:ClearTimer(self.m_bpEndTimer)
|
|
self.m_bpEndTimer = 0
|
|
end
|
|
end
|
|
|
|
|
|
|
|
PhaseBattlePass.CloseSelf = HL.Override() << function(self)
|
|
if self.arg and self.arg.fromPhase == PhaseId.CashShop then
|
|
PhaseManager:OpenPhaseFast(PhaseId.CashShop)
|
|
end
|
|
PhaseBattlePass.Super.CloseSelf(self)
|
|
end
|
|
|
|
|
|
|
|
PhaseBattlePass._OnDestroy = HL.Override() << function(self)
|
|
PhaseBattlePass.Super._OnDestroy(self)
|
|
end
|
|
|
|
|
|
|
|
PhaseBattlePass._OnRefresh = HL.Override() << function(self)
|
|
if not self.m_basePanel then
|
|
return
|
|
end
|
|
local isBaseFrontPanel = self.m_basePanel.uiCtrl:GetSortingOrder() >= UIManager:CurBlockKeyboardEventPanelOrder()
|
|
if not isBaseFrontPanel then
|
|
return
|
|
end
|
|
if self.arg and self.arg.panelId and self.m_curPanel.uiCtrl.panelId ~= self.arg.panelId then
|
|
Notify(MessageConst.ON_CHANGE_BATTLE_PASS_TAB, self.arg)
|
|
elseif self.m_curPanel then
|
|
self.m_curPanel.uiCtrl:OnPhaseRefresh(self.arg)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._TryOpenBattlePassDisplay = HL.Method().Return(HL.Boolean) << function(self)
|
|
|
|
|
|
local bpSystem = GameInstance.player.battlePassSystem
|
|
if bpSystem:IsSeasonUnread(GameInstance.player.battlePassSystem.seasonData.seasonId) then
|
|
bpSystem:ResetAllReadTasks()
|
|
local showingTaskIds = BattlePassUtils.GetShowingTaskIds()
|
|
if #showingTaskIds > 0 then
|
|
bpSystem:ReadTasks(showingTaskIds)
|
|
end
|
|
bpSystem:ReadSeason(GameInstance.player.battlePassSystem.seasonData.seasonId)
|
|
UIManager:Open(PanelId.BattlePassSeasonDisplay, {
|
|
onClose = function()
|
|
self.m_basePanel = self:CreatePhasePanelItem(PanelId.BattlePass, self.arg)
|
|
self:_TryPopPanel()
|
|
if BattlePassUtils.CheckBattlePassPurchaseBlock() then
|
|
UIManager:SetTopOrder(PanelId.BattlePassSeasonDisplay)
|
|
return
|
|
end
|
|
local popupPanelId = nil
|
|
if self.arg ~= nil and self.arg.popupPanelId ~= nil then
|
|
popupPanelId = self.arg.popupPanelId
|
|
end
|
|
|
|
local planBuyCtrl = nil
|
|
if popupPanelId ~= 'BattlePassAdvancedPlanBuy' then
|
|
planBuyCtrl = UIManager:Open(PanelId.BattlePassAdvancedPlanBuy)
|
|
end
|
|
if UIManager:IsOpen(PanelId.BattlePassSeasonDisplay) then
|
|
UIManager:SetTopOrder(PanelId.BattlePassSeasonDisplay)
|
|
end
|
|
end,
|
|
})
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
|
|
|
|
PhaseBattlePass._TryPopPanel = HL.Method() << function(self)
|
|
local popupPanelId = nil
|
|
if self.arg ~= nil and self.arg.popupPanelId ~= nil then
|
|
popupPanelId = self.arg.popupPanelId
|
|
end
|
|
if BattlePassUtils.CheckBattlePassPurchaseBlock() and popupPanelId == 'BattlePassAdvancedPlanBuy' then
|
|
return
|
|
end
|
|
if popupPanelId ~= nil then
|
|
local panelId = PanelId[popupPanelId]
|
|
UIManager:Open(panelId)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass.ChangePanel = HL.Method(HL.Number, HL.Boolean, HL.Opt(HL.Any)) << function(self, panelId, isRight, arg)
|
|
if self.m_isChanging then
|
|
return
|
|
end
|
|
self:_OpenPanel(panelId, isRight, arg)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._OpenPanel = HL.Method(HL.Number, HL.Boolean, HL.Opt(HL.Any)) << function(self, panelId, isRight, arg)
|
|
self:_ClearCoroutine(self.m_transCoroutine)
|
|
self.m_transCoroutine = nil
|
|
self.m_isChanging = false
|
|
if self.m_curPanel ~= nil then
|
|
if self.m_curPanel.uiCtrl.panelId ~= panelId then
|
|
InputManagerInst.controllerNaviManager:SetTarget(nil)
|
|
end
|
|
self:_HidePanelImpl(self.m_curPanel, isRight,function()
|
|
self.m_curPanel = self:_OpenPanelImpl(panelId, isRight, arg)
|
|
end)
|
|
else
|
|
self.m_curPanel = self:_OpenPanelImpl(panelId, isRight, arg, true)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._HidePanelImpl = HL.Method(HL.Forward("PhasePanelItem"), HL.Boolean, HL.Function)
|
|
<< function(self, panelItem, isRight, onPanelHide)
|
|
if panelItem == nil and onPanelHide ~= nil then
|
|
onPanelHide()
|
|
return
|
|
end
|
|
local uiCtrl = panelItem.uiCtrl
|
|
InputManagerInst.controllerNaviManager:TryRemoveLayer(uiCtrl.naviGroup)
|
|
local outAniName = isRight and uiCtrl.view.config.ANI_OUT_RIGHT or uiCtrl.view.config.ANI_OUT_LEFT
|
|
uiCtrl.animationWrapper:ClearTween(false)
|
|
uiCtrl.animationWrapper:Play(outAniName, function()
|
|
uiCtrl:Hide()
|
|
end)
|
|
self.m_isChanging = true
|
|
self.m_transCoroutine = self:_StartCoroutine(function()
|
|
coroutine.wait(self.m_basePanel.uiCtrl.view.config.TRANSITION_DELAY_TIME)
|
|
onPanelHide()
|
|
self.m_transCoroutine = nil
|
|
self.m_isChanging = false
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhaseBattlePass._OpenPanelImpl = HL.Method(HL.Number, HL.Boolean, HL.Opt(HL.Any, HL.Boolean)).Return(HL.Forward("PhasePanelItem"))
|
|
<< function(self, panelId, isRight, arg, isFirstInit)
|
|
isFirstInit = isFirstInit == true
|
|
local panelItem
|
|
if self.m_panelItemDic[panelId] then
|
|
panelItem = self.m_panelItemDic[panelId]
|
|
panelItem.uiCtrl:Show()
|
|
else
|
|
panelItem = self:CreatePhasePanelItem(panelId, arg)
|
|
if panelItem == nil then
|
|
return
|
|
end
|
|
self.m_panelItemDic[panelId] = panelItem
|
|
end
|
|
local uiCtrl = panelItem.uiCtrl
|
|
uiCtrl.animationWrapper:ClearTween(false)
|
|
if isFirstInit then
|
|
uiCtrl.animationWrapper:PlayInAnimation()
|
|
else
|
|
local inAniName = isRight and uiCtrl.view.config.ANI_IN_RIGHT or uiCtrl.view.config.ANI_IN_LEFT
|
|
uiCtrl.animationWrapper:Play(inAniName)
|
|
end
|
|
return panelItem
|
|
end
|
|
|
|
HL.Commit(PhaseBattlePass)
|
|
|