From c21cece463c61eb7b7b80637568f36ca66d34fc3 Mon Sep 17 00:00:00 2001 From: puxuan <413323644@qq.com> Date: Wed, 22 Oct 2025 15:05:56 +0800 Subject: [PATCH] fix bug --- lua/app/bf/unity/ui_spine_object.lua | 110 ++++++++++++++---- lua/app/common/module_manager.lua | 99 ++++++++++++++-- .../localization_global_const.lua | 3 + lua/app/config/strings/cn/global.lua | 3 + lua/app/module/maincity/maincity_manager.lua | 17 +-- .../cell/side_bar_act_sprint_cell.lua | 3 - lua/app/ui/main_city/component/main_comp.lua | 6 +- lua/app/ui/main_city/main_city_ui.lua | 10 +- lua/app/ui/main_city/module_unlock_ui.lua | 16 +-- 9 files changed, 201 insertions(+), 66 deletions(-) diff --git a/lua/app/bf/unity/ui_spine_object.lua b/lua/app/bf/unity/ui_spine_object.lua index ab3950be..d179bd4f 100644 --- a/lua/app/bf/unity/ui_spine_object.lua +++ b/lua/app/bf/unity/ui_spine_object.lua @@ -40,7 +40,32 @@ function UISpineObject:getAnimationState(forceRefresh) return self.animationState end +---- loop必须为false +function UISpineObject:playAnimOnPercent(animName, loop, forceRefresh, forceGetSG, percent) + local trackEntry = self:playAnim(animName, loop, forceRefresh, forceGetSG) + local spineAnim = self:getAnimation(trackEntry) + local duration = spineAnim.Duration + trackEntry.AnimationStart = percent * duration +end + +function UISpineObject:playAnimOnUpdate(animName, loop, forceRefresh, forceGetSG, percent) + self:killAniCompleteSeq() + self:getAnimationState(forceGetSG) + local trackEntry = self:playAnim(animName, loop, forceRefresh, forceGetSG) + local spineAnim = self:getAnimation(trackEntry) + local startTime = spineAnim.Duration * percent + + if self.animationState then + local trackEntry = self.animationState:SetAnimation(startTime, animName, loop) + if forceRefresh then + self.skeletonGraphic:Update(startTime) + end + return trackEntry + end +end + function UISpineObject:playAnim(animName, loop, forceRefresh, forceGetSG) + self:killAniCompleteSeq() self:getAnimationState(forceGetSG) if self.animationState then local trackEntry = self.animationState:SetAnimation(0, animName, loop) @@ -101,19 +126,41 @@ function UISpineObject:rePlayAnim(animName, loop, forceRefresh) end end -function UISpineObject:playAnimComplete(animName, loop, forceRefresh, complete, forceGetSG) +function UISpineObject:playAnimCompleteOnPer(animName, loop, forceRefresh, complete, forceGetSG, customTime, customCallback, percent) + local trackEntry = self:playAnim(animName, loop, forceRefresh, forceGetSG) + local spineAnim = self:getAnimation(trackEntry) + local duration = spineAnim.Duration + self:killAniCompleteSeq() + self.animCompleteSeq = self:createBindTweenSequence() + self.animCompleteSeq:AppendInterval(duration - (percent * duration)) + self.animCompleteSeq:AppendCallback(complete) + if customTime and customCallback then + self.animCompleteSeq:InsertCallback(customTime, customCallback) + end + trackEntry.AnimationStart = percent * duration +end + +function UISpineObject:playAnimComplete(animName, loop, forceRefresh, complete, forceGetSG, customTime, customCallback) local spineAnim = self:getAnimation(self:playAnim(animName, loop, forceRefresh, forceGetSG)) local duration = spineAnim.Duration - if self.playAnimCompleteSeq then - self.playAnimCompleteSeq:Kill() - self.playAnimCompleteSeq = nil + self:killAniCompleteSeq() + self.animCompleteSeq = self:createBindTweenSequence() + self.animCompleteSeq:AppendInterval(duration) + self.animCompleteSeq:AppendCallback(complete) + if customTime and customCallback then + self.animCompleteSeq:InsertCallback(customTime, customCallback) end - self.playAnimCompleteSeq = self:createBindTweenSequence() - self.playAnimCompleteSeq:AppendInterval(duration) - self.playAnimCompleteSeq:OnComplete(complete) return duration end + +function UISpineObject:killAniCompleteSeq() + if self.animCompleteSeq then + self.animCompleteSeq:Kill() + self.animCompleteSeq = nil + end +end + function UISpineObject:findAnim(animName) self:getAnimationState() if self.animationState then @@ -129,13 +176,18 @@ function UISpineObject:getAnimation(trackEntry) return trackEntry and trackEntry.Animation end +function UISpineObject:setAttachment(slotName, attachmentName) + self:getSkeletonGraphic().Skeleton:SetAttachment(slotName, attachmentName) +end + + function UISpineObject:getAnimSpeed() if self.skeletonGraphic then return self.skeletonGraphic.timeScale end end -function UISpineObject:setTimeScale(timeScale) +function UISpineObject:setAnimSpeed(timeScale) if self.skeletonGraphic then self.skeletonGraphic.timeScale = timeScale end @@ -153,6 +205,18 @@ function UISpineObject:setIsUnScaledTime(value) end end +function UISpineObject:getAnimationDuration(animationName) + local spinAnimation = self:findAnim(animationName) + if spinAnimation == nil then + return 0 + end + return spinAnimation.Duration +end + +function UISpineObject:setDefaultMix(mixDuration) + self:getSkeletonGraphic().skeletonDataAsset:GetAnimationStateData().DefaultMix = mixDuration +end + function UISpineObject:clearTrack() if self.animationState then self.animationState:ClearTrack(0) @@ -248,26 +312,26 @@ function UISpineObject:onLoadAsset() end function UISpineObject:addAnimationCompleteCallback(callback) - if self._animationStateCompleteCallback then - return - end - self._animationStateCompleteCallback = function(entry) - callback(entry.Animation.Name) - end - local state = self:getAnimationState() - if state then - state:Complete("+", self._animationStateCompleteCallback) + if self._animationStateCompleteCallback then + return + end + self._animationStateCompleteCallback = function(entry) + callback(entry.Animation.Name) + end + local state = self:getAnimationState() + if state then + state:Complete("+", self._animationStateCompleteCallback) end end function UISpineObject:removeAnimationCompleteCallback() if self._animationStateCompleteCallback then - local state = self:getAnimationState() - if state then - state:Complete("-", self._animationStateCompleteCallback) - end - self._animationStateCompleteCallback = nil - end + local state = self:getAnimationState() + if state then + state:Complete("-", self._animationStateCompleteCallback) + end + self._animationStateCompleteCallback = nil + end end function UISpineObject:setTimeScale(timeScale) diff --git a/lua/app/common/module_manager.lua b/lua/app/common/module_manager.lua index 0f9cdd44..24d0c6c3 100644 --- a/lua/app/common/module_manager.lua +++ b/lua/app/common/module_manager.lua @@ -164,27 +164,102 @@ end -- 功能是否开启 function ModuleManager:getIsOpen(key, hideToast) - local cfg = ConfigManager:getConfig("func_open")[key] - if cfg == nil then + local cfg = ConfigManager:getConfig("func_open")[key] + if cfg == nil then return true end - -- 优先判断等级 + -- 且 + if cfg.sever_time then + local serverDay = DataManager.PlayerData:getServerOpenDay() + local isOpen = serverDay >= cfg.sever_time + if not hideToast and not isOpen then + if cfg.level then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_LEVEL_SEVER, cfg.level, serverDay, cfg.sever_time)) + elseif cfg.stage then + local str = DataManager.ChapterData:getChapterNameXYMode(cfg.stage) + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_STAGE_SEVER, str, serverDay, cfg.sever_time)) + else + -- 策划说必定有level或stage + end + end + if not isOpen then + return false + end + end + if cfg.time then + local createDay = DataManager.PlayerData:getCreateDay() + local isOpen = createDay >= cfg.time + if not hideToast and not isOpen then + if cfg.level then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_LEVEL_SEVER, cfg.level, createDay, cfg.time)) + elseif cfg.stage then + local str = DataManager.ChapterData:getChapterNameXYMode(cfg.stage) + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_STAGE_SEVER, str, createDay, cfg.time)) + else + -- 策划说必定有level或stage + end + end + if not isOpen then + return false + end + end if cfg.level then local isOpen = DataManager.PlayerData:getLv() >= cfg.level if not hideToast and not isOpen then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_LEVEL, cfg.level)) end - return isOpen - elseif cfg.stage then -- 没有填等级字段就判断关卡 - local isOpen = DataManager.ChapterData:getMaxChapterId() >= cfg.stage - if not hideToast and not isOpen then - local page = DataManager.ChapterData:getChapterPage(cfg.stage) - local stage = DataManager.ChapterData:getChapterStage(cfg.stage) - GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_STAGE, page .. "-" .. stage)) + if not isOpen then + return false end - return isOpen end - return true + if cfg.stage then + local isOpen = DataManager.ChapterData:getChapterPassed(cfg.stage) + if not hideToast and not isOpen then + local str = DataManager.ChapterData:getChapterNameXYMode(cfg.stage) + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_STAGE, str)) + end + if not isOpen then + return false + end + end + + -- 或 + local stage2, time2 + if cfg.stage_2 then + local isOpen = DataManager.ChapterData:getChapterPassed(cfg.stage_2) + if isOpen then + return true + else + stage2 = cfg.stage_2 + end + end + if cfg.time_2 then + local createDay = DataManager.PlayerData:getCreateDay() + local isOpen = createDay >= cfg.time_2 + if isOpen then + return true + else + time2 = cfg.time_2 + end + end + if stage2 and time2 then + if not hideToast then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_STAGE_OR_SEVER, stage2, time2)) + end + return false + elseif stage2 and not cfg.time_2 then + if not hideToast then + local str = DataManager.ChapterData:getChapterNameXYMode(stage2) + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_STAGE, str)) + end + return false + elseif time2 and not cfg.stage_2 then + if not hideToast then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.FUNC_OPEN_SEVER, time2)) + end + return false + end + return true end function ModuleManager:showPop(key) diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index 014e534a..6c4a8698 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -932,6 +932,9 @@ local LocalizationGlobalConst = DUNGEON_TITLE_7 = "DUNGEON_TITLE_7", DUNGEON_TITLE_8 = "DUNGEON_TITLE_8", DUNGEON_TITLE_9 = "DUNGEON_TITLE_9", + FUNC_OPEN_STAGE_SEVER = "FUNC_OPEN_STAGE_SEVER", + FUNC_OPEN_LEVEL_SEVER = "FUNC_OPEN_LEVEL_SEVER", + FUNC_OPEN_STAGE_OR_SEVER = "FUNC_OPEN_STAGE_OR_SEVER", } return LocalizationGlobalConst \ No newline at end of file diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 5b6cdf47..13438584 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -932,6 +932,9 @@ local localization_global = ["DUNGEON_TITLE_7"] = "材料探索", ["DUNGEON_TITLE_8"] = "金币", ["DUNGEON_TITLE_9"] = "材料", + ["FUNC_OPEN_STAGE_SEVER"] = "通关章节{0}且{1}/{2}天后解锁", + ["FUNC_OPEN_LEVEL_SEVER"] = "等级达到{0}且{1}/{2}天后解锁", + ["FUNC_OPEN_STAGE_OR_SEVER"] = "通关章节{0}或{1}/{2}天后解锁", } return localization_global \ No newline at end of file diff --git a/lua/app/module/maincity/maincity_manager.lua b/lua/app/module/maincity/maincity_manager.lua index 79985b31..960f2cfc 100644 --- a/lua/app/module/maincity/maincity_manager.lua +++ b/lua/app/module/maincity/maincity_manager.lua @@ -4,13 +4,8 @@ function MaincityManager:showMainCityUI(isFirstEnter, targetIndex) UIManager:showUI(UIManager.UI_PATH.MAINCITY_UI, {isFirstEnter = isFirstEnter, targetIndex = targetIndex}) end -function MaincityManager:showModuleUnlockUI() - local chapterId = DataManager.PlayerData:getModuleUnlockChapter() - if chapterId <= 0 then - return - end - DataManager.PlayerData:markShowModuleUnlock() - UIManager:showUI("app/ui/main_city/module_unlock_ui", {chapterId = chapterId}) +function MaincityManager:showModuleUnlockUI(params) + UIManager:showUI("app/ui/main_city/module_unlock_ui", params) end function MaincityManager:showChapterBoxUI(chapterId) @@ -46,10 +41,10 @@ function MaincityManager:getFuncOpenShowList() if ModuleManager:showPop(moduleKey) and not LocalData:getFuncOpenShowList()[moduleKey] then if ModuleManager:getIsOpen(moduleKey, true) then table.insert(showList, moduleKey) - elseif moduleKey == ModuleManager.MODULE_KEY.EQUIP_SKIN and DataManager.WeaponData:isOpen() then - table.insert(showList, moduleKey) - elseif moduleKey == ModuleManager.MODULE_KEY.SKIN and DataManager.SkinData:isOpen() then - table.insert(showList, moduleKey) + -- elseif moduleKey == ModuleManager.MODULE_KEY.EQUIP_SKIN and DataManager.WeaponData:isOpen() then + -- table.insert(showList, moduleKey) + -- elseif moduleKey == ModuleManager.MODULE_KEY.SKIN and DataManager.SkinData:isOpen() then + -- table.insert(showList, moduleKey) end end end diff --git a/lua/app/ui/main_city/cell/side_bar_act_sprint_cell.lua b/lua/app/ui/main_city/cell/side_bar_act_sprint_cell.lua index 800ab03f..e295d3a1 100755 --- a/lua/app/ui/main_city/cell/side_bar_act_sprint_cell.lua +++ b/lua/app/ui/main_city/cell/side_bar_act_sprint_cell.lua @@ -39,15 +39,12 @@ function SideBarActSprintCell:_refreshTime() local remainTime = DataManager.ActSprintData:getRemainTime() if remainTime then self.timeBg:setActive(true) - self.timeBg:setAnchoredPositionY(-70) - self.txName:setAnchoredPositionY(5) if remainTime < 0 then remainTime = 0 end self.txTime:setText(Time:formatNumTimeStr(remainTime)) else self.timeBg:setActive(false) - self.txName:setAnchoredPositionY(5) end end diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index e110c514..031d450c 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -295,11 +295,13 @@ function MainComp:getDailyChallengeBtnPosition() end function MainComp:getIdleBtnPosition() - return self.leftBtn:getPosition() + local pos = self.leftBtn:getPosition() + return {x = pos.x + 0.5, y = pos.y + 0.5, z = 0} end function MainComp:getSummonBtnPosition() - return self.rightBtn:getPosition() + local pos = self.rightBtn:getPosition() + return {x = pos.x - 0.5, y = pos.y + 0.5, z = 0} end function MainComp:refreshHero() diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index d2b91b45..f61a91d7 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -650,14 +650,14 @@ function MainCityUI:checkMainPop() return end -- 检查功能弹窗 - if DataManager.PlayerData:getIfCanShowModuleUnlock() and not GFunc.isShenhe() then - ModuleManager.MaincityManager:showModuleUnlockUI() - return - end + -- if DataManager.PlayerData:getIfCanShowModuleUnlock() and not GFunc.isShenhe() then + -- ModuleManager.MaincityManager:showModuleUnlockUI() + -- return + -- end -- 功能解锁 local showFuncList = ModuleManager.MaincityManager:getFuncOpenShowList() if showFuncList and #showFuncList > 0 and not GFunc.isShenhe() then - ModuleManager.MaincityManager:showModuleUnlockUI() + ModuleManager.MaincityManager:showModuleUnlockUI(showFuncList) EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.REFRESH_MAIN_CITY_BOTTOM) return end diff --git a/lua/app/ui/main_city/module_unlock_ui.lua b/lua/app/ui/main_city/module_unlock_ui.lua index 5d4a8fc6..0157169a 100644 --- a/lua/app/ui/main_city/module_unlock_ui.lua +++ b/lua/app/ui/main_city/module_unlock_ui.lua @@ -17,18 +17,14 @@ function ModuleUnlockUI:onClose() self.animVanish:Kill() self.animVanish = nil end + if self.spineStar then + self.spineStar:killAniCompleteSeq() + end + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP) 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 + self.unlockList = params or {} end function ModuleUnlockUI:onLoadRootComplete() @@ -65,7 +61,7 @@ function ModuleUnlockUI:checkShowNext() return end self.moduleKey = table.remove(self.unlockList, 1) - ModuleManager.MaincityManager:markFuncOpen(self.moduleType) + ModuleManager.MaincityManager:markFuncOpen(self.moduleKey) local info = ConfigManager:getConfig("func_open")[self.moduleKey] local i18nInfo = I18N:getConfig("func_open")[self.moduleKey]