diff --git a/302/Assets/Prefabs/Anomaly23/ghost.prefab b/302/Assets/Prefabs/Anomaly23/ghost.prefab index fc55bdd..1f935c1 100644 --- a/302/Assets/Prefabs/Anomaly23/ghost.prefab +++ b/302/Assets/Prefabs/Anomaly23/ghost.prefab @@ -696,6 +696,7 @@ GameObject: - component: {fileID: 6077576747107725253} - component: {fileID: 5615054433689430107} - component: {fileID: 6691339936817308490} + - component: {fileID: 3035267094544484457} m_Layer: 0 m_Name: ghost m_TagString: Untagged @@ -776,7 +777,105 @@ MonoBehaviour: speedInit: 1 speedDelta: 5 durationChase: 25 - durationFade: 5 + durationBlow: 5 + timeAudioStart: 3 + durationFade: 3 +--- !u!82 &3035267094544484457 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6383441288876432308} + m_Enabled: 0 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: c52ad1d603f6a794aad196f6376d508d, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &6612614341887459618 GameObject: m_ObjectHideFlags: 0 diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs index d97a175..b47c367 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs @@ -2,6 +2,7 @@ using UnityEngine; [RequireComponent(typeof(Animator))] +[RequireComponent(typeof(AudioSource))] public class Anomaly23_Ghost : SCH_AnomalyObject { /********** @@ -17,11 +18,16 @@ public class Anomaly23_Ghost : SCH_AnomalyObject public float speedInit; public float speedDelta; public float durationChase; + public float durationBlow; + public float timeAudioStart; public float durationFade; // 애니메이터 private Animator _animator; + // 오디오 소스 + private AudioSource _audioSource; + // 오브젝트 private GameObject _objectPlayer; private GameObject _objectCamera; @@ -29,6 +35,7 @@ public class Anomaly23_Ghost : SCH_AnomalyObject // 내부 수치 private float _timeStart; private bool _isChasing; + private bool _isCatched; /************** * properties * @@ -47,10 +54,14 @@ void OnCollisionEnter(Collision other) if (other.collider.CompareTag("Player") && _isChasing) { PlayerController script = _objectPlayer.GetComponent(); + _isCatched = true; if (script != null) { Log("Call `script.GameOver` begin"); script.GameOver(); Log("Call `script.GameOver` end"); + + Log("Call `FadeAudioAsync` asynchronously"); + StartCoroutine(FadeAudioAsync()); } else { Log("Call `script.GameOver`: failed", mode: 1); } @@ -72,15 +83,12 @@ void Update() transform.LookAt(positionTarget); transform.Translate(Vector3.forward * speed * Time.deltaTime); _animator.SetFloat("Speed", speed); - } else { + } else if (!_isCatched) { _isChasing = false; Log("Call `Manager.InteractionSuccess` begin"); Manager.InteractionSuccess(); Log("Call `Manager.InteractionSuccess` end"); - - Log("Call `BlowAsync` asynchronously"); - StartCoroutine(BlowAsync()); } } } @@ -103,6 +111,15 @@ protected override bool InitFields() res = false; } + // _audioSource + _audioSource = GetComponent(); + if (_audioSource != null) { + Log("Initialize `_audioSource`: success"); + } else { + Log("Initialize `_audioSource`: failed", mode: 1); + res = false; + } + // _objectPlayer _objectPlayer = GameObject.Find(namePlayer); if (_objectPlayer != null) { @@ -129,6 +146,10 @@ protected override bool InitFields() _isChasing = true; Log("Initialize `_isChasing`: success"); + // _isCatched + _isCatched = false; + Log("Initialize `_isChasing`: success"); + return res; } @@ -144,6 +165,23 @@ protected override bool SetAnomaly() transform.position = position; Log("Set position: success"); + Log("Call `StartAudioAsync` asynchronously"); + StartCoroutine(StartAudioAsync()); + + return res; + } + + // 이상현상을 초기화하는 메서드 + public override bool ResetAnomaly() + { + bool res = base.ResetAnomaly(); + + _audioSource.enabled = false; + Log("Reset audio source: success"); + + Log("Call `BlowAsync` asynchronously"); + StartCoroutine(BlowAsync()); + return res; } @@ -151,6 +189,31 @@ protected override bool SetAnomaly() * methods * ***********/ + // 시작하고 일정 시간 후 오디오 소스를 시작하는 메서드 + private IEnumerator StartAudioAsync() + { + yield return new WaitForSeconds(timeAudioStart); + + _audioSource.enabled = true; + } + + // 오디오 소스 볼륨을 서서히 줄이는 메서드 + private IEnumerator FadeAudioAsync() + { + float timeStart = Time.time; + float time; + + yield return null; + + while ((time = Time.time - timeStart) < durationFade) { + _audioSource.volume = 1.0f - time / durationFade; + + yield return null; + } + + _audioSource.enabled = false; + } + // 지속시간 동안 바람빠지다가 사라지는 메서드 private IEnumerator BlowAsync() { @@ -160,7 +223,7 @@ private IEnumerator BlowAsync() yield return new WaitForSeconds(0.1f); - while ((time = Time.time - timeStart) < durationFade) { + while ((time = Time.time - timeStart) < durationBlow) { float scale = (float)(random.LogNormalDist(0.0, 1.0) * 1.5); transform.rotation = Random.rotation; diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Laptop.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Laptop.cs index 2967700..b8c4588 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Laptop.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Laptop.cs @@ -31,6 +31,7 @@ public class Anomaly23_Laptop : SCH_AnomalyObject void Update() { if (_script != null && _script.Index != anomalyScreenIndex) { + _index = _script.Index; _script.ChangeScreen(anomalyScreenIndex); } } diff --git a/302/Assets/Sounds/Anomaly23.meta b/302/Assets/Sounds/Anomaly23.meta new file mode 100644 index 0000000..9fae362 --- /dev/null +++ b/302/Assets/Sounds/Anomaly23.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9a4b456f10c2b20418ef6556e9f1e713 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/302/Assets/Sounds/Anomaly23/bright-violin-hit_E_major.wav b/302/Assets/Sounds/Anomaly23/bright-violin-hit_E_major.wav new file mode 100644 index 0000000..4a66786 Binary files /dev/null and b/302/Assets/Sounds/Anomaly23/bright-violin-hit_E_major.wav differ diff --git a/302/Assets/Sounds/Anomaly23/bright-violin-hit_E_major.wav.meta b/302/Assets/Sounds/Anomaly23/bright-violin-hit_E_major.wav.meta new file mode 100644 index 0000000..eb334af --- /dev/null +++ b/302/Assets/Sounds/Anomaly23/bright-violin-hit_E_major.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: c52ad1d603f6a794aad196f6376d508d +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: