Enhance tile emission effects and integrate beat synchronization
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<TileViewAdapter> _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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user