Skip to content

Commit bacd1c7

Browse files
committed
Disable audio sfx events on animation during cutscenes
1 parent bd53a95 commit bacd1c7

File tree

10 files changed

+32
-21
lines changed

10 files changed

+32
-21
lines changed

UOP1_Project/Assets/Prefabs/Characters/NPCs_BasePrefabs/Gluecose.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ MonoBehaviour:
211211
m_EditorClassIdentifier:
212212
_sfxEventChannel: {fileID: 11400000, guid: c3c796b7c31ad3647a3fbae42e74764e, type: 2}
213213
_audioConfig: {fileID: 11400000, guid: 8d4217c8fabf9824490196f34baf326a, type: 2}
214+
_gameState: {fileID: 11400000, guid: 159f9c22d98e249ceb08f2c5de2311a4, type: 2}
214215
idleSound: {fileID: 11400000, guid: adf34253665d2004ca6f5fdd979baddc, type: 2}
215216
moveSound: {fileID: 11400000, guid: 87f5311fb0b12fb4e979c1e531b4c29f, type: 2}
216217
attackSound: {fileID: 11400000, guid: 2647e8ddc9ab3f74b8b50871e43f34d2, type: 2}
@@ -518,7 +519,7 @@ PrefabInstance:
518519
- target: {fileID: 919132149155446097, guid: 63937395ff7a888419d4b8fe450d3c91,
519520
type: 3}
520521
propertyPath: m_Name
521-
value: SlimeCritter
522+
value: Gluecose
522523
objectReference: {fileID: 0}
523524
- target: {fileID: 919132149155446097, guid: 63937395ff7a888419d4b8fe450d3c91,
524525
type: 3}

UOP1_Project/Assets/Prefabs/Characters/NPCs_BasePrefabs/Groen.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ MonoBehaviour:
181181
m_EditorClassIdentifier:
182182
_sfxEventChannel: {fileID: 11400000, guid: c3c796b7c31ad3647a3fbae42e74764e, type: 2}
183183
_audioConfig: {fileID: 11400000, guid: 8d4217c8fabf9824490196f34baf326a, type: 2}
184+
_gameState: {fileID: 11400000, guid: 159f9c22d98e249ceb08f2c5de2311a4, type: 2}
184185
idleSound: {fileID: 11400000, guid: 24fe7a7fe0b3b404c9f611646c660a15, type: 2}
185186
moveSound: {fileID: 0}
186187
attackSound: {fileID: 11400000, guid: 8a1e12d8d2b97134ba56d78de73d6b1a, type: 2}
@@ -705,7 +706,7 @@ PrefabInstance:
705706
- target: {fileID: 919132149155446097, guid: 415e24332f8993c4da4c452ed27d2873,
706707
type: 3}
707708
propertyPath: m_Name
708-
value: PlantCritter
709+
value: Groen
709710
objectReference: {fileID: 0}
710711
- target: {fileID: 919132149155446097, guid: 415e24332f8993c4da4c452ed27d2873,
711712
type: 3}

UOP1_Project/Assets/Prefabs/Characters/NPCs_BasePrefabs/Klipper.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ MonoBehaviour:
230230
m_EditorClassIdentifier:
231231
_sfxEventChannel: {fileID: 11400000, guid: c3c796b7c31ad3647a3fbae42e74764e, type: 2}
232232
_audioConfig: {fileID: 11400000, guid: 8d4217c8fabf9824490196f34baf326a, type: 2}
233+
_gameState: {fileID: 11400000, guid: 159f9c22d98e249ceb08f2c5de2311a4, type: 2}
233234
idleSound: {fileID: 11400000, guid: 0ecf2a2b2f934f1488d6b9300935b22e, type: 2}
234235
moveSound: {fileID: 11400000, guid: d96b99268ed844a4ea91f8a7fb179357, type: 2}
235236
attackSound: {fileID: 11400000, guid: f528618e85c11d3429ed3d2cc7ce548d, type: 2}
@@ -300,7 +301,7 @@ PrefabInstance:
300301
- target: {fileID: 919132149155446097, guid: 7ded5f0996b0fce4688147fd67a029e5,
301302
type: 3}
302303
propertyPath: m_Name
303-
value: RockCritter
304+
value: Klipper
304305
objectReference: {fileID: 0}
305306
- target: {fileID: 919132149155446097, guid: 7ded5f0996b0fce4688147fd67a029e5,
306307
type: 3}

UOP1_Project/Assets/Prefabs/Characters/NPCs_BasePrefabs/Townsfolk_F.prefab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ MonoBehaviour:
249249
m_EditorClassIdentifier:
250250
_sfxEventChannel: {fileID: 11400000, guid: c3c796b7c31ad3647a3fbae42e74764e, type: 2}
251251
_audioConfig: {fileID: 11400000, guid: 8d4217c8fabf9824490196f34baf326a, type: 2}
252+
_gameState: {fileID: 11400000, guid: 159f9c22d98e249ceb08f2c5de2311a4, type: 2}
252253
singShort: {fileID: 0}
253254
singLong: {fileID: 0}
254255
talk: {fileID: 11400000, guid: efd56f3ee0f40204e86ddb3689497004, type: 2}

UOP1_Project/Assets/Prefabs/Characters/NPCs_BasePrefabs/Townsfolk_M.prefab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ MonoBehaviour:
221221
m_EditorClassIdentifier:
222222
_sfxEventChannel: {fileID: 11400000, guid: c3c796b7c31ad3647a3fbae42e74764e, type: 2}
223223
_audioConfig: {fileID: 11400000, guid: 8d4217c8fabf9824490196f34baf326a, type: 2}
224+
_gameState: {fileID: 11400000, guid: 159f9c22d98e249ceb08f2c5de2311a4, type: 2}
224225
singShort: {fileID: 0}
225226
singLong: {fileID: 0}
226227
talk: {fileID: 11400000, guid: e3b212b9803f0bf48b88faa7ee22b5c7, type: 2}

UOP1_Project/Assets/Scripts/Characters/CharacterAudio.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ public class CharacterAudio : MonoBehaviour
66
{
77
[SerializeField] protected AudioCueEventChannelSO _sfxEventChannel = default;
88
[SerializeField] protected AudioConfigurationSO _audioConfig = default;
9-
9+
[SerializeField] protected GameStateSO _gameState = default;
10+
protected void PlayAudio(AudioCueSO audioCue, AudioConfigurationSO audioConfiguration, Vector3 positionInSpace = default)
11+
{
12+
if (_gameState.CurrentGameState != GameState.Cutscene)
13+
_sfxEventChannel.RaisePlayEvent(audioCue, audioConfiguration, positionInSpace);
14+
}
1015
}

UOP1_Project/Assets/Scripts/Characters/CharacterAudio.cs.meta

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UOP1_Project/Assets/Scripts/Characters/CritterAudio.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ public class CritterAudio : CharacterAudio
66
{
77
[SerializeField] private AudioCueSO idleSound, moveSound, attackSound, gettingHitSound, deathSound;
88

9-
public void PlayIdleSound() => _sfxEventChannel.RaisePlayEvent(idleSound, _audioConfig, transform.position);
9+
public void PlayIdleSound() => PlayAudio(idleSound, _audioConfig, transform.position);
1010
//The move sound will not be called for the plant critter
11-
public void PlayMoveSound() => _sfxEventChannel.RaisePlayEvent(moveSound, _audioConfig, transform.position);
12-
public void PlayAttackSound() => _sfxEventChannel.RaisePlayEvent(attackSound, _audioConfig, transform.position);
13-
public void PlayGettingHitSound() => _sfxEventChannel.RaisePlayEvent(gettingHitSound, _audioConfig, transform.position);
14-
public void PlayDeathSound() => _sfxEventChannel.RaisePlayEvent(deathSound, _audioConfig, transform.position);
11+
public void PlayMoveSound() => PlayAudio(moveSound, _audioConfig, transform.position);
12+
public void PlayAttackSound() => PlayAudio(attackSound, _audioConfig, transform.position);
13+
public void PlayGettingHitSound() => PlayAudio(gettingHitSound, _audioConfig, transform.position);
14+
public void PlayDeathSound() => PlayAudio(deathSound, _audioConfig, transform.position);
1515

1616
}

