From 53de85a2691bf0db85b9c1dc8bdc9f15abd79d0f Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sat, 13 Dec 2025 00:58:49 +0100 Subject: [PATCH] Enhance tile emission effects and integrate beat synchronization --- Assets/Materials/{Warning Tile.mat => Tile.mat} | 2 +- .../{Warning Tile.mat.meta => Tile.mat.meta} | 0 Assets/Prefabs/Tile.prefab | 2 +- .../Infrastructure/Unity/GameBootstrap.cs | 17 +++++++++++++++++ .../Infrastructure/Unity/TileViewAdapter.cs | 15 +++++++++------ 5 files changed, 28 insertions(+), 8 deletions(-) rename Assets/Materials/{Warning Tile.mat => Tile.mat} (99%) rename Assets/Materials/{Warning Tile.mat.meta => Tile.mat.meta} (100%) diff --git a/Assets/Materials/Warning Tile.mat b/Assets/Materials/Tile.mat similarity index 99% rename from Assets/Materials/Warning Tile.mat rename to Assets/Materials/Tile.mat index 8bcc269..1afb4f7 100644 --- a/Assets/Materials/Warning Tile.mat +++ b/Assets/Materials/Tile.mat @@ -7,7 +7,7 @@ Material: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Warning Tile + m_Name: Tile m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 diff --git a/Assets/Materials/Warning Tile.mat.meta b/Assets/Materials/Tile.mat.meta similarity index 100% rename from Assets/Materials/Warning Tile.mat.meta rename to Assets/Materials/Tile.mat.meta diff --git a/Assets/Prefabs/Tile.prefab b/Assets/Prefabs/Tile.prefab index 8530362..1a10a6e 100644 --- a/Assets/Prefabs/Tile.prefab +++ b/Assets/Prefabs/Tile.prefab @@ -69,7 +69,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + - {fileID: 2100000, guid: 6f050d9117f771bbbab3e6f1eead9d67, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 diff --git a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs index 984c4ef..16c7144 100644 --- a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs +++ b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs @@ -56,6 +56,7 @@ namespace Infrastructure.Unity private void OnDisable() { _actions.Player.Disable(); + beatPulseController.OnMeasure.RemoveListener(OnBeatMeasure); } @@ -206,6 +207,11 @@ namespace Infrastructure.Unity _gameSession.OnSpawnNpc += SpawnNpc; _gameSession.OnSpawnPowerUp += SpawnPowerUp; + if (beatPulseController) + { + beatPulseController.OnMeasure.AddListener(OnBeatMeasure); + } + if (!soundManager) return; _gameSession.OnScoreChanged += _ => soundManager.PlayScore(); @@ -291,5 +297,16 @@ namespace Infrastructure.Unity } }; } + + private void OnBeatMeasure() + { + foreach (var tile in _allTiles) + { + if (!_tileViews.TryGetValue(tile.Id, out var tileView)) continue; + if (tile.CurrentState != TileState.Stable) continue; + + tileView.PulseEmission(1.3f); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Infrastructure/Unity/TileViewAdapter.cs b/Assets/Scripts/Infrastructure/Unity/TileViewAdapter.cs index 8aa82f0..84b1d5a 100644 --- a/Assets/Scripts/Infrastructure/Unity/TileViewAdapter.cs +++ b/Assets/Scripts/Infrastructure/Unity/TileViewAdapter.cs @@ -28,8 +28,8 @@ namespace Infrastructure.Unity private MaterialPropertyBlock _propBlock; private static readonly int ColorProperty = Shader.PropertyToID("_BaseColor"); - private static readonly int EmissionIntensity = Shader.PropertyToID("_EmissionIntensity"); - + private static readonly int EmissionColorProperty = Shader.PropertyToID("_EmissionColor"); + private Action _onReturnToPool; private void Awake() @@ -111,7 +111,7 @@ namespace Infrastructure.Unity public void PulseEmission(float intensity) { - StartCoroutine(PulseEmissionRoutine(intensity, 0.2f)); + StartCoroutine(PulseEmissionRoutine(intensity, 0.1f)); StartCoroutine(PulseScaleRoutine()); } @@ -176,13 +176,16 @@ namespace Infrastructure.Unity private IEnumerator PulseEmissionRoutine(float intensity, float duration) { meshRenderer.GetPropertyBlock(_propBlock); - var originalIntensity = _propBlock.GetFloat(EmissionIntensity); - _propBlock.SetFloat(EmissionIntensity, intensity); + + var baseColor = _propBlock.GetColor(ColorProperty); + var glowingColor = baseColor * intensity; + + _propBlock.SetColor(EmissionColorProperty, glowingColor); meshRenderer.SetPropertyBlock(_propBlock); yield return new WaitForSeconds(duration); - _propBlock.SetFloat(EmissionIntensity, originalIntensity); + _propBlock.SetColor(EmissionColorProperty, Color.black); meshRenderer.SetPropertyBlock(_propBlock); } }