From f35edeabe842754a1730e3f2969124cf9be60f4a Mon Sep 17 00:00:00 2001 From: bottlefish <781230111@qq.com> Date: Tue, 30 Jun 2026 20:39:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(memory):=20=E6=90=9C=E7=B4=A2=20overlay=20?= =?UTF-8?q?=E9=81=AE=E7=BD=A9=E4=B8=8E=E8=B0=83=E9=A2=91=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E9=87=87=E6=A0=B7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../Scripts/FixSystem/Memory/MemoryProcess.cs | 90 ++++++++++++++++--- 1 file changed, 76 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs b/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs index 26112fbd1..673a93bfe 100644 --- a/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs +++ b/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs @@ -59,6 +59,12 @@ namespace AibisDream.FixSystem [SerializeField] private bool useSpriteShaderTuning = true; [SerializeField] private CanvasGroup playBackground; + [SerializeField] private Graphic standbyOverlay; + [SerializeField, Range(0f, 1f)] private float standbyOverlayMinAlpha = 0.04f; + [SerializeField, Range(0f, 1f)] private float standbyOverlayMaxAlpha = 0.12f; + [SerializeField, Range(0f, 1f)] private float searchOverlayAlpha = 0.85f; + [SerializeField] private float standbyOverlayPulseDuration = 0.8f; + [SerializeField] private float searchTargetMinDistanceFromStart = 2.5f; [SerializeField] private GameObject memoryGroup; @@ -72,6 +78,7 @@ namespace AibisDream.FixSystem [SerializeField] private Material fadeMaterial; private Material runtimeMemoryMaterial; private Material runtimeNoColorMemoryMaterial; + private Tween overlayTween; public void OpenMemoryView() { @@ -94,6 +101,8 @@ namespace AibisDream.FixSystem public void CloseMemoryView() { + StopStandbyOverlay(); + SetOverlayAlpha(0f); memoryView.gameObject.SetActive(false); memoryGroup.SetActive(false); } @@ -116,6 +125,7 @@ namespace AibisDream.FixSystem PunchTapeManager.Instance.OpenFavoritesPanel(); playBackground.gameObject.SetActive(false); playBackground.alpha = 0; + StartStandbyOverlay(); } public void OnExit() @@ -180,6 +190,7 @@ namespace AibisDream.FixSystem private void OnDestroy() { + overlayTween?.Kill(); if (runtimeMemoryMaterial != null) Destroy(runtimeMemoryMaterial); if (runtimeNoColorMemoryMaterial != null) @@ -205,17 +216,23 @@ namespace AibisDream.FixSystem OnSearchComplete(); } - private float GetRandomNumber() + private float GetRandomSearchTarget(MemorySlider slider) { - // 随机决定选择哪个区间 - if (UnityEngine.Random.value < 0.5f) // 50% 概率选择第一个区间 - { - return UnityEngine.Random.Range(0.5f, 2f); - } - else // 50% 概率选择第二个区间 - { - return UnityEngine.Random.Range(4f, 5.5f); - } + float start = slider != null ? slider.StartValue : 0f; + float max = slider != null ? slider.MaxValue : 6f; + float minDistance = Mathf.Max(0f, searchTargetMinDistanceFromStart); + float nearBandMin = start + minDistance; + float nearBandMax = start + (max - start) * 0.55f; + float farBandMin = max - 1.5f; + float farBandMax = max - 0.5f; + + if (nearBandMin >= nearBandMax) + return UnityEngine.Random.Range(farBandMin, farBandMax); + + if (UnityEngine.Random.value < 0.5f) + return UnityEngine.Random.Range(nearBandMin, nearBandMax); + + return UnityEngine.Random.Range(farBandMin, farBandMax); } private void OnSearchComplete() @@ -303,6 +320,7 @@ namespace AibisDream.FixSystem SetMemoryColor(Color.black); SetVolumeWeight(memoryProcessVolume, 0f); _activePunchTape = null; + StartStandbyOverlay(); playBackground.gameObject.SetActive(false); playBackground.alpha = 0; @@ -390,13 +408,14 @@ namespace AibisDream.FixSystem isPlayingFaderSound = false; } - frequencySlider.TargetValue = GetRandomNumber(); - claritySlider.TargetValue = GetRandomNumber(); + frequencySlider.TargetValue = GetRandomSearchTarget(frequencySlider); + claritySlider.TargetValue = GetRandomSearchTarget(claritySlider); PunchTapeManager.Instance.CloseFavoritesPanel(); if (punchTape == null) { Debug.Log("no punchTape"); + StartStandbyOverlay(); yield break; } @@ -408,6 +427,9 @@ namespace AibisDream.FixSystem yield break; } + StopStandbyOverlay(); + ShowSearchOverlay(); + var searchMemoryKey = string.Format(MemorySpritePath, _activePunchTape.MemoryIndex); var searchMemoryHandle = ResourceSystem.LoadAsync(searchMemoryKey); yield return searchMemoryHandle; @@ -420,17 +442,16 @@ namespace AibisDream.FixSystem Debug.LogError("Memory not found: " + searchMemoryKey); } - SetVolumeWeight(memoryProcessVolume, 1f); AudioManager.Instance.PlaySfx("event:/Scriptal/mem_load"); yield return new WaitForSeconds(SearchStartDelay); AudioManager.Instance.SetSfxParam("event:/Amb/amb_mem_tuning", "is_mem_tuning", 1); SetMemoryColor(Color.white); - SetVolumeWeight(memoryProcessVolume, 0f); isProcessing = true; frequencySlider.PrepareForSearch(); claritySlider.PrepareForSearch(); + ClearSearchOverlay(); bool freqUnlocked = false; bool clarityUnlocked = false; frequencySlider.UnlockSlider(() => freqUnlocked = true); @@ -562,6 +583,47 @@ namespace AibisDream.FixSystem return memoryFinishedImage != null || legacyMemoryFinishedSpriteRenderer != null; } + private void StartStandbyOverlay() + { + if (standbyOverlay == null || isProcessing) + return; + + overlayTween?.Kill(); + SetOverlayAlpha(standbyOverlayMinAlpha); + overlayTween = standbyOverlay + .DOFade(standbyOverlayMaxAlpha, Mathf.Max(0.01f, standbyOverlayPulseDuration)) + .SetLoops(-1, LoopType.Yoyo) + .SetEase(Ease.InOutSine); + } + + private void StopStandbyOverlay() + { + overlayTween?.Kill(); + overlayTween = null; + } + + private void ShowSearchOverlay() + { + StopStandbyOverlay(); + SetOverlayAlpha(searchOverlayAlpha); + } + + private void ClearSearchOverlay() + { + StopStandbyOverlay(); + SetOverlayAlpha(0f); + } + + private void SetOverlayAlpha(float alpha) + { + if (standbyOverlay == null) + return; + + Color color = standbyOverlay.color; + color.a = Mathf.Clamp01(alpha); + standbyOverlay.color = color; + } + private void SetMemorySprite(Sprite sprite) { if (memoryFinishedImage != null)