Files
YachtDice/Assets/Scripts/UI/DicePanelView.cs
T
horooko 13b18b0a8b [Rename] Unify Die → Dice naming across the entire project
Standardize all class, interface, file, method, event, field, and variable
names from the inconsistent "Die" form to "Dice", matching the existing
DiceManager/DiceCatalog/DiceCollection convention.

Renamed files (7 + meta): IDie→IDice, DieInstance→DiceInstance,
DieDefinitionSO→DiceDefinitionSO, StandardDieSO→StandardDiceSO,
DieValueCondition→DiceValueCondition, AddPerDieEffect→AddPerDiceEffect,
MultiplyPerDieEffect→MultiplyPerDiceEffect.

Updated all 31 consumer and test files with matching reference changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 05:37:12 +07:00

105 lines
3.3 KiB
C#

using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace YachtDice.UI
{
public class DicePanelView : MonoBehaviour
{
[Header("Dice Display")]
[SerializeField] private Button[] diceButtons = new Button[5];
[SerializeField] private TMP_Text[] diceValueTexts = new TMP_Text[5];
[SerializeField] private Image[] diceBackgrounds = new Image[5];
[Header("Roll")]
[SerializeField] private Button rollButton;
[SerializeField] private TMP_Text rollButtonText;
[Header("Colors")]
[SerializeField] private Color unlockedColor = Color.white;
[SerializeField] private Color lockedColor = new Color(1f, 0.85f, 0.4f, 1f);
public event Action<int> OnDiceToggled;
public event Action OnRollClicked;
private void Awake()
{
for (int i = 0; i < diceButtons.Length; i++)
{
int capturedIndex = i;
diceButtons[i].onClick.AddListener(() => OnDiceToggled?.Invoke(capturedIndex));
}
rollButton.onClick.AddListener(() => OnRollClicked?.Invoke());
for (int i = 0; i < diceValueTexts.Length; i++)
{
diceValueTexts[i].text = "?";
diceBackgrounds[i].color = unlockedColor;
diceButtons[i].interactable = false;
}
SetRollButtonState(true, 0, 3);
}
public void SetDiceValue(int index, int value)
{
if (index >= 0 && index < diceValueTexts.Length)
diceValueTexts[index].text = value.ToString();
}
public void SetAllDiceValues(int[] values)
{
for (int i = 0; i < values.Length && i < diceValueTexts.Length; i++)
diceValueTexts[i].text = values[i].ToString();
}
public void SetDiceLocked(int index, bool isLocked)
{
if (index >= 0 && index < diceBackgrounds.Length)
diceBackgrounds[index].color = isLocked ? lockedColor : unlockedColor;
}
public void SetDiceInteractable(bool interactable)
{
for (int i = 0; i < diceButtons.Length; i++)
diceButtons[i].interactable = interactable;
}
public void SetRollButtonState(bool interactable, int currentRoll, int maxRolls)
{
rollButton.interactable = interactable;
if (currentRoll >= maxRolls)
rollButtonText.text = "Выберите категорию";
else
rollButtonText.text = $"Бросок {currentRoll + 1}/{maxRolls}";
}
public void ResetForNewTurn()
{
for (int i = 0; i < diceValueTexts.Length; i++)
{
diceValueTexts[i].text = "?";
diceBackgrounds[i].color = unlockedColor;
diceButtons[i].interactable = false;
}
}
public void ResetForNewGame()
{
ResetForNewTurn();
SetRollButtonState(true, 0, 3);
}
private void OnDestroy()
{
for (int i = 0; i < diceButtons.Length; i++)
diceButtons[i].onClick.RemoveAllListeners();
rollButton.onClick.RemoveAllListeners();
}
}
}