功能解锁飞行动画

This commit is contained in:
Fang 2023-06-02 15:37:44 +08:00
parent 2f2a993c12
commit b6936a2c4a
13 changed files with 278 additions and 44 deletions

View File

@ -259,6 +259,11 @@ function BaseObject:addPosition(x, y, z)
transform.position = Vector3 transform.position = Vector3
end end
function BaseObject:getPosition()
local transform = self:getTransform()
return transform.position
end
function BaseObject:getLocalPosition() function BaseObject:getLocalPosition()
local transform = self:getTransform() local transform = self:getTransform()
return transform.localPosition return transform.localPosition

View File

@ -26,7 +26,13 @@ function MaincityManager:firstEnterMainCity()
end end
function MaincityManager:changeMainCityLeftSideBarOpenOrClose() function MaincityManager:changeMainCityLeftSideBarOpenOrClose()
local mainUI = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI)
if not mainUI then
return nil
end
self.isLeftSideBarClose = not self.isLeftSideBarClose self.isLeftSideBarClose = not self.isLeftSideBarClose
mainUI:refreshLeftBtns()
end end
function MaincityManager:getIsMainCityLeftSideBarClose() function MaincityManager:getIsMainCityLeftSideBarClose()
@ -34,11 +40,62 @@ function MaincityManager:getIsMainCityLeftSideBarClose()
end end
function MaincityManager:changeMainCityRightSideBarOpenOrClose() function MaincityManager:changeMainCityRightSideBarOpenOrClose()
local mainUI = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI)
if not mainUI then
return nil
end
self.isRightSideBarClose = not self.isRightSideBarClose self.isRightSideBarClose = not self.isRightSideBarClose
mainUI:refreshRightBtns()
end end
function MaincityManager:getIsMainCityRightSideBarClose() function MaincityManager:getIsMainCityRightSideBarClose()
return self.isRightSideBarClose return self.isRightSideBarClose
end end
-- 获取主界面各个模块的入口坐标
function MaincityManager:getModuleEntrancePos(moduleKey)
local mainUI = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI)
if not mainUI then
return nil
end
if moduleKey == ModuleManager.MODULE_KEY.TASK then
return mainUI:getTaskIconPos()
elseif moduleKey == ModuleManager.MODULE_KEY.MALL_DAILY then
return mainUI:getMallIconPos()
elseif moduleKey == ModuleManager.MODULE_KEY.DAILY_CHALLENGE then
return mainUI:getDailyChallengeIconPos()
elseif moduleKey == ModuleManager.MODULE_KEY.FUND or
moduleKey == ModuleManager.MODULE_KEY.IDLE_DROP or
moduleKey == ModuleManager.MODULE_KEY.SEVEN_DAY then
return mainUI:getSideBarActIconPos(moduleKey)
end
end
-- 模块在侧边栏,-10不在侧边栏1
function MaincityManager:getModuleInSideBarWhere(moduleKey)
local mainUI = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI)
if not mainUI then
return nil
end
if self.mainCityUI:isInSideBarLeft(moduleKey) then
return -1
elseif self.mainCityUI:isInSideBarRight(moduleKey) then
return 1
else
return 0
end
end
function MaincityManager:isActivSideBarModule(moduleKey)
local mainUI = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI)
if not mainUI then
return nil
end
return self.mainCityUI:isActivSideBarModule(moduleKey)
end
return MaincityManager return MaincityManager

View File

@ -5,6 +5,12 @@ local DEFAULT_RED_POINT_POS_Y = 30
local DEFAULT_RED_POINT_SCALE = 0.6 local DEFAULT_RED_POINT_SCALE = 0.6
-- 需要继承重写的部分 *********************************************************** -- 需要继承重写的部分 ***********************************************************
-- 模块key值对应ModuleManager.MODULE_KEY
function SideBarBaseCellComp:getModuleKey()
return nil
end
function SideBarBaseCellComp:getIsOpen() function SideBarBaseCellComp:getIsOpen()
return false return false
end end
@ -142,6 +148,19 @@ function SideBarBaseCellComp:setVisible(visible)
end end
end end
function SideBarBaseCellComp:getIsVisible()
return self.visible
end
function SideBarBaseCellComp:getEntrancePos()
if self:getIconRes() then
return self.icon:getPosition()
elseif self:getSpineName() then
return self.spine:getPosition()
end
return nil
end
function SideBarBaseCellComp:getCellPath() function SideBarBaseCellComp:getCellPath()
return self.cellPath return self.cellPath
end end

