d06ad78645
View layer: CategoryRowView (reusable x13 row with preview/recorded score display), ScoreCardView (full scorecard panel with Russian category names, upper bonus tracking), DicePanelView (5 dice buttons with lock toggle + roll counter), GameInfoView (turn display + game over overlay). Controller layer: GameController bridges Model and View — subscribes to model events in Awake() to catch GameManager.Start(), routes UI clicks to game logic, computes preview scores for all unfilled categories after each roll, handles upper section bonus (63+ = +35). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public sealed class CategoryRowView : MonoBehaviour
|
|
{
|
|
[Header("UI Elements")]
|
|
[SerializeField] private TMP_Text categoryNameText;
|
|
[SerializeField] private TMP_Text scoreText;
|
|
[SerializeField] private Button selectButton;
|
|
[SerializeField] private Image background;
|
|
|
|
[Header("Colors")]
|
|
[SerializeField] private Color normalColor = new Color(0.95f, 0.95f, 0.95f, 1f);
|
|
[SerializeField] private Color usedColor = new Color(0.75f, 0.75f, 0.75f, 1f);
|
|
[SerializeField] private Color previewPositiveColor = new Color(0.85f, 1f, 0.85f, 1f);
|
|
[SerializeField] private Color previewZeroColor = new Color(1f, 0.88f, 0.88f, 1f);
|
|
|
|
private YachtCategory category;
|
|
private bool isUsed;
|
|
|
|
public event Action<YachtCategory> OnCategorySelected;
|
|
|
|
public void Initialize(YachtCategory cat, string displayName)
|
|
{
|
|
category = cat;
|
|
isUsed = false;
|
|
categoryNameText.text = displayName;
|
|
scoreText.text = "";
|
|
selectButton.onClick.AddListener(HandleClick);
|
|
SetInteractable(false);
|
|
background.color = normalColor;
|
|
}
|
|
|
|
public void ShowPreview(int previewScore)
|
|
{
|
|
if (isUsed) return;
|
|
scoreText.text = previewScore.ToString();
|
|
background.color = previewScore > 0 ? previewPositiveColor : previewZeroColor;
|
|
}
|
|
|
|
public void HidePreview()
|
|
{
|
|
if (isUsed) return;
|
|
scoreText.text = "";
|
|
background.color = normalColor;
|
|
}
|
|
|
|
public void SetRecordedScore(int score)
|
|
{
|
|
isUsed = true;
|
|
scoreText.text = score.ToString();
|
|
SetInteractable(false);
|
|
background.color = usedColor;
|
|
}
|
|
|
|
public void SetInteractable(bool interactable)
|
|
{
|
|
if (isUsed)
|
|
{
|
|
selectButton.interactable = false;
|
|
return;
|
|
}
|
|
selectButton.interactable = interactable;
|
|
}
|
|
|
|
public void ResetRow()
|
|
{
|
|
isUsed = false;
|
|
scoreText.text = "";
|
|
SetInteractable(false);
|
|
background.color = normalColor;
|
|
}
|
|
|
|
private void HandleClick()
|
|
{
|
|
OnCategorySelected?.Invoke(category);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
selectButton.onClick.RemoveListener(HandleClick);
|
|
}
|
|
}
|