feat():为压力板、按钮、拉杆添加音效,为玩家移动添加音效

This commit is contained in:
2025-10-29 17:05:10 +08:00
parent 97a3a351d7
commit 3c438b3871
11 changed files with 512 additions and 4 deletions

View File

@@ -14,6 +14,10 @@ namespace Script.Gameplay.Facility
private bool isPressing = false;
private Vector3 buttonInitialPosition;
[SerializeField] private AudioClip turnSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource buttonSound;
private void Awake()
{
buttonInitialPosition = buttonPressPoint.transform.position;
@@ -37,12 +41,16 @@ namespace Script.Gameplay.Facility
isPressing = true;
// 按钮按下的动画或效果可以在这里添加
buttonPressPoint.transform.position = new Vector3(0, 0, 0);
buttonSound.clip = turnSound;
buttonSound.Play();
yield return new WaitForSeconds(signalDuration);
SendSignal(false, this.gameObject);
isPressing = false;
// 按钮弹起的动画或效果可以在这里添加
buttonPressPoint.transform.position = buttonInitialPosition;
buttonSound.clip = returnSound;
buttonSound.Play();
}
}

View File

@@ -9,6 +9,9 @@ namespace Script.Gameplay.Facility
{
private bool isPulled = false;
[SerializeField] private GameObject rotationPrefab;
[SerializeField] private AudioClip turnSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource LeverSound;
public override string GetInteractPrompt()
{
@@ -30,11 +33,15 @@ namespace Script.Gameplay.Facility
{
// 旋转拉杆到下拉位置
rotationPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 45f);
LeverSound.clip = turnSound;
LeverSound.Play();
}
else
{
// 旋转拉杆回到初始位置
rotationPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
LeverSound.clip = returnSound;
LeverSound.Play();
}
}
}

View File

@@ -11,6 +11,10 @@ namespace Script.Gameplay.Facility
[SerializeField] private Vector3 plateOffset = Vector3.up * 0.1f;
[SerializeField] private GameObject pressTopPrefab;
[SerializeField] private AudioClip pressedSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource plateSound;
private bool lastState = false;
private bool hasObject = false;
@@ -27,13 +31,21 @@ namespace Script.Gameplay.Facility
{
// 被压下动画
if (pressTopPrefab != null)
{
pressTopPrefab.transform.localPosition = new Vector3(0, 0, 0.1f);
plateSound.clip = pressedSound;
plateSound.Play();
}
}
else
{
// 弹起动画
if (pressTopPrefab != null)
{
pressTopPrefab.transform.localPosition = new Vector3(0, 0, 1);
plateSound.clip = returnSound;
plateSound.Play();
}
}
}
}