c1_lua/lua/app/ui/main_city/module_unlock_ui.lua
2023-05-31 20:53:57 +08:00

83 lines
2.3 KiB
Lua

local ModuleUnlockUI = class("ModuleUnlockUI", BaseUI)
function ModuleUnlockUI:getPrefabPath()
return "assets/prefabs/ui/main_city/module_unlock_ui.prefab"
end
function ModuleUnlockUI:isFullScreen()
return false
end
function ModuleUnlockUI:onClose()
if self.unlockAnimationSeq then
self.unlockAnimationSeq:Kill()
self.unlockAnimationSeq = nil
end
end
function ModuleUnlockUI:ctor(params)
self.chapterId = params and params.chapterId
self.unlockList = {}
local cfg = ConfigManager:getConfig("func_open")
for k, v in pairs(cfg) do
if v.stage == self.chapterId and v.pop_ups == nil then
table.insert(self.unlockList, k)
end
end
end
function ModuleUnlockUI:onLoadRootComplete()
self.uiMap = self.root:genAllChildren()
self.uiMap["module_unlock_ui.bg"]:addClickListener(function()
self:showNextModuleUnlockAnimation()
end)
self.moduleNameTx = self.uiMap["module_unlock_ui.name_tx"]
self.moduleIcon = self.uiMap["module_unlock_ui.icon"]
self.uiMap["module_unlock_ui.continue"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_TO_CONTINUE))
self.uiMap["module_unlock_ui.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.FUNC_UNLOCK))
self:showModuleUnlockAnimation()
end
function ModuleUnlockUI:showNextModuleUnlockAnimation()
if self:showModuleUnlockAnimation() then
self:playUnlockAnimation()
end
end
function ModuleUnlockUI:showModuleUnlockAnimation()
if #self.unlockList <= 0 then
self:closeUI()
return false
end
local moduleKey = table.remove(self.unlockList, 1)
local info = ConfigManager:getConfig("func_open")[moduleKey]
local i18nInfo = I18N:getConfig("func_open")[moduleKey]
if info == nil or i18nInfo == nil then
self:closeUI()
return false
end
self.moduleNameTx:setText(i18nInfo.name)
if info.icon then
self.moduleIcon:setSprite(GConst.ATLAS_PATH.MODULE, info.icon)
end
return true
end
function ModuleUnlockUI:playUnlockAnimation()
if self.unlockAnimationSeq == nil then
self.unlockAnimationSeq = self.root:createBindTweenSequence()
local scaleTween1 = self.root:getTransform():DOScale(1.05, 0.15)
self.unlockAnimationSeq:Append(scaleTween1)
local scaleTween2 = self.root:getTransform():DOScale(1, 0.2)
self.unlockAnimationSeq:Append(scaleTween2)
self.unlockAnimationSeq:SetAutoKill(false)
else
self.unlockAnimationSeq:Restart()
end
end
return ModuleUnlockUI