添加音效
This commit is contained in:
@@ -9,7 +9,10 @@ using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using Cinemachine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
using System;
|
||||
using AibisDream.Kit;
|
||||
using FMODUnity;
|
||||
|
||||
public class MemoryProcess : MonoBehaviour
|
||||
{
|
||||
@@ -35,6 +38,10 @@ public class MemoryProcess : MonoBehaviour
|
||||
private float lockThreshold = 0.06f; // 锁定阈值
|
||||
|
||||
private bool isProcessing = false; // 新增变量来追踪是否正在处理记忆
|
||||
private FMOD.Studio.EventInstance faderSoundInstance; // 添加音效实例变量
|
||||
private bool isPlayingFaderSound = false; // 追踪音效是否正在播放
|
||||
private float lastFrequencyValue; // 记录上一帧的频率值
|
||||
private float lastClarityValue; // 记录上一帧的清晰度值
|
||||
|
||||
private bool isColorful = false; //
|
||||
private bool isFrequencyFound = false; // 追踪是否找到目标频率
|
||||
@@ -58,14 +65,14 @@ public class MemoryProcess : MonoBehaviour
|
||||
|
||||
public IEnumerator DropMemoryProjector()
|
||||
{
|
||||
Sequence zoomInSequence = DOTween.Sequence();
|
||||
DG.Tweening.Sequence zoomInSequence = DOTween.Sequence();
|
||||
zoomInSequence.Append(projector.transform.DOLocalMoveY(-5, 2f).SetEase(Ease.OutElastic, 0.5f));
|
||||
yield return zoomInSequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
public void PullMemoryProjector()
|
||||
{
|
||||
Sequence zoomOutSequence = DOTween.Sequence();
|
||||
DG.Tweening.Sequence zoomOutSequence = DOTween.Sequence();
|
||||
zoomOutSequence.Append(projector.transform.DOLocalMoveY(0, 2f).SetEase(Ease.OutElastic, 0.5f));
|
||||
//yield return zoomOutSequence.WaitForCompletion();
|
||||
}
|
||||
@@ -143,7 +150,11 @@ public class MemoryProcess : MonoBehaviour
|
||||
);
|
||||
float t = Mathf.Clamp01(distance / maxDistance);
|
||||
UpdateFrequencyShaderParameters(t);
|
||||
CheckIfFound(t, ref isFrequencyFound); // 这里更新 isFrequencyFound
|
||||
CheckIfFound(t, ref isFrequencyFound);
|
||||
|
||||
// 控制音效
|
||||
float speed = Mathf.Abs(Input.GetAxis("Mouse X")); // 获取鼠标移动速度
|
||||
UpdateFaderSound(speed);
|
||||
}
|
||||
|
||||
void OnClarityChanged(float value)
|
||||
@@ -156,7 +167,11 @@ public class MemoryProcess : MonoBehaviour
|
||||
float t = Mathf.Clamp01(distance / maxDistance);
|
||||
|
||||
UpdateClarityShaderParameters(t);
|
||||
CheckIfFound(t, ref isClarityFound); // 这里更新 isClarityFound
|
||||
CheckIfFound(t, ref isClarityFound);
|
||||
|
||||
// 控制音效
|
||||
float speed = Mathf.Abs(Input.GetAxis("Mouse X")); // 获取鼠标移动速度
|
||||
UpdateFaderSound(speed);
|
||||
}
|
||||
|
||||
void OnSearchComplete()
|
||||
@@ -164,6 +179,7 @@ public class MemoryProcess : MonoBehaviour
|
||||
Debug.Log("Memory search completed.");
|
||||
frequencySlider.interactable = false;
|
||||
claritySlider.interactable = false;
|
||||
AudioManager.Instance.SetSfxParam("event:/Amb/amb_mem_tuning", "is_mem_tuning", 0);
|
||||
StartCoroutine(PlayMemory());
|
||||
}
|
||||
|
||||
@@ -204,11 +220,13 @@ public class MemoryProcess : MonoBehaviour
|
||||
isFrequencyFound = false;
|
||||
isClarityFound = false;
|
||||
isProcessing = false;
|
||||
isPlayingFaderSound = false;
|
||||
if (frequencySlider != null)
|
||||
{
|
||||
frequencySlider.onValueChanged.AddListener(OnFrequencyChanged);
|
||||
frequencySlider.gameObject.SetActive(false);
|
||||
frequencySlider.value = 3;
|
||||
lastFrequencyValue = frequencySlider.value;
|
||||
frequencySlider.interactable = true;
|
||||
}
|
||||
|
||||
@@ -217,6 +235,7 @@ public class MemoryProcess : MonoBehaviour
|
||||
claritySlider.onValueChanged.AddListener(OnClarityChanged);
|
||||
claritySlider.gameObject.SetActive(false);
|
||||
claritySlider.value = 3;
|
||||
lastClarityValue = claritySlider.value;
|
||||
claritySlider.interactable = true;
|
||||
}
|
||||
fadeMaterial.SetFloat("_DirectionalDistortionFade",-15f);
|
||||
@@ -276,6 +295,7 @@ public class MemoryProcess : MonoBehaviour
|
||||
playBackground.gameObject.SetActive(true);
|
||||
//FavoritesManager.Instance.CloseFavorites();
|
||||
playBackground.alpha=0;
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/mem_play");
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
MemoryClarityVloume.weight=0;
|
||||
Memoryfrequencyloume.weight=0;
|
||||
@@ -288,6 +308,7 @@ public class MemoryProcess : MonoBehaviour
|
||||
playBackground.gameObject.SetActive(true);
|
||||
//FavoritesManager.Instance.CloseFavorites();
|
||||
playBackground.alpha=0;
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/mem_play");
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
// Set material properties
|
||||
MemoryClarityVloume.weight=0;
|
||||
@@ -326,8 +347,10 @@ public class MemoryProcess : MonoBehaviour
|
||||
Debug.LogError("Memory not found: " + PunchTape.MemoryIndex);
|
||||
}
|
||||
MemoryProcessVloume.weight=1;
|
||||
AudioManager.Instance.PlaySfx("event:/Scriptal/mem_load");
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
AudioManager.Instance.SetSfxParam("event:/Amb/amb_mem_tuning", "is_mem_tuning", 1);
|
||||
|
||||
|
||||
memoryFinishedspRender.color=Color.white;
|
||||
@@ -337,7 +360,7 @@ public class MemoryProcess : MonoBehaviour
|
||||
isProcessing = true; // 开始处理,设置为true
|
||||
frequencySlider.gameObject.SetActive(true);
|
||||
claritySlider.gameObject.SetActive(true);
|
||||
Sequence memorySequence = DOTween.Sequence();
|
||||
DG.Tweening.Sequence memorySequence = DOTween.Sequence();
|
||||
yield return memorySequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
@@ -346,4 +369,25 @@ public class MemoryProcess : MonoBehaviour
|
||||
{
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
private void UpdateFaderSound(float speed)
|
||||
{
|
||||
if (speed > 0.01f) // 如果速度大于阈值
|
||||
{
|
||||
if (!isPlayingFaderSound)
|
||||
{
|
||||
// 开始播放音效
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/mem_fader");
|
||||
isPlayingFaderSound = true;
|
||||
}
|
||||
// 更新音效参数
|
||||
AudioManager.Instance.SetSfxParam("event:/ActionFB/mem_fader", "mem_fader_speed", speed);
|
||||
}
|
||||
else if (isPlayingFaderSound)
|
||||
{
|
||||
// 停止音效
|
||||
AudioManager.Instance.StopSfx("event:/ActionFB/mem_fader");
|
||||
isPlayingFaderSound = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user