Ещё звуки

-Добавлены звуки открытия и закрытия двери
This commit is contained in:
realM0nkey 2025-09-17 00:20:36 +03:00
parent 23109c3619
commit 0f8f58170e
1474 changed files with 292400 additions and 12440 deletions

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 5c199e662eb9ae82ca7c062e04e34b7a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ac4f9fd8c1b50b1f1a9bf051e33cf431
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 93a325154b3e9422da691ea4cfafad72
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -5,33 +5,58 @@
public class Door : OpenableObject
{
[SerializeField] private float rotateByDegrees = -90f;
[SerializeField] private float enemyDetectionRange = 3f; // Радиус обнаружения врага
[SerializeField] private Collider doorCollider; // Коллайдер двери
[SerializeField] private float openTime = 0.5f; // Время открытия двери (уменьшено для скорости)
[SerializeField] private float closeTime = 1f; // Время закрытия двери
[SerializeField] private bool isForbiddenForEnemy = false; // Время закрытия двери
[SerializeField] private float enemyDetectionRange = 3f;
[SerializeField] private Collider doorCollider;
[SerializeField] private float openTime = 0.5f;
[SerializeField] private float closeTime = 1f;
[SerializeField] private bool isForbiddenForEnemy = false;
[SerializeField] public AudioClip openSound;
[SerializeField] public AudioClip closeSound;
private Vector3 startRotation;
private Vector3 endRotation;
private bool isMoving;
private bool isOpen;
private AudioSource audioSource;
void Start()
{
// Проверяем и добавляем AudioSource
audioSource = GetComponent<AudioSource>();
if (audioSource == null)
{
audioSource = gameObject.AddComponent<AudioSource>();
audioSource.playOnAwake = false;
audioSource.loop = false;
audioSource.spatialBlend = 1f;
audioSource.volume = 0.7f;
Debug.Log($"Добавлен AudioSource на {gameObject.name}");
}
startRotation = transform.rotation.eulerAngles;
endRotation = startRotation + Vector3.up * rotateByDegrees;
isOpen = false;
// Проверяем звуки
if (openSound == null) Debug.LogWarning($"Дверь {gameObject.name}: openSound не назначен!");
if (closeSound == null) Debug.LogWarning($"Дверь {gameObject.name}: closeSound не назначен!");
// Синхронизируем громкость
GameUIManager uiManager = FindObjectOfType<GameUIManager>();
if (uiManager != null && uiManager.soundVolumeSlider != null)
{
UpdateVolume(uiManager.soundVolumeSlider.value);
}
}
void Update()
{
// Проверяем, есть ли враг рядом, и дверь не движется
if (!isMoving && !isOpen && !isForbiddenForEnemy)
{
Collider[] colliders = Physics.OverlapSphere(transform.position, enemyDetectionRange);
foreach (Collider col in colliders)
{
if (col.CompareTag("Enemy")) // У врага должен быть тег "Enemy"
if (col.CompareTag("Enemy"))
{
StartCoroutine(Open());
break;
@ -42,10 +67,27 @@ void Update()
public override IEnumerator Open()
{
if (IsLockedByKeypad)
{
Debug.Log("Дверь заблокирована кодом!");
yield break;
}
isMoving = true;
isOpen = true;
// Отключаем коллайдер, чтобы враг мог пройти
// Проигрываем звук открывания
if (openSound != null)
{
audioSource.clip = openSound;
audioSource.Play();
Debug.Log($"Дверь {gameObject.name} открывается!");
}
else
{
Debug.LogWarning($"Дверь {gameObject.name}: openSound не имеет звука!");
}
if (doorCollider != null)
{
doorCollider.enabled = false;
@ -55,7 +97,7 @@ public override IEnumerator Open()
while (timer < 1f)
{
timer += Time.deltaTime / openTime;
openOrCloseLerp = timer; // Обновляем значение для возможного использования в базовом классе
openOrCloseLerp = timer;
transform.rotation = Quaternion.Lerp(Quaternion.Euler(startRotation), Quaternion.Euler(endRotation), timer);
yield return null;
}
@ -68,7 +110,18 @@ public override IEnumerator Close()
isMoving = true;
isOpen = false;
// Включаем коллайдер обратно
// Проигрываем звук закрывания
if (closeSound != null)
{
audioSource.clip = closeSound;
audioSource.Play();
Debug.Log($"Дверь {gameObject.name} закрывается!");
}
else
{
Debug.LogWarning($"Дверь {gameObject.name}: closeSound не имеет звука!");
}
if (doorCollider != null)
{
doorCollider.enabled = true;
@ -78,7 +131,7 @@ public override IEnumerator Close()
while (timer < 1f)
{
timer += Time.deltaTime / closeTime;
openOrCloseLerp = 1f - timer; // Обновляем для обратного движения
openOrCloseLerp = 1f - timer;
transform.rotation = Quaternion.Lerp(Quaternion.Euler(startRotation), Quaternion.Euler(endRotation), 1f - timer);
yield return null;
}
@ -86,7 +139,15 @@ public override IEnumerator Close()
isMoving = false;
}
// Визуализация радиуса обнаружения в редакторе
public void UpdateVolume(float volume)
{
if (audioSource != null)
{
audioSource.volume = volume * 0.8f;
Debug.Log($"Door: Громкость звука двери {gameObject.name} = {audioSource.volume}");
}
}
void OnDrawGizmosSelected()
{
Gizmos.color = Color.green;

View File

@ -54,6 +54,9 @@ void Start()
mouseSensitivityInput.onEndEdit.AddListener(UpdateMouseSensitivityFromInput);
if (soundVolumeInput != null)
soundVolumeInput.onEndEdit.AddListener(UpdateSoundVolumeFromInput);
// Инициализируем громкость для всех звуков
UpdateSoundVolume(soundVolumeSlider.value);
}
void Update()
@ -111,6 +114,9 @@ void GoToMainMenu()
void ExitGame()
{
Application.Quit();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
void UpdateMouseSensitivity(float value)
@ -126,12 +132,23 @@ void UpdateMouseSensitivity(float value)
void UpdateSoundVolume(float value)
{
AudioListener.volume = value;
// Обновляем громкость шагов
FootstepSounds footstep = FindObjectOfType<FootstepSounds>();
if (footstep != null)
{
footstep.audioSource.volume = value; // Или value * 0.8f для тише
footstep.audioSource.volume = value * 0.8f;
Debug.Log($"GameUIManager: Громкость шагов = {value * 0.8f}");
}
AudioListener.volume = value;
// Обновляем громкость всех дверей
Door[] doors = FindObjectsOfType<Door>();
foreach (Door door in doors)
{
door.UpdateVolume(value);
}
if (soundVolumeInput != null)
soundVolumeInput.text = value.ToString("F2");
}

BIN
1 laba/Assets/Sound/close-door.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 5fa0f668df1407fff9074e10c887cea6
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

BIN
1 laba/Assets/Sound/open-door.wav (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: c7c93f9d260590624960c016d601afc8
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More