View File

@ -1,6 +1,10 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarBeginnerGiftCell = class("SideBarBeginnerGiftCell", SideBarBaseCellComp) local SideBarBeginnerGiftCell = class("SideBarBeginnerGiftCell", SideBarBaseCellComp)
function SideBarBeginnerGiftCell:getModuleKey()
return ModuleManager.MODULE_KEY.BEGINNER_GIFT
end
function SideBarBeginnerGiftCell:getIsOpen() function SideBarBeginnerGiftCell:getIsOpen()
return DataManager.ShopData:getBeginnerGiftShowSideBar() return DataManager.ShopData:getBeginnerGiftShowSideBar()
end end

View File

@ -1,6 +1,10 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarFirstRechargeCell = class("SideBarFirstRechargeCell", SideBarBaseCellComp) local SideBarFirstRechargeCell = class("SideBarFirstRechargeCell", SideBarBaseCellComp)
function SideBarFirstRechargeCell:getModuleKey()
return ModuleManager.MODULE_KEY.FIRST_RECHARGE
end
function SideBarFirstRechargeCell:getIsOpen() function SideBarFirstRechargeCell:getIsOpen()
return DataManager.ShopData:getShowFirstRechargeSideBar() return DataManager.ShopData:getShowFirstRechargeSideBar()
end end

View File

@ -1,6 +1,10 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarGoldPigCell = class("SideBarGoldPigCell", SideBarBaseCellComp) local SideBarGoldPigCell = class("SideBarGoldPigCell", SideBarBaseCellComp)
function SideBarGoldPigCell:getModuleKey()
return ModuleManager.MODULE_KEY.GOLD_PIG
end
function SideBarGoldPigCell:getIsOpen() function SideBarGoldPigCell:getIsOpen()
return DataManager.GoldPigData:getIsOpen() return DataManager.GoldPigData:getIsOpen()
end end

View File

@ -1,6 +1,10 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarGrowthFundCell = class("SideBarGrowthFundCell", SideBarBaseCellComp) local SideBarGrowthFundCell = class("SideBarGrowthFundCell", SideBarBaseCellComp)
function SideBarGrowthFundCell:getModuleKey()
return ModuleManager.MODULE_KEY.FUND
end
function SideBarGrowthFundCell:getIsOpen() function SideBarGrowthFundCell:getIsOpen()
return DataManager.GrowthFundData:getIsOpen() return DataManager.GrowthFundData:getIsOpen()
end end

View File

@ -1,6 +1,10 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarIdleCell = class("SideBarIdleCell", SideBarBaseCellComp) local SideBarIdleCell = class("SideBarIdleCell", SideBarBaseCellComp)
function SideBarIdleCell:getModuleKey()
return ModuleManager.MODULE_KEY.IDLE_DROP
end
function SideBarIdleCell:getIsOpen() function SideBarIdleCell:getIsOpen()
return DataManager.IdleData:getIsOpen() return DataManager.IdleData:getIsOpen()
end end

View File

@ -1,6 +1,10 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell" local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarSevenDaysCell = class("SideBarSevenDaysCell", SideBarBaseCellComp) local SideBarSevenDaysCell = class("SideBarSevenDaysCell", SideBarBaseCellComp)
function SideBarSevenDaysCell:getModuleKey()
return ModuleManager.MODULE_KEY.SEVEN_DAY
end
function SideBarSevenDaysCell:getIsOpen() function SideBarSevenDaysCell:getIsOpen()
return DataManager.SevenDayData:getIsOpen() return DataManager.SevenDayData:getIsOpen()
end end

View File

