From acffef7b5a82f39b08b4d21be1467ec1dcd3afbf Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Mon, 20 Apr 2020 20:03:04 +0300 Subject: [PATCH] Add torch sfx, rename Campfire vol -> Fire vol --- Assets/Audio Mixers/MainMixer.mixer | 67 ++++++- .../Prefabs/Environment/BurningStick.prefab | 181 ++++++++++++++++++ Assets/Prefabs/Environment/stick.prefab | 46 +++++ Assets/Prefabs/Player/Player.prefab | 2 +- Assets/Prefabs/UI/Pause Menu.prefab | 2 +- Assets/Scripts/ItemGrabber.cs | 22 ++- Assets/Scripts/Torch.cs | 21 +- 7 files changed, 332 insertions(+), 9 deletions(-) diff --git a/Assets/Audio Mixers/MainMixer.mixer b/Assets/Audio Mixers/MainMixer.mixer index 0a8294e..5075012 100644 --- a/Assets/Audio Mixers/MainMixer.mixer +++ b/Assets/Audio Mixers/MainMixer.mixer @@ -33,6 +33,20 @@ AudioMixerEffectController: m_SendTarget: {fileID: 0} m_EnableWetMix: 0 m_Bypass: 0 +--- !u!244 &-6255916091702430506 +AudioMixerEffectController: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_EffectID: 9520d85589c9e024da13463e085024bf + m_EffectName: Attenuation + m_MixLevel: a5461d35a34b32640884b2a723b0cea2 + m_Parameters: [] + m_SendTarget: {fileID: 0} + m_EnableWetMix: 0 + m_Bypass: 0 --- !u!244 &-6119931374106344343 AudioMixerEffectController: m_ObjectHideFlags: 3 @@ -69,6 +83,44 @@ AudioMixerGroupController: m_Mute: 0 m_Solo: 0 m_BypassEffects: 0 +--- !u!244 &-5197969762179464907 +AudioMixerEffectController: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_EffectID: 3379818075d29034cbc01b00c83df4f0 + m_EffectName: Lowpass + m_MixLevel: 749818488dc68de43926443ee599ab8a + m_Parameters: + - m_ParameterName: Cutoff freq + m_GUID: 9f37ae073eb26e54f93d6ea7c5e77b1b + - m_ParameterName: Resonance + m_GUID: eb6adc5a04258914b9df1b0fcc93d665 + m_SendTarget: {fileID: 0} + m_EnableWetMix: 0 + m_Bypass: 0 +--- !u!243 &-4473023764082028856 +AudioMixerGroupController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Torch + m_AudioMixer: {fileID: 24100000} + m_GroupID: f26d1353f522d5a4abfb02f874e440de + m_Children: [] + m_Volume: 118a95e1adc69904c92cc8ba0d5d3b78 + m_Pitch: 7b256dfd2b989424f93529d0b036e070 + m_Send: 00000000000000000000000000000000 + m_Effects: + - {fileID: -5197969762179464907} + - {fileID: -6255916091702430506} + m_UserColorIndex: 0 + m_Mute: 0 + m_Solo: 0 + m_BypassEffects: 0 --- !u!245 &-3105936107480203619 AudioMixerSnapshotController: m_ObjectHideFlags: 0 @@ -79,9 +131,16 @@ AudioMixerSnapshotController: m_AudioMixer: {fileID: 24100000} m_SnapshotID: ac9cc10b0c59e3b4682dc5089372ae81 m_FloatValues: + 56305850b5d092f4eae31403545ce1dc: 0.1 + ef9a57b05885adb44a345384676fa600: 200 + 118a95e1adc69904c92cc8ba0d5d3b78: 4 + 5b3bf9627c3c142438ce39b85cbaca3d: 1 + 73b353e344009894b8a018843580e79d: 1 + 2efb7a04eb7ce404e90abf3b0ada7945: 3801 + 9f37ae073eb26e54f93d6ea7c5e77b1b: 2000 d3d28f4b939c15c4fb46575e1562c52b: 9 3b873ffd7476b574ab79c605a05a50ff: 0 - fb93bc0e4abea1d4e840f1f2832ba33d: 3 + fb93bc0e4abea1d4e840f1f2832ba33d: 6 m_TransitionOverrides: {} --- !u!243 &-2967980135314984734 AudioMixerGroupController: @@ -146,6 +205,7 @@ AudioMixerGroupController: - {fileID: -8678847571685279384} - {fileID: -860412736225255873} - {fileID: 6572270565297822335} + - {fileID: -4473023764082028856} m_Volume: fd01f6bdeaa870c4688fa6fcad7c3e41 m_Pitch: fc8fd2fca838b3843a92c252855b9146 m_Send: 00000000000000000000000000000000 @@ -191,6 +251,7 @@ AudioMixerController: - 3f76253721c9d6643aeee536840efa28 - 9dc227c354f4f5349aa2a811c85b2415 - e98388ceee042154bb13e28dbe91c9a1 + - f26d1353f522d5a4abfb02f874e440de name: View m_CurrentViewIndex: 0 m_TargetSnapshot: {fileID: -3105936107480203619} @@ -369,8 +430,10 @@ AudioMixerSnapshotController: m_AudioMixer: {fileID: 24100000} m_SnapshotID: 99acc46f1b1d7c24b861966f8835044d m_FloatValues: + 118a95e1adc69904c92cc8ba0d5d3b78: 4 + 9f37ae073eb26e54f93d6ea7c5e77b1b: 2000 d3d28f4b939c15c4fb46575e1562c52b: 9 fd01f6bdeaa870c4688fa6fcad7c3e41: 0 3b873ffd7476b574ab79c605a05a50ff: 0 - fb93bc0e4abea1d4e840f1f2832ba33d: 3 + fb93bc0e4abea1d4e840f1f2832ba33d: 6 m_TransitionOverrides: {} diff --git a/Assets/Prefabs/Environment/BurningStick.prefab b/Assets/Prefabs/Environment/BurningStick.prefab index 2060b70..5282530 100644 --- a/Assets/Prefabs/Environment/BurningStick.prefab +++ b/Assets/Prefabs/Environment/BurningStick.prefab @@ -1,5 +1,133 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &5660250723420672 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1920801300980537475} + - component: {fileID: 2118652764677376848} + m_Layer: 0 + m_Name: Audio Source + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1920801300980537475 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5660250723420672} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.011, y: 0.228, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1830340994370403595} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &2118652764677376848 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5660250723420672} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: -4473023764082028856, guid: 032de345950918c4e89684078c6a7213, + type: 2} + m_audioClip: {fileID: 8300000, guid: 280c9d9eb97f5ce4d857fb945bfddb1e, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + 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: 1 + 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 &2086008818391599545 GameObject: m_ObjectHideFlags: 0 @@ -36,6 +164,8 @@ Transform: - {fileID: 8656022059323805365} - {fileID: 3832243548091795177} - {fileID: 7948189956267693667} + - {fileID: 1920801300980537475} + - {fileID: 4877920229996310201} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -60,6 +190,12 @@ MonoBehaviour: PanicLifetimeThreshold: 10 PassTorchAnimationDuration: 0.5 IgniteDuration: 2 + TorchSound: {fileID: 2118652764677376848} + FireClips: + - {fileID: 8300000, guid: 280c9d9eb97f5ce4d857fb945bfddb1e, type: 3} + - {fileID: 8300000, guid: f33dea627b0de8248a82605c4e0e6e71, type: 3} + - {fileID: 8300000, guid: 021edc202d1cd73478de90d9a3ead06e, type: 3} + - {fileID: 8300000, guid: 2d22ab70306de704598b89a705777afb, type: 3} --- !u!54 &2081929903982442016 Rigidbody: m_ObjectHideFlags: 0 @@ -5020,6 +5156,51 @@ ParticleSystemRenderer: m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} m_MaskInteraction: 0 +--- !u!1 &7479130334613842717 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4877920229996310201} + - component: {fileID: 7620417528792264248} + m_Layer: 10 + m_Name: Interaction Trigger + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4877920229996310201 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7479130334613842717} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1830340994370403595} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!136 &7620417528792264248 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7479130334613842717} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + m_Radius: 0.07 + m_Height: 0.6 + m_Direction: 1 + m_Center: {x: 0.005, y: 0, z: 0.005} --- !u!1 &7981884805349908101 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Environment/stick.prefab b/Assets/Prefabs/Environment/stick.prefab index c5416b1..51003f4 100644 --- a/Assets/Prefabs/Environment/stick.prefab +++ b/Assets/Prefabs/Environment/stick.prefab @@ -1,5 +1,50 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &1774343341489610875 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1711730649631156610} + - component: {fileID: 7965271002899560656} + m_Layer: 10 + m_Name: Interaction Trigger + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1711730649631156610 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1774343341489610875} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1830340994370403595} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!136 &7965271002899560656 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1774343341489610875} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + m_Radius: 0.07 + m_Height: 0.6 + m_Direction: 1 + m_Center: {x: 0.005, y: 0, z: 0.005} --- !u!1 &2086008818391599545 GameObject: m_ObjectHideFlags: 0 @@ -32,6 +77,7 @@ Transform: - {fileID: 4295605565537018981} - {fileID: 7722979984909929174} - {fileID: 8934967594637573488} + - {fileID: 1711730649631156610} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Prefabs/Player/Player.prefab b/Assets/Prefabs/Player/Player.prefab index 336a0f2..eb6291c 100644 --- a/Assets/Prefabs/Player/Player.prefab +++ b/Assets/Prefabs/Player/Player.prefab @@ -924,7 +924,7 @@ CharacterController: serializedVersion: 2 m_Height: 1.8 m_Radius: 0.1 - m_SlopeLimit: 30 + m_SlopeLimit: 45 m_StepOffset: 0.05 m_SkinWidth: 0.08 m_MinMoveDistance: 0.001 diff --git a/Assets/Prefabs/UI/Pause Menu.prefab b/Assets/Prefabs/UI/Pause Menu.prefab index b68ac45..02d4e0d 100644 --- a/Assets/Prefabs/UI/Pause Menu.prefab +++ b/Assets/Prefabs/UI/Pause Menu.prefab @@ -3163,7 +3163,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Campfire volume + m_Text: Fire volume --- !u!1 &6818139631915637241 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/ItemGrabber.cs b/Assets/Scripts/ItemGrabber.cs index d1d72d1..4f3138d 100644 --- a/Assets/Scripts/ItemGrabber.cs +++ b/Assets/Scripts/ItemGrabber.cs @@ -35,6 +35,7 @@ public class ItemGrabber : MonoBehaviour { Vector3 From = CameraTransform.position; Vector3 Direction = CameraTransform.forward; + Item ThrowableItem = GetThrowableItem(); Item TorchableItem = GetTorchableItem(); bool CanIgniteTorch = Torch != null && TorchableItem != null; @@ -69,7 +70,7 @@ public class ItemGrabber : MonoBehaviour { } } - if (Input.GetButtonDown("Grab") && Item == null) { + if (Input.GetButtonDown("Grab") && Item == null && ThrowableItem != null) { Vector3 DropPosition; if (Campfire != null) { DropPosition = Campfire.transform.position + Vector3.up * 0.7f; @@ -80,8 +81,8 @@ public class ItemGrabber : MonoBehaviour { DropPosition = From + Direction * Distance; } } - GrabbedItems[0].Drop(DropPosition); - GrabbedItems.RemoveAt(0); + ThrowableItem.Drop(DropPosition); + GrabbedItems.Remove(ThrowableItem); } } @@ -116,6 +117,8 @@ public class ItemGrabber : MonoBehaviour { PrimaryText.text = $"Burn {GrabbedItems[0].Quality.DisplayName}"; } else if (Item != null) { PrimaryText.text = $"Take {Item.Quality.DisplayName}"; + } else if (ThrowableItem != null) { + PrimaryText.text = $"Throw {ThrowableItem.Quality.DisplayName}"; } SecondaryIndicator.alpha = Mathf.Lerp(SecondaryIndicator.alpha, CanIgniteTorch ? 1 : 0, 10f * Time.deltaTime); if (CanIgniteTorch) { @@ -127,7 +130,18 @@ public class ItemGrabber : MonoBehaviour { Item ChosenItem = null; foreach (Item I in GrabbedItems) { Torch CurrentTorch = I.GetComponent(); - if (CurrentTorch == null || CurrentTorch.Burning) { + if (I.Quality.Ignitable && (CurrentTorch == null || CurrentTorch.Burning)) { + ChosenItem = I; + continue; + } + } + return ChosenItem; + } + + private Item GetThrowableItem() { + Item ChosenItem = null; + foreach (Item I in GrabbedItems) { + if (I.gameObject != NextTorch) { ChosenItem = I; continue; } diff --git a/Assets/Scripts/Torch.cs b/Assets/Scripts/Torch.cs index 24f5d31..e6f211f 100644 --- a/Assets/Scripts/Torch.cs +++ b/Assets/Scripts/Torch.cs @@ -14,6 +14,10 @@ public class Torch : MonoBehaviour { public float PassTorchAnimationDuration; public float IgniteDuration; + [Header("Sound effects")] + public AudioSource TorchSound; + public AudioClip[] FireClips; + public bool Burning { get { return Lifetime > 0; @@ -30,10 +34,12 @@ public class Torch : MonoBehaviour { private Quaternion PassStartRotation; private Vector3 BaseScale; + private float StartLifetime; private void Awake() { Body = GetComponent(); BaseScale = transform.localScale; + StartLifetime = Lifetime; } private void Update() { @@ -59,13 +65,26 @@ public class Torch : MonoBehaviour { } Lifetime -= Time.deltaTime; - Light.color = Color.Lerp(Light.color, Lifetime <= PanicLifetimeThreshold ? PanicColor : NormalColor, 4f * Time.deltaTime); if (Lifetime <= 0) { Particles.Stop(); Light.color = Color.Lerp(Light.color, Color.black, 4f * Time.deltaTime); + TorchSound.volume = Mathf.Lerp(TorchSound.volume, 0, 8f * Time.deltaTime); if (Light.color == Color.black) { Light.enabled = false; } + if (TorchSound.volume == 0) { + TorchSound.enabled = false; + } + } else { + bool Panic = Lifetime <= PanicLifetimeThreshold; + Light.color = Color.Lerp(Light.color, Panic ? PanicColor : NormalColor, 4f * Time.deltaTime); + + if ((TorchSound.clip.length - TorchSound.time) <= Time.deltaTime || !TorchSound.isPlaying) { + TorchSound.clip = FireClips[Random.Range(0, FireClips.Length)]; + TorchSound.time = 0; + TorchSound.Play(); + } + TorchSound.volume = 0.5f + 0.5f * (1f / (Mathf.Max(0, StartLifetime + 0.5f - Lifetime) * 4f + 1)) - (Panic ? 0.3f : 0); } }