diff --git a/.erp b/.erp index b9e385f..33ed403 100644 --- a/.erp +++ b/.erp @@ -5,7 +5,7 @@ false false true - 1677785606 - 5977929065333740048 + 1677780742 + 819460763959917709 false \ No newline at end of file diff --git a/Assets/Prefabs/Counter/StoveCounter.prefab b/Assets/Prefabs/Counter/StoveCounter.prefab index ad539a1..2808259 100644 --- a/Assets/Prefabs/Counter/StoveCounter.prefab +++ b/Assets/Prefabs/Counter/StoveCounter.prefab @@ -1,5 +1,147 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &7924211026834254886 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5783891165566790229} + - component: {fileID: 5289876591296970476} + - component: {fileID: 7875328989254448195} + m_Layer: 0 + m_Name: Sound + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5783891165566790229 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7924211026834254886} + m_LocalRotation: {x: -0, y: 0.999996, z: -0, w: -0.0028347075} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6616006834372177299} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &5289876591296970476 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7924211026834254886} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: 511c1cbfb8b48b64083aec78fe17115f, type: 3} + m_PlayOnAwake: 0 + 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: 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!114 &7875328989254448195 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7924211026834254886} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a58f05adbbecd024eacd08f86e3c175c, type: 3} + m_Name: + m_EditorClassIdentifier: + stoveCounter: {fileID: 5065327384487018965} --- !u!1001 &268634890214101408 PrefabInstance: m_ObjectHideFlags: 0 @@ -98,6 +240,10 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 265883278189504360} + - targetCorrespondingSourceObject: {fileID: 6371086230447438899, guid: 509501a557d1d0a45817fb7332917dd5, + type: 3} + insertIndex: -1 + addedObject: {fileID: 5783891165566790229} m_AddedComponents: - targetCorrespondingSourceObject: {fileID: 6869097019740516189, guid: 509501a557d1d0a45817fb7332917dd5, type: 3} diff --git a/Assets/Scenes/GaneScene.unity b/Assets/Scenes/GaneScene.unity index 109f104..d6e94c2 100644 --- a/Assets/Scenes/GaneScene.unity +++ b/Assets/Scenes/GaneScene.unity @@ -1320,6 +1320,51 @@ Transform: type: 3} m_PrefabInstance: {fileID: 253451472} m_PrefabAsset: {fileID: 0} +--- !u!1 &559164285 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 559164287} + - component: {fileID: 559164286} + m_Layer: 0 + m_Name: SoundManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &559164286 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 559164285} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bebe77aac6b586c4aabb54e536895c69, type: 3} + m_Name: + m_EditorClassIdentifier: + audioClipsRefsSO: {fileID: 11400000, guid: 764f567af285f5e4aafccb58bd96148a, type: 2} +--- !u!4 &559164287 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 559164285} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &600789208 GameObject: m_ObjectHideFlags: 0 @@ -2066,6 +2111,7 @@ GameObject: m_Component: - component: {fileID: 974939166} - component: {fileID: 974939167} + - component: {fileID: 974939168} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -2108,6 +2154,18 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 64 kitchenObjectHoldPoint: {fileID: 408182762} +--- !u!114 &974939168 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 974939165} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf7fadd8f8bd7a548ad5f84a17b100e9, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1075657335 PrefabInstance: m_ObjectHideFlags: 0 @@ -3294,7 +3352,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 27.3, y: -72.5} + m_AnchoredPosition: {x: 27.300049, y: -72.5} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 1} --- !u!114 &1660265263 @@ -3402,7 +3460,7 @@ PrefabInstance: - target: {fileID: 3123278271184499230, guid: ca9c1594c8f67cb4daee56bdfadbbdc9, type: 3} propertyPath: m_LocalPosition.z - value: 3.5 + value: 3.508 objectReference: {fileID: 0} - target: {fileID: 3123278271184499230, guid: ca9c1594c8f67cb4daee56bdfadbbdc9, type: 3} @@ -3794,7 +3852,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 25.2, y: -22.2} + m_AnchoredPosition: {x: 25.199951, y: -22.199951} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1942177923 @@ -4329,7 +4387,7 @@ PrefabInstance: - target: {fileID: 3123278271184499230, guid: ca9c1594c8f67cb4daee56bdfadbbdc9, type: 3} propertyPath: m_LocalPosition.z - value: -5.50769 + value: -5.508 objectReference: {fileID: 0} - target: {fileID: 3123278271184499230, guid: ca9c1594c8f67cb4daee56bdfadbbdc9, type: 3} diff --git a/Assets/ScriptableObjects/AudioClipsRefsSO.asset b/Assets/ScriptableObjects/AudioClipsRefsSO.asset new file mode 100644 index 0000000..f17052f --- /dev/null +++ b/Assets/ScriptableObjects/AudioClipsRefsSO.asset @@ -0,0 +1,44 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6398abfe3947f214aae1dfd889dc05dc, type: 3} + m_Name: AudioClipsRefsSO + m_EditorClassIdentifier: + chop: + - {fileID: 8300000, guid: e519f586b4ac0904e877dfab85ed729e, type: 3} + - {fileID: 8300000, guid: 9c6157275e190604d8136e7e497e941e, type: 3} + - {fileID: 8300000, guid: 99c666127ba3b974c99980d14efcf03c, type: 3} + deliveryFail: + - {fileID: 8300000, guid: 400611abd7434234993616a86c030d1e, type: 3} + - {fileID: 8300000, guid: 6a936576e1e30a640844535c71d5a149, type: 3} + deliverySuccess: + - {fileID: 8300000, guid: 50205ffe58351d244bbcbd725dbfa802, type: 3} + - {fileID: 8300000, guid: 4b22bfbdbacfa0445bc9bbfbb0141085, type: 3} + footstep: + - {fileID: 8300000, guid: 078e15982fce2e147bf06c8a7682f28b, type: 3} + - {fileID: 8300000, guid: b2d2893ac04fbdb44a226f4b6ea0d271, type: 3} + - {fileID: 8300000, guid: cc97c340134faa948bcaf20fea6429c6, type: 3} + - {fileID: 8300000, guid: 64a04bb4fa4ed5d4eac6b0a31f91843a, type: 3} + objectDrop: + - {fileID: 8300000, guid: 9c88983fa5906dc41944ec5a43b6b5c7, type: 3} + - {fileID: 8300000, guid: 331b82ab2c0e2b74d805124d11372c85, type: 3} + - {fileID: 8300000, guid: 961379cce253f794abff0d24df806b68, type: 3} + objectPickup: + - {fileID: 8300000, guid: 668de61a04ca5914aa745f8712c62720, type: 3} + - {fileID: 8300000, guid: 6728bf8b07482414e99ba965fdd022d8, type: 3} + - {fileID: 8300000, guid: 32d29abc86751884081d2005f9ff2676, type: 3} + stoveSizzle: {fileID: 8300000, guid: 511c1cbfb8b48b64083aec78fe17115f, type: 3} + trash: + - {fileID: 8300000, guid: 4b70ec0f0afb9ac4ea7dfea07aca4eb4, type: 3} + - {fileID: 8300000, guid: 6024ba1d53d005f48a96b3a9f6bacedd, type: 3} + warning: + - {fileID: 8300000, guid: b90d8099bdbf09a40ab1163556d5b5f4, type: 3} + - {fileID: 8300000, guid: b59c98e0066c41f42b8100f5cb180f5b, type: 3} diff --git a/Assets/ScriptableObjects/AudioClipsRefsSO.asset.meta b/Assets/ScriptableObjects/AudioClipsRefsSO.asset.meta new file mode 100644 index 0000000..5fe8c7c --- /dev/null +++ b/Assets/ScriptableObjects/AudioClipsRefsSO.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 764f567af285f5e4aafccb58bd96148a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Counters/BaseCounter.cs b/Assets/Scripts/Counters/BaseCounter.cs index 6e15c8e..bd59fff 100644 --- a/Assets/Scripts/Counters/BaseCounter.cs +++ b/Assets/Scripts/Counters/BaseCounter.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -5,6 +6,8 @@ using UnityEngine; public class BaseCounter : MonoBehaviour, IKitchenObjectParent { + public static event EventHandler OnAnyObjectPlaced; + [SerializeField] private Transform counterTopPoint; private KitchenObject kitchenObject; @@ -28,6 +31,11 @@ public class BaseCounter : MonoBehaviour, IKitchenObjectParent public void SetKitchenObject(KitchenObject kitchenObject) { this.kitchenObject = kitchenObject; + + if (kitchenObject != null ) + { + OnAnyObjectPlaced?.Invoke(this, EventArgs.Empty); + } } public KitchenObject GetKitchenObject() diff --git a/Assets/Scripts/Counters/CuttingCounter.cs b/Assets/Scripts/Counters/CuttingCounter.cs index 5a867ec..fd3da00 100644 --- a/Assets/Scripts/Counters/CuttingCounter.cs +++ b/Assets/Scripts/Counters/CuttingCounter.cs @@ -6,6 +6,8 @@ using UnityEngine; public class CuttingCounter : BaseCounter, IHasProgress { + public static event EventHandler OnAnyCut; + public event EventHandler OnProgressChange; public event EventHandler OnCut; @@ -72,6 +74,7 @@ public class CuttingCounter : BaseCounter, IHasProgress cuttingProgress++; OnCut?.Invoke(this, EventArgs.Empty); + OnAnyCut?.Invoke(this, EventArgs.Empty); CuttingRecipeSO cuttingRecipeSO = GetCuttingRecipeSOWithInput(GetKitchenObject().GetKitchenObjectSO()); diff --git a/Assets/Scripts/Counters/DeliveryCounter.cs b/Assets/Scripts/Counters/DeliveryCounter.cs index 18139a4..b9ebc5d 100644 --- a/Assets/Scripts/Counters/DeliveryCounter.cs +++ b/Assets/Scripts/Counters/DeliveryCounter.cs @@ -1,9 +1,18 @@ +using ERP.Discord; using System.Collections; using System.Collections.Generic; using UnityEngine; public class DeliveryCounter : BaseCounter { + + public static DeliveryCounter Instance { get; private set; } + + private void Awake() + { + Instance = this; + } + public override void Interact(Player player) { if (player.HasKitchenObject()) diff --git a/Assets/Scripts/Counters/TrashCounter.cs b/Assets/Scripts/Counters/TrashCounter.cs index 0257300..ec3b5db 100644 --- a/Assets/Scripts/Counters/TrashCounter.cs +++ b/Assets/Scripts/Counters/TrashCounter.cs @@ -1,14 +1,20 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TrashCounter : BaseCounter { + + public static event EventHandler OnAnyObjectTrashed; + public override void Interact(Player player) { if (player.HasKitchenObject()) { player.GetKitchenObject().DestroySelf(); + + OnAnyObjectTrashed?.Invoke(this, EventArgs.Empty); } } } diff --git a/Assets/Scripts/DeliveryManager.cs b/Assets/Scripts/DeliveryManager.cs index 331c9bf..0854471 100644 --- a/Assets/Scripts/DeliveryManager.cs +++ b/Assets/Scripts/DeliveryManager.cs @@ -8,6 +8,8 @@ public class DeliveryManager : MonoBehaviour public event EventHandler OnRecipeSpawned; public event EventHandler OnRecipeCompleted; + public event EventHandler OnRecipeSuccess; + public event EventHandler OnRecipeFailed; public static DeliveryManager Instance { get; private set; } [SerializeField] private RecipeListSO recipeListSO; @@ -80,11 +82,11 @@ public class DeliveryManager : MonoBehaviour if (plateContentsMatchesRecipe) { // Player delivered correct recipe - Debug.Log("Player delivered a recipe from the waiting list!"); waitingRecipeSOList.RemoveAt(i); OnRecipeCompleted?.Invoke(this, EventArgs.Empty); + OnRecipeSuccess?.Invoke(this, EventArgs.Empty); return; } @@ -94,7 +96,8 @@ public class DeliveryManager : MonoBehaviour // No matches found! // Player brought the wrong recipe! - Debug.Log("Player brought the wrong recipe!"); + OnRecipeFailed?.Invoke(this, EventArgs.Empty); + } public List GetWaitingRecipeSOList() diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 8a0e5b7..c8667f1 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -9,6 +9,7 @@ public class Player : MonoBehaviour, IKitchenObjectParent public static Player Instance { get; private set; } + public event EventHandler OnPickedUpSomething; public event EventHandler OnSelectedcounterChanged; public class OnSelectedCounterChangedEventArgs : EventArgs { @@ -190,6 +191,11 @@ public class Player : MonoBehaviour, IKitchenObjectParent public void SetKitchenObject(KitchenObject kitchenObject) { this.kitchenObject = kitchenObject; + + if (kitchenObject != null) + { + OnPickedUpSomething?.Invoke(this, EventArgs.Empty); + } } public KitchenObject GetKitchenObject() diff --git a/Assets/Scripts/PlayerSounds.cs b/Assets/Scripts/PlayerSounds.cs new file mode 100644 index 0000000..d4480d6 --- /dev/null +++ b/Assets/Scripts/PlayerSounds.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerSounds : MonoBehaviour +{ + + private Player player; + private float footstepTimer; + private float footstepTimerMax = .1f; + + private void Awake() + { + player = GetComponent(); + } + + private void Update() + { + footstepTimer -= Time.deltaTime; + if (footstepTimer < 0f ) + { + footstepTimer = footstepTimerMax; + + if (player.IsWalking()) + { + float volume = 1f; + SoundManager.Instance.PlayFootsteps(player.transform.position, volume); + } + } + } + +} diff --git a/Assets/Scripts/PlayerSounds.cs.meta b/Assets/Scripts/PlayerSounds.cs.meta new file mode 100644 index 0000000..e2cf272 --- /dev/null +++ b/Assets/Scripts/PlayerSounds.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cf7fadd8f8bd7a548ad5f84a17b100e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs b/Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs new file mode 100644 index 0000000..4fc1c84 --- /dev/null +++ b/Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu()] +public class AudioClipsRefsSO : ScriptableObject +{ + + public AudioClip[] chop; + public AudioClip[] deliveryFail; + public AudioClip[] deliverySuccess; + public AudioClip[] footstep; + public AudioClip[] objectDrop; + public AudioClip[] objectPickup; + public AudioClip stoveSizzle; + public AudioClip[] trash; + public AudioClip[] warning; + +} diff --git a/Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs.meta b/Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs.meta new file mode 100644 index 0000000..05af45e --- /dev/null +++ b/Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6398abfe3947f214aae1dfd889dc05dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SoundManager.cs b/Assets/Scripts/SoundManager.cs new file mode 100644 index 0000000..07f7c01 --- /dev/null +++ b/Assets/Scripts/SoundManager.cs @@ -0,0 +1,77 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SoundManager : MonoBehaviour +{ + + public static SoundManager Instance { get; private set; } + + [SerializeField] private AudioClipsRefsSO audioClipsRefsSO; + + private void Awake() + { + Instance = this; + } + + private void Start() + { + DeliveryManager.Instance.OnRecipeSuccess += DeliveryManager_OnRecipeSuccess; + DeliveryManager.Instance.OnRecipeFailed += DeliveryManager_OnRecipeFailed; + CuttingCounter.OnAnyCut += CuttingCounter_OnAnyCut; + Player.Instance.OnPickedUpSomething += Player_OnPickedUpSomething; + BaseCounter.OnAnyObjectPlaced += BaseCounter_OnAnyObjectPlaced; + TrashCounter.OnAnyObjectTrashed += TrashCounter_OnAnyObjectTrashed; + } + + private void TrashCounter_OnAnyObjectTrashed(object sender, System.EventArgs e) + { + TrashCounter trashCounter = sender as TrashCounter; + PlaySound(audioClipsRefsSO.trash, trashCounter.transform.position); + } + + private void BaseCounter_OnAnyObjectPlaced(object sender, System.EventArgs e) + { + BaseCounter counter = sender as BaseCounter; + PlaySound(audioClipsRefsSO.objectDrop, counter.transform.position); + } + + private void Player_OnPickedUpSomething(object sender, System.EventArgs e) + { + PlaySound(audioClipsRefsSO.objectPickup, Player.Instance.transform.position); + } + + private void CuttingCounter_OnAnyCut(object sender, System.EventArgs e) + { + CuttingCounter cuttingCounter = sender as CuttingCounter; + PlaySound(audioClipsRefsSO.chop, cuttingCounter.transform.position); + } + + private void DeliveryManager_OnRecipeFailed(object sender, System.EventArgs e) + { + DeliveryCounter deliveryCounter = DeliveryCounter.Instance; + PlaySound(audioClipsRefsSO.deliveryFail, deliveryCounter.transform.position); + } + + private void DeliveryManager_OnRecipeSuccess(object sender, System.EventArgs e) + { + DeliveryCounter deliveryCounter = DeliveryCounter.Instance; + PlaySound(audioClipsRefsSO.deliverySuccess, deliveryCounter.transform.position); + } + + private void PlaySound(AudioClip[] audioClipArray, Vector3 position, float volume = 1f) + { + PlaySound(audioClipArray[Random.Range(0, audioClipArray.Length)], position, volume); + } + + private void PlaySound(AudioClip audioClip, Vector3 position, float volume = 1f) + { + AudioSource.PlayClipAtPoint(audioClip, position, volume); + } + + public void PlayFootsteps(Vector3 position, float volume) + { + PlaySound(audioClipsRefsSO.footstep, position, volume); + } + +} diff --git a/Assets/Scripts/SoundManager.cs.meta b/Assets/Scripts/SoundManager.cs.meta new file mode 100644 index 0000000..5da6396 --- /dev/null +++ b/Assets/Scripts/SoundManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bebe77aac6b586c4aabb54e536895c69 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/StoveCounterSound.cs b/Assets/Scripts/StoveCounterSound.cs new file mode 100644 index 0000000..1df229b --- /dev/null +++ b/Assets/Scripts/StoveCounterSound.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class StoveCounterSound : MonoBehaviour +{ + + [SerializeField] private StoveCounter stoveCounter; + private AudioSource audioSource; + + private void Awake() + { + audioSource = GetComponent(); + } + + private void Start() + { + stoveCounter.OnStateChanged += StoveCounter_OnStateChanged; + } + + private void StoveCounter_OnStateChanged(object sender, StoveCounter.OnStateChangedEventArgs e) + { + bool playSound = e.state == StoveCounter.State.Frying || e.state == StoveCounter.State.Fried; + + if (playSound) + { + audioSource.Play(); + } else + { + audioSource.Pause(); + } + } +} diff --git a/Assets/Scripts/StoveCounterSound.cs.meta b/Assets/Scripts/StoveCounterSound.cs.meta new file mode 100644 index 0000000..d625e23 --- /dev/null +++ b/Assets/Scripts/StoveCounterSound.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a58f05adbbecd024eacd08f86e3c175c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: