Added audio to the decorations minigame and switched the rock for the fez

This commit is contained in:
journaliciouz
2025-11-28 15:28:15 +01:00
parent fbf9ee464a
commit 652e3ab814
4 changed files with 232 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,169 @@
fileFormatVersion: 2
guid: d3b945e9081f3454e92477c61b0af5d7
TextureImporter:
internalIDToNameTable:
- first:
213: 6093286654331370248
second: fez_0
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: fez_0
rect:
serializedVersion: 2
x: 0
y: 17
width: 300
height: 275
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: 80bbc02bde3bf8450800000000000000
internalID: 6093286654331370248
vertices: []
indices:
edges: []
weights: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable:
fez_0: 6093286654331370248
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,6 +1,12 @@
using Core; using Core;
using Core.Lifecycle; using Core.Lifecycle;
using Minigames.StatueDressup.Data; using Minigames.StatueDressup.Data;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.ResourceManagement.AsyncOperations;
namespace Minigames.StatueDressup.Events namespace Minigames.StatueDressup.Events
{ {
@@ -12,6 +18,11 @@ namespace Minigames.StatueDressup.Events
{ {
public static DecorationEventsManager Instance { get; private set; } public static DecorationEventsManager Instance { get; private set; }
private AppleAudioSource _targetAudioPlayer;
// Dictionary to track addressable handles by AudioManager
private Dictionary<AppleAudioSource, AsyncOperationHandle<AudioResource>> _addressableHandles
= new Dictionary<AppleAudioSource, AsyncOperationHandle<AudioResource>>();
// Static events for decoration state changes // Static events for decoration state changes
public static event System.Action<DecorationEventData> OnDecorationTappedInGrid; public static event System.Action<DecorationEventData> OnDecorationTappedInGrid;
public static event System.Action<DecorationEventData> OnDecorationTappedOnStatue; public static event System.Action<DecorationEventData> OnDecorationTappedOnStatue;
@@ -35,6 +46,10 @@ namespace Minigames.StatueDressup.Events
Instance = this; Instance = this;
// Get ref to AudioComponent
_targetAudioPlayer = GetComponent<AppleAudioSource>();
// Subscribe to all events // Subscribe to all events
OnDecorationTappedInGrid += HandleDecorationTappedInGrid; OnDecorationTappedInGrid += HandleDecorationTappedInGrid;
OnDecorationTappedOnStatue += HandleDecorationTappedOnStatue; OnDecorationTappedOnStatue += HandleDecorationTappedOnStatue;
@@ -58,10 +73,29 @@ namespace Minigames.StatueDressup.Events
OnDecorationDroppedOut -= HandleDecorationDroppedOut; OnDecorationDroppedOut -= HandleDecorationDroppedOut;
OnDecorationFinishedDroppingOut -= HandleDecorationFinishedDroppingOut; OnDecorationFinishedDroppingOut -= HandleDecorationFinishedDroppingOut;
ReleaseAllHandles();
Instance = null; Instance = null;
} }
} }
private void OnApplicationQuit()
{
ReleaseAllHandles();
}
private void ReleaseAllHandles()
{
foreach (var handle in _addressableHandles.Values)
{
if (handle.IsValid())
{
Addressables.Release(handle);
}
}
_addressableHandles.Clear();
}
#region Static Broadcasting Methods #region Static Broadcasting Methods
/// <summary> /// <summary>
@@ -127,19 +161,20 @@ namespace Minigames.StatueDressup.Events
private void HandleDecorationTappedInGrid(DecorationEventData eventData) private void HandleDecorationTappedInGrid(DecorationEventData eventData)
{ {
Logging.Debug($"[DecorationEventsManager] Decoration tapped in grid: {eventData.DecorationData?.DecorationId}"); Logging.Debug($"[DecorationEventsManager] Decoration tapped in grid: {eventData.DecorationData?.DecorationId}");
// TODO: Play tap SFX/VFX
} }
private void HandleDecorationTappedOnStatue(DecorationEventData eventData) private void HandleDecorationTappedOnStatue(DecorationEventData eventData)
{ {
Logging.Debug($"[DecorationEventsManager] Decoration tapped on statue: {eventData.DecorationData?.DecorationId}"); Logging.Debug($"[DecorationEventsManager] Decoration tapped on statue: {eventData.DecorationData?.DecorationId}");
// TODO: Play tap SFX/VFX (different from grid tap?)
} }
private void HandleDecorationStartedDragging(DecorationEventData eventData) private void HandleDecorationStartedDragging(DecorationEventData eventData)
{ {
Logging.Debug($"[DecorationEventsManager] Decoration started dragging: {eventData.DecorationData?.DecorationId} (FromStatue: {eventData.FromStatue})"); Logging.Debug($"[DecorationEventsManager] Decoration started dragging: {eventData.DecorationData?.DecorationId} (FromStatue: {eventData.FromStatue})");
// TODO: Play drag start SFX, maybe show drag VFX //Play tap SFX/VFX
PlayAdressableAudio("card_albumdrop");
} }
private void HandleDecorationFinishedDragging(DecorationEventData eventData) private void HandleDecorationFinishedDragging(DecorationEventData eventData)
@@ -151,13 +186,15 @@ namespace Minigames.StatueDressup.Events
private void HandleDecorationDroppedOnStatue(DecorationEventData eventData) private void HandleDecorationDroppedOnStatue(DecorationEventData eventData)
{ {
Logging.Debug($"[DecorationEventsManager] Decoration dropped on statue: {eventData.DecorationData?.DecorationId}"); Logging.Debug($"[DecorationEventsManager] Decoration dropped on statue: {eventData.DecorationData?.DecorationId}");
// TODO: Play success SFX, maybe show placement VFX // Play success SFX
PlayAdressableAudio("card_albumdrop_deep");
} }
private void HandleDecorationDroppedOut(DecorationEventData eventData) private void HandleDecorationDroppedOut(DecorationEventData eventData)
{ {
Logging.Debug($"[DecorationEventsManager] Decoration dropped out (animation starting): {eventData.DecorationData?.DecorationId}"); Logging.Debug($"[DecorationEventsManager] Decoration dropped out (animation starting): {eventData.DecorationData?.DecorationId}");
// TODO: Play drop-out SFX (whoosh/disappear sound?) // Play disappear SFX SFX
PlayAdressableAudio("random_swoosh");
} }
private void HandleDecorationFinishedDroppingOut(DecorationEventData eventData) private void HandleDecorationFinishedDroppingOut(DecorationEventData eventData)
@@ -167,6 +204,21 @@ namespace Minigames.StatueDressup.Events
} }
#endregion #endregion
public void PlayAdressableAudio(string key)
{
// Load the asset via addressables
var handle = Addressables.LoadAssetAsync<AudioResource>(key);
var result = handle.WaitForCompletion();
// Store the handle for later release
_addressableHandles[_targetAudioPlayer] = handle;
Logging.Debug($"[DecorationEventsManager] Loaded addressable audio clip: {key}");
_targetAudioPlayer.audioSource.resource = result;
_targetAudioPlayer.Play(0);
}
} }
} }

View File

@@ -310,7 +310,7 @@ public class AudioManager : ManagedBehaviour, IPausable
// Store the handle for later release // Store the handle for later release
_addressableHandles[uiAudioSource] = handle; _addressableHandles[uiAudioSource] = handle;
Logging.Debug($"[CinematicsManager] Loaded addressable UI audio clip: {key}"); Logging.Debug($"[AudioManager] Loaded addressable UI audio clip: {key}");
_targetAudioPlayer.audioSource.resource = result; _targetAudioPlayer.audioSource.resource = result;
_targetAudioPlayer.Play(0); _targetAudioPlayer.Play(0);