@ -71,8 +71,10 @@ function MainComp:refreshFightBtn()
end end
function MainComp:refreshLeftBtn() function MainComp:refreshLeftBtn()
local leftBtn = self.uiMap["main_comp.left_btn"] if self.leftBtn == nil then
leftBtn:setActive(false) self.leftBtn = self.uiMap["main_comp.left_btn"]
end
self.leftBtn:setActive(false)
local leftIdx = self:getCurLeftModuleIdx() local leftIdx = self:getCurLeftModuleIdx()
if leftIdx == nil then if leftIdx == nil then
@ -83,23 +85,25 @@ function MainComp:refreshLeftBtn()
return return
end end
leftBtn:setActive(true) self.leftBtn:setActive(true)
local iconAtlas, iconName = moduleCell:getEntranceIcon() local iconAtlas, iconName = moduleCell:getEntranceIcon()
self.uiMap["main_comp.left_btn.desc"]:setText(moduleCell:getEntranceName()) self.uiMap["main_comp.left_btn.desc"]:setText(moduleCell:getEntranceName())
self.uiMap["main_comp.left_btn.icon"]:setSprite(iconAtlas, iconName) self.uiMap["main_comp.left_btn.icon"]:setSprite(iconAtlas, iconName)
leftBtn:addClickListener(function() self.leftBtn:addClickListener(function()
self:refreshModule(leftIdx) self:refreshModule(leftIdx)
end) end)
if moduleCell:getShowEntranceRedPoint() then if moduleCell:getShowEntranceRedPoint() then
leftBtn:addRedPoint(65, 35, 0.6) self.leftBtn:addRedPoint(65, 35, 0.6)
else else
leftBtn:removeRedPoint() self.leftBtn:removeRedPoint()
end end
end end
function MainComp:refreshRightBtn() function MainComp:refreshRightBtn()
local rightBtn = self.uiMap["main_comp.right_btn"] if self.rightBtn == nil then
rightBtn:setActive(false) self.rightBtn = self.uiMap["main_comp.right_btn"]
end
self.rightBtn:setActive(false)
local rightIdx = self:getCurRightModuleIdx() local rightIdx = self:getCurRightModuleIdx()
if rightIdx == nil then if rightIdx == nil then
@ -110,17 +114,17 @@ function MainComp:refreshRightBtn()
return return
end end
rightBtn:setActive(true) self.rightBtn:setActive(true)
local iconAtlas, iconName = moduleCell:getEntranceIcon() local iconAtlas, iconName = moduleCell:getEntranceIcon()
self.uiMap["main_comp.right_btn.desc"]:setText(moduleCell:getEntranceName()) self.uiMap["main_comp.right_btn.desc"]:setText(moduleCell:getEntranceName())
self.uiMap["main_comp.right_btn.icon"]:setSprite(iconAtlas, iconName) self.uiMap["main_comp.right_btn.icon"]:setSprite(iconAtlas, iconName)
rightBtn:addClickListener(function() self.rightBtn:addClickListener(function()
self:refreshModule(rightIdx) self:refreshModule(rightIdx)
end) end)
if moduleCell:getShowEntranceRedPoint() then if moduleCell:getShowEntranceRedPoint() then
rightBtn:addRedPoint(-65, 35, 0.6) self.rightBtn:addRedPoint(-65, 35, 0.6)
else else
rightBtn:removeRedPoint() self.rightBtn:removeRedPoint()
end end
end end
@ -188,4 +192,13 @@ function MainComp:refreshStageFormaion()
end end
end end
function MainComp:getDailyChallengeIconPos()
if self:getCurLeftModuleIdx() == GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE then
return self.leftBtn:getPosition()
end
if self:getCurRightModuleIdx() == GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE then
return self.rightBtn:getPosition()
end
end
return MainComp return MainComp

View File

