Add SFX and SFX logic
This commit is contained in:
parent
f0e4f6c9ba
commit
1aa97baff4
19 changed files with 504 additions and 8 deletions
4
.erp
4
.erp
|
@ -5,7 +5,7 @@
|
|||
<resetOnSceneChange>false</resetOnSceneChange>
|
||||
<debugMode>false</debugMode>
|
||||
<EditorClosed>true</EditorClosed>
|
||||
<LastTimestamp>1677785606</LastTimestamp>
|
||||
<LastSessionID>5977929065333740048</LastSessionID>
|
||||
<LastTimestamp>1677780742</LastTimestamp>
|
||||
<LastSessionID>819460763959917709</LastSessionID>
|
||||
<Errored>false</Errored>
|
||||
</ERPSettings>
|
|
@ -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}
|
||||
|
|
|
@ -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}
|
||||
|
|
44
Assets/ScriptableObjects/AudioClipsRefsSO.asset
Normal file
44
Assets/ScriptableObjects/AudioClipsRefsSO.asset
Normal file
|
@ -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}
|
8
Assets/ScriptableObjects/AudioClipsRefsSO.asset.meta
Normal file
8
Assets/ScriptableObjects/AudioClipsRefsSO.asset.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 764f567af285f5e4aafccb58bd96148a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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()
|
||||
|
|
|
@ -6,6 +6,8 @@ using UnityEngine;
|
|||
public class CuttingCounter : BaseCounter, IHasProgress
|
||||
{
|
||||
|
||||
public static event EventHandler OnAnyCut;
|
||||
|
||||
public event EventHandler<IHasProgress.OnProgressChangeEventsArgs> 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());
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<RecipeSO> GetWaitingRecipeSOList()
|
||||
|
|
|
@ -9,6 +9,7 @@ public class Player : MonoBehaviour, IKitchenObjectParent
|
|||
|
||||
public static Player Instance { get; private set; }
|
||||
|
||||
public event EventHandler OnPickedUpSomething;
|
||||
public event EventHandler<OnSelectedCounterChangedEventArgs> 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()
|
||||
|
|
32
Assets/Scripts/PlayerSounds.cs
Normal file
32
Assets/Scripts/PlayerSounds.cs
Normal file
|
@ -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<Player>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
footstepTimer -= Time.deltaTime;
|
||||
if (footstepTimer < 0f )
|
||||
{
|
||||
footstepTimer = footstepTimerMax;
|
||||
|
||||
if (player.IsWalking())
|
||||
{
|
||||
float volume = 1f;
|
||||
SoundManager.Instance.PlayFootsteps(player.transform.position, volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/PlayerSounds.cs.meta
Normal file
11
Assets/Scripts/PlayerSounds.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf7fadd8f8bd7a548ad5f84a17b100e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs
Normal file
19
Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs
Normal file
|
@ -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;
|
||||
|
||||
}
|
11
Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs.meta
Normal file
11
Assets/Scripts/ScriptableObjects/AudioClipsRefsSO.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6398abfe3947f214aae1dfd889dc05dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
77
Assets/Scripts/SoundManager.cs
Normal file
77
Assets/Scripts/SoundManager.cs
Normal file
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/SoundManager.cs.meta
Normal file
11
Assets/Scripts/SoundManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bebe77aac6b586c4aabb54e536895c69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/StoveCounterSound.cs
Normal file
33
Assets/Scripts/StoveCounterSound.cs
Normal file
|
@ -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<AudioSource>();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/StoveCounterSound.cs.meta
Normal file
11
Assets/Scripts/StoveCounterSound.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a58f05adbbecd024eacd08f86e3c175c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in a new issue