feat(memory): 搜索 overlay 遮罩与调频目标采样优化
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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<Sprite>(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)
|
||||
|
||||
Reference in New Issue
Block a user