@ -403,7 +403,6 @@ end
function MainCityUI:openOrCloseLeftSideBar() function MainCityUI:openOrCloseLeftSideBar()
ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose() ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose()
self:refreshLeftBtns()
if self.isShowLeftSideBarArrowRedPoint ~= nil then if self.isShowLeftSideBarArrowRedPoint ~= nil then
local isShowLeftSideBarArrowRedPoint = self.isShowLeftSideBarArrowRedPoint local isShowLeftSideBarArrowRedPoint = self.isShowLeftSideBarArrowRedPoint
self.isShowLeftSideBarArrowRedPoint = nil self.isShowLeftSideBarArrowRedPoint = nil
@ -470,7 +469,6 @@ end
function MainCityUI:openOrCloseRightSideBar() function MainCityUI:openOrCloseRightSideBar()
ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose() ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose()
self:refreshRightBtns()
if self.isShowRightSideBarArrowRedPoint ~= nil then if self.isShowRightSideBarArrowRedPoint ~= nil then
local isShowRightSideBarArrowRedPoint = self.isShowRightSideBarArrowRedPoint local isShowRightSideBarArrowRedPoint = self.isShowRightSideBarArrowRedPoint
self.isShowRightSideBarArrowRedPoint = nil self.isShowRightSideBarArrowRedPoint = nil
@ -969,4 +967,63 @@ function MainCityUI:checkGift()
end end
end end
function MainCityUI:getTaskIconPos()
return self.taskBtn:getPosition()
end
function MainCityUI:getMallIconPos()
return self.bottomBtnSpines[GConst.MainCityConst.BOTTOM_PAGE.SHOP]:getPosition()
end
function MainCityUI:getDailyChallengeIconPos()
return self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:getDailyChallengeIconPos()
end
function MainCityUI:getSideBarActIconPos(moduleKey)
for name, cell in pairs(self.leftBarList) do
if moduleKey == cell:getModuleKey() then
return cell:getBaseObject():getPosition()
end
end
for name, cell in pairs(self.rightBarList) do
if moduleKey == cell:getModuleKey() then
return cell:getBaseObject():getPosition()
end
end
return nil
end
function MainCityUI:isInSideBarLeft(moduleKey)
for name, cell in pairs(self.leftBarList) do
if moduleKey == cell:getModuleKey() then
return true
end
end
return false
end
function MainCityUI:isInSideBarRight(moduleKey)
for name, cell in pairs(self.rightBarList) do
if moduleKey == cell:getModuleKey() then
return true
end
end
return false
end
function MainCityUI:isActivSideBarModule(moduleKey)
for name, cell in pairs(self.leftBarList) do
if moduleKey == cell:getModuleKey() then
return cell:getIsActive() and cell:getIsVisible()
end
end
for name, cell in pairs(self.rightBarList) do
if moduleKey == cell:getModuleKey() then
return cell:getIsActive() and cell:getIsVisible()
end
end
return nil
end
return MainCityUI return MainCityUI

View File

@ -29,54 +29,114 @@ end
function ModuleUnlockUI:onLoadRootComplete() function ModuleUnlockUI:onLoadRootComplete()
self.uiMap = self.root:genAllChildren() self.uiMap = self.root:genAllChildren()
self.uiMap["module_unlock_ui.bg"]:addClickListener(function()
self:showNextModuleUnlockAnimation() self.bg = self.uiMap["module_unlock_ui.bg"]
self.bg:addClickListener(function()
if not self.canClick then
return
end
self:showModuleUnlockVanishAnim()
end) end)
self.moduleNameTx = self.uiMap["module_unlock_ui.bg.name_tx"]
self.moduleNameTx = self.uiMap["module_unlock_ui.name_tx"]
self.moduleIcon = self.uiMap["module_unlock_ui.icon"] self.moduleIcon = self.uiMap["module_unlock_ui.icon"]
self.uiMap["module_unlock_ui.continue"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_TO_CONTINUE)) self.titleTx = self.uiMap["module_unlock_ui.bg.spine_title.title_tx"]
self.uiMap["module_unlock_ui.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.FUNC_UNLOCK)) self.spineTitle = self.uiMap["module_unlock_ui.bg.spine_title"]
self.spineCircle = self.uiMap["module_unlock_ui.icon.spine_circle"]
self.spineStar = self.uiMap["module_unlock_ui.spine_star"]
self.uiMap["module_unlock_ui.bg.continue"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_TO_CONTINUE))
self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.FUNC_UNLOCK))
self:showModuleUnlockAnimation() self.initIconPos = self.uiMap["module_unlock_ui.init_pos"]:getPosition()
self.canvasGroupBg = self.bg:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
self.canvasGroupTitleTx = self.titleTx:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
self.canvasGroupIcon = self.moduleIcon:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
self:checkShowNext()
end end
function ModuleUnlockUI:showNextModuleUnlockAnimation() -- 检查是否展示
if self:showModuleUnlockAnimation() then function ModuleUnlockUI:checkShowNext()
self:playUnlockAnimation()
end
end
function ModuleUnlockUI:showModuleUnlockAnimation()
if #self.unlockList <= 0 then if #self.unlockList <= 0 then
self:closeUI() self:closeUI()
return false return
end end
local moduleKey = table.remove(self.unlockList, 1) self.moduleKey = table.remove(self.unlockList, 1)
local info = ConfigManager:getConfig("func_open")[moduleKey] local info = ConfigManager:getConfig("func_open")[self.moduleKey]
local i18nInfo = I18N:getConfig("func_open")[moduleKey] local i18nInfo = I18N:getConfig("func_open")[self.moduleKey]
if info == nil or i18nInfo == nil then if info == nil or i18nInfo == nil then
self:closeUI() self:closeUI()
return false return
end end
self.moduleNameTx:setText(i18nInfo.name) self.moduleNameTx:setText(i18nInfo.name)
if info.icon then if info.icon then
self.moduleIcon:setSprite(GConst.ATLAS_PATH.MODULE, info.icon) self.moduleIcon:setSprite(GConst.ATLAS_PATH.MODULE, info.icon)
end end
return true
-- 侧边栏功能,检查处理侧边栏打开
if not ModuleManager.MaincityManager:isActivSideBarModule(self.moduleKey) then
if ModuleManager.MaincityManager:getModuleInSideBarWhere(self.moduleKey) == -1 then
ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose()
elseif ModuleManager.MaincityManager:getModuleInSideBarWhere(self.moduleKey) == 1 then
ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose()
end
end
self:showModuleUnlockAppearAnim()
end end
function ModuleUnlockUI:playUnlockAnimation() -- 出现
if self.unlockAnimationSeq == nil then function ModuleUnlockUI:showModuleUnlockAppearAnim()
self.unlockAnimationSeq = self.root:createBindTweenSequence() self.canClick = false
local scaleTween1 = self.root:getTransform():DOScale(1.05, 0.15) self.canvasGroupBg.alpha = 0
self.unlockAnimationSeq:Append(scaleTween1) self.canvasGroupTitleTx.alpha = 0
self.canvasGroupIcon.alpha = 0
self.titleTx:setLocalScale(0,0,0)
self.moduleIcon:setLocalScale(1,1,1)
self.moduleIcon:setPosition(self.initIconPos.x, self.initIconPos.y, self.initIconPos.z)
local scaleTween2 = self.root:getTransform():DOScale(1, 0.2) self.spineTitle:playAnim("idle", false, true, true)
self.unlockAnimationSeq:Append(scaleTween2) self:performWithDelayGlobal(function()
self.unlockAnimationSeq:SetAutoKill(false) self.spineCircle:playAnim("idle", false, true, true)
end, 0.17)
if self.animAppear == nil then
self.animAppear = self.root:createBindTweenSequence()
self.animAppear:Insert(0, self.canvasGroupBg:DOFade(1, 0.14))
self.animAppear:Insert(0.13, self.canvasGroupIcon:DOFade(1, 0.07))
self.animAppear:Insert(0.13, self.moduleIcon:getTransform():DOScale(1.2, 0.07))
self.animAppear:Insert(0.17, self.canvasGroupTitleTx:DOFade(1, 0.1))
self.animAppear:Insert(0.17, self.titleTx:getTransform():DOScale(1.2, 0.1))
self.animAppear:Insert(0.2, self.moduleIcon:getTransform():DOScale(1, 0.13))
self.animAppear:SetAutoKill(false)
self.animAppear:OnComplete(function()
self.canClick = true
end)
else else
self.unlockAnimationSeq:Restart() self.animAppear:Restart()
end
end
-- 消失
function ModuleUnlockUI:showModuleUnlockVanishAnim()
self.canClick = false
self.animVanish = self.root:createBindTweenSequence()
self.animVanish:Insert(0, self.canvasGroupBg:DOFade(0, 0.1))
self.animVanish:Insert(0, self.titleTx:getTransform():DOScale(1, 0.16))
self.animVanish:Insert(0, self.moduleIcon:getTransform():DOScale(0.46, 0.1))
self.animVanish:Insert(0.33, self.canvasGroupIcon:DOFade(0, 0.07))
local targetPos = ModuleManager.MaincityManager:getModuleEntrancePos(self.moduleKey)
if targetPos then
self.spineStar:setPosition(targetPos.x, targetPos.y, targetPos.z)
self.animVanish:Insert(0.17, self.moduleIcon:getTransform():DOMove(CS.UnityEngine.Vector3(targetPos.x, targetPos.y, targetPos.z), 0.16))
self.animVanish:OnComplete(function()
self.animVanish = nil
self.spineStar:playAnimComplete("idle", false, true, function()
self:checkShowNext()
end)
end)
else
self.animVanish:OnComplete(function()
self.animVanish = nil
self:checkShowNext()
end)
end end
end end

View File

@ -1,7 +1,6 @@
local ActivityData = class("ActivityData", BaseData) local ActivityData = class("ActivityData", BaseData)
function ActivityData:init(data) function ActivityData:init(data)
end end
return ActivityData return ActivityData