UOP1_Project/Assets/Scripts/Characters/NPCAudio.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ public class NPCAudio : CharacterAudio
77
[SerializeField] private AudioCueSO singShort, singLong, talk, footstep;
88

99
//when we have the ground detector script, we should check the type to know which footstep sound to play
10-
public void PlayFootstep() => _sfxEventChannel.RaisePlayEvent(footstep, _audioConfig, transform.position);
11-
public void PlayTalk() => _sfxEventChannel.RaisePlayEvent(talk, _audioConfig, transform.position);
10+
public void PlayFootstep() => PlayAudio(footstep, _audioConfig, transform.position);
11+
public void PlayTalk() => PlayAudio(talk, _audioConfig, transform.position);
1212
//Only bard hare will use the Idle since he sings at that time
13-
public void PlaySingShort() => _sfxEventChannel.RaisePlayEvent(singShort, _audioConfig, transform.position);
14-
public void PlaySingLong() => _sfxEventChannel.RaisePlayEvent(singLong, _audioConfig, transform.position);
13+
public void PlaySingShort() => PlayAudio(singShort, _audioConfig, transform.position);
14+
public void PlaySingLong() => PlayAudio(singLong, _audioConfig, transform.position);
1515

1616
}

UOP1_Project/Assets/Scripts/Characters/ProtagonistAudio.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ public class ProtagonistAudio : CharacterAudio
44
{
55
[SerializeField] private AudioCueSO caneSwing, liftoff, land, objectPickup, footstep, getHit, die, talk;
66

7-
public void PlayFootstep() => _sfxEventChannel.RaisePlayEvent(footstep, _audioConfig, transform.position);
8-
public void PlayJumpLiftoff() => _sfxEventChannel.RaisePlayEvent(liftoff, _audioConfig, transform.position);
9-
public void PlayJumpLand() => _sfxEventChannel.RaisePlayEvent(land, _audioConfig, transform.position);
10-
public void PlayCaneSwing() => _sfxEventChannel.RaisePlayEvent(caneSwing, _audioConfig, transform.position);
11-
public void PlayObjectPickup() => _sfxEventChannel.RaisePlayEvent(objectPickup, _audioConfig, transform.position);
12-
public void PlayGetHit() => _sfxEventChannel.RaisePlayEvent(getHit, _audioConfig, transform.position);
13-
public void PlayDie() => _sfxEventChannel.RaisePlayEvent(die, _audioConfig, transform.position);
14-
public void PlayTalk() => _sfxEventChannel.RaisePlayEvent(talk, _audioConfig, transform.position);
7+
public void PlayFootstep() => PlayAudio(footstep, _audioConfig, transform.position);
8+
public void PlayJumpLiftoff() => PlayAudio(liftoff, _audioConfig, transform.position);
9+
public void PlayJumpLand() => PlayAudio(land, _audioConfig, transform.position);
10+
public void PlayCaneSwing() => PlayAudio(caneSwing, _audioConfig, transform.position);
11+
public void PlayObjectPickup() => PlayAudio(objectPickup, _audioConfig, transform.position);
12+
public void PlayGetHit() => PlayAudio(getHit, _audioConfig, transform.position);
13+
public void PlayDie() => PlayAudio(die, _audioConfig, transform.position);
14+
public void PlayTalk() => PlayAudio(talk, _audioConfig, transform.position);
1515
}

0 commit comments

Comments
 (0)