Add Hunter NPC and Teleporter features with associated prefabs and effects

This commit is contained in:
2025-12-13 00:01:29 +01:00
parent c0fb207768
commit d8b0583fac
32 changed files with 823 additions and 217 deletions

View File

@@ -4,7 +4,6 @@ using Core.Domain;
using Core.Ports;
using KBCore.Refs;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Infrastructure.Unity
{
@@ -12,38 +11,58 @@ namespace Infrastructure.Unity
public class TileViewAdapter : MonoBehaviour, ITileView
{
private Tile _linkedTile;
public string TileId { get; private set; }
[Header("Visuals Settings")]
[SerializeField] private Color stableColor = new Color(0.2f, 0.2f, 0.2f); // Dark Grey
[SerializeField] private Color warningColor = new Color(1f, 0.2f, 0.2f); // Neon Red
[SerializeField] private Color fragileColor = new Color(0.6f, 0.8f, 1f, 0.5f); // Cyan/Glass
[SerializeField] private float colorSpeed = 2f;
[Self] [SerializeField] private Rigidbody rb;
[Self] [SerializeField] private MeshRenderer meshRenderer;
[Self][SerializeField] private Rigidbody rb;
[Self][SerializeField] private MeshRenderer meshRenderer;
public Rigidbody Rigidbody => rb;
public MeshRenderer MeshRenderer => meshRenderer;
private MaterialPropertyBlock _propBlock;
private static readonly int ColorProperty = Shader.PropertyToID("_BaseColor");
private Action<TileViewAdapter> _onReturnToPool;
private void Awake()
{
_propBlock = new MaterialPropertyBlock();
rb.isKinematic = true;
rb.useGravity = false;
}
public void Initialize(Tile tile)
{
Initialize(tile, null);
}
public void Initialize(Tile tile, Action<TileViewAdapter> onReturnToPool = null)
{
_linkedTile = tile;
TileId = tile.Id;
SetColor(stableColor);
_onReturnToPool = onReturnToPool;
// Reset physics
rb.isKinematic = true;
rb.useGravity = false;
if (_linkedTile.Type == TileType.Fragile)
{
SetColor(fragileColor);
}
else
{
SetColor(ThemeManager.CurrentTheme.StableColor);
}
_linkedTile.OnStateChanged += OnTileStateChanged;
}
@@ -57,18 +76,16 @@ namespace Infrastructure.Unity
switch (state)
{
case TileState.Stable:
StartCoroutine(AnimateColor(stableColor));
StartCoroutine(AnimateColor(ThemeManager.CurrentTheme.StableColor));
break;
case TileState.Warning:
StartCoroutine(AnimateColor(warningColor));
StartCoroutine(AnimateColor(ThemeManager.CurrentTheme.WarningColor));
break;
case TileState.Falling:
DropPhysics();
// Optionally change material or add effects for falling state
break;
case TileState.Destroyed:
Dispose();
// Optionally change material or add effects for destroyed state
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
@@ -79,8 +96,6 @@ namespace Infrastructure.Unity
{
rb.isKinematic = false;
rb.useGravity = true;
// rb.AddTorque(Random.insideUnitSphere * 5f, ForceMode.Impulse);
}
public void Dispose()
@@ -124,8 +139,15 @@ namespace Infrastructure.Unity
transform.localScale = Vector3.Lerp(startScale, Vector3.zero, t);
yield return null;
}
Destroy(gameObject);
if (_onReturnToPool != null)
{
_onReturnToPool(this);
}
else
{
Destroy(gameObject);
}
}
private void OnDestroy()