Add detective board
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using Unheimlich.Data.DetectiveBoard;
|
||||
|
||||
namespace Unheimlich.UI.DetectiveBoard
|
||||
{
|
||||
/// <summary>
|
||||
/// Visual representation of a clue node on the detective board.
|
||||
/// Displays as a post-it/card with title, description, and icon.
|
||||
/// Supports visual states: unlocked, eliminated, highlighted.
|
||||
/// </summary>
|
||||
public class ClueNodeUI : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Image _nodeImage;
|
||||
[SerializeField] private TextMeshProUGUI _titleText;
|
||||
[SerializeField] private Image _iconImage;
|
||||
[SerializeField] private GameObject _eliminatedOverlay;
|
||||
|
||||
private ClueData _clueData;
|
||||
private bool _isEliminated;
|
||||
private Color _originalColor;
|
||||
|
||||
public ClueData ClueData => _clueData;
|
||||
public bool IsEliminated => _isEliminated;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the node with clue data.
|
||||
/// </summary>
|
||||
public void Initialize(ClueData clueData)
|
||||
{
|
||||
_clueData = clueData;
|
||||
|
||||
if (_titleText != null)
|
||||
_titleText.text = clueData.Title;
|
||||
|
||||
if (_iconImage != null && clueData.Icon != null)
|
||||
{
|
||||
_iconImage.sprite = clueData.Icon;
|
||||
_iconImage.enabled = true;
|
||||
}
|
||||
else if (_iconImage != null)
|
||||
{
|
||||
_iconImage.enabled = false;
|
||||
}
|
||||
|
||||
if (_nodeImage != null)
|
||||
{
|
||||
_originalColor = clueData.NodeColor;
|
||||
_nodeImage.color = _originalColor;
|
||||
}
|
||||
|
||||
if (_eliminatedOverlay != null)
|
||||
_eliminatedOverlay.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this node as eliminated (incorrect hypothesis).
|
||||
/// </summary>
|
||||
public void SetEliminated(bool eliminated)
|
||||
{
|
||||
_isEliminated = eliminated;
|
||||
|
||||
if (_eliminatedOverlay != null)
|
||||
_eliminatedOverlay.SetActive(eliminated);
|
||||
|
||||
if (_nodeImage != null)
|
||||
{
|
||||
_nodeImage.color = eliminated ? Color.gray : _originalColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Highlights the node when hovered.
|
||||
/// </summary>
|
||||
public void SetHighlighted(bool highlighted, Color highlightColor)
|
||||
{
|
||||
if (_nodeImage != null && !_isEliminated)
|
||||
{
|
||||
_nodeImage.color = highlighted ? highlightColor : _originalColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the position of this node on the board (world space or canvas).
|
||||
/// </summary>
|
||||
public void SetPosition(Vector3 position)
|
||||
{
|
||||
transform.position = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user