Add metadata files for LeanTween assets and update existing prefab references

This commit is contained in:
2025-12-13 02:33:23 +01:00
parent 2381153dbe
commit 471cf45df3
463 changed files with 237904 additions and 73 deletions

View File

@@ -47,6 +47,8 @@ namespace Infrastructure.Unity
private PlayerController _playerInstance;
private GameObject _currentOrbInstance;
private bool _isGameRunning;
private int _currentPlayerFloorIndex;
private int _currentDisplayedScore;
private void OnEnable()
{
@@ -110,14 +112,12 @@ namespace Infrastructure.Unity
// Note: Generator uses negative offsets: 0, -15, -30.
// So Floor 0 is at Y=0. Floor 1 is at Y=-15.
// Math to get positive index:
var rawFloor = Mathf.RoundToInt(-playerY / floorHeightDistance);
var currentFloor = Mathf.Clamp(rawFloor, 0, floorsCount - 1);
_currentPlayerFloorIndex = Mathf.Clamp(rawFloor, 0, floorsCount - 1);
_gameSession.SetPlayerFloor(currentFloor);
_gameSession.SetPlayerFloor(_currentPlayerFloorIndex);
// UPDATE VISIBILITY
floorVisibilityManager.UpdateFloorVisibility(currentFloor);
floorVisibilityManager.UpdateFloorVisibility(_currentPlayerFloorIndex);
}
var dt = Time.deltaTime;
@@ -161,13 +161,28 @@ namespace Infrastructure.Unity
private void UpdateScoreUi(int newScore)
{
if (!scoreText) return;
LeanTween.cancel(scoreText.gameObject);
scoreText.rectTransform.localScale = Vector3.one;
LeanTween.scale(scoreText.rectTransform, Vector3.one * 1.5f, 0.5f)
.setEasePunch();
var combo = _gameSession?.ComboMultiplier ?? 1;
var comboText = combo > 1 ? $" (x{combo})" : "";
LeanTween.value(scoreText.gameObject, (float val) =>
{
var currentVal = Mathf.RoundToInt(val);
var combo = _gameSession?.ComboMultiplier ?? 1;
var comboText = combo > 1 ? $" <color=yellow>x{combo}</color>" : "";
scoreText.text = $"{currentVal}{comboText}";
}, _currentDisplayedScore, newScore, 0.5f)
.setEaseOutExpo();
scoreText.text = $"Data: {newScore}{comboText}";
_currentDisplayedScore = newScore;
if (highScoreText && _gameSession != null) highScoreText.text = $"BEST: {_gameSession.HighScore}";
if (highScoreText && _gameSession != null)
highScoreText.text = $"BEST: {_gameSession.HighScore}";
}
@@ -274,7 +289,8 @@ namespace Infrastructure.Unity
private void StartGameSequence()
{
_isGameRunning = true;
_currentDisplayedScore = 0;
if (startScreenUi) startScreenUi.SetActive(false);
if (soundManager)
@@ -318,12 +334,24 @@ namespace Infrastructure.Unity
private void OnBeatMeasure()
{
foreach (var tile in _allTiles)
if (_allTiles.Count == 0) return;
var pulseCount = 25;
for (var i = 0; i < pulseCount; i++)
{
if (!_tileViews.TryGetValue(tile.Id, out var tileView)) continue;
if (tile.CurrentState != TileState.Stable) continue;
var randIndex = Random.Range(0, _allTiles.Count);
var tile = _allTiles[randIndex];
tileView.PulseEmission(1.3f);
if (tile.Floor < _currentPlayerFloorIndex) continue;
if (tile.Floor > _currentPlayerFloorIndex + 1) continue;
if (tile.CurrentState != TileState.Stable) continue;
if (_tileViews.TryGetValue(tile.Id, out var tileView))
{
tileView.PulseEmission(Random.Range(1.2f, 2.0f));
}
}
}
}

View File

@@ -1,16 +1,40 @@
using System;
using KBCore.Refs;
using UnityEngine;
namespace Infrastructure.Unity
{
public class OrbViewAdapter : MonoBehaviour
{
[SerializeField] private ParticleSystem pickupVfx;
[Self][SerializeField] private MeshRenderer meshRenderer;
public event Action OnCollected;
private MaterialPropertyBlock _propBlock;
private static readonly int ColorProperty = Shader.PropertyToID("_BaseColor");
private void Awake()
{
_propBlock = new MaterialPropertyBlock();
}
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent<PlayerController>(out var player))
{
if (pickupVfx)
{
var vfx = Instantiate(pickupVfx, transform.position, Quaternion.identity);
var main = vfx.main;
meshRenderer.GetPropertyBlock(_propBlock);
var currentColor = _propBlock.GetColor(ColorProperty);
main.startColor = currentColor;
Destroy(vfx.gameObject, 2f);
}
OnCollected?.Invoke();
Destroy(gameObject);
}

View File

@@ -56,6 +56,12 @@ namespace Infrastructure.Unity
if (pickupVfx)
{
var vfx = Instantiate(pickupVfx, transform.position, Quaternion.identity);
var main = vfx.main;
meshRenderer.GetPropertyBlock(_propBlock);
var currentColor = _propBlock.GetColor(ColorProperty);
main.startColor = currentColor;
Destroy(vfx.gameObject, 2f);
}

View File

@@ -111,8 +111,23 @@ namespace Infrastructure.Unity
public void PulseEmission(float intensity)
{
StartCoroutine(PulseEmissionRoutine(intensity, 0.1f));
StartCoroutine(PulseScaleRoutine());
LeanTween.cancel(gameObject);
transform.localScale = Vector3.one;
LeanTween.scale(gameObject, Vector3.one * 1.05f, 0.15f).setEasePunch();
meshRenderer.GetPropertyBlock(_propBlock);
var baseColor = _propBlock.GetColor(ColorProperty);
var flashColor = baseColor * intensity;
LeanTween.value(gameObject, (Color col) =>
{
meshRenderer.GetPropertyBlock(_propBlock);
_propBlock.SetColor(EmissionColorProperty, col);
meshRenderer.SetPropertyBlock(_propBlock);
}, flashColor, Color.black, 0.4f)
.setEaseOutQuad();
}
public void SetAlpha(float alpha)
@@ -178,29 +193,5 @@ namespace Infrastructure.Unity
_linkedTile.OnStateChanged -= OnTileStateChanged;
}
}
private IEnumerator PulseScaleRoutine()
{
var original = transform.localScale;
transform.localScale = original * 1.05f;
yield return new WaitForSeconds(0.1f);
transform.localScale = original;
}
private IEnumerator PulseEmissionRoutine(float intensity, float duration)
{
meshRenderer.GetPropertyBlock(_propBlock);
var baseColor = _propBlock.GetColor(ColorProperty);
var glowingColor = baseColor * intensity;
_propBlock.SetColor(EmissionColorProperty, glowingColor);
meshRenderer.SetPropertyBlock(_propBlock);
yield return new WaitForSeconds(duration);
_propBlock.SetColor(EmissionColorProperty, Color.black);
meshRenderer.SetPropertyBlock(_propBlock);
}
}
}