bee20fd1f8
Wrap all 39 scripts and 6 test files in namespaces matching their folder structure (e.g. Assets/Scripts/Dice/ → YachtDice.Dice). Add cross-namespace using directives where types are referenced across modules. Set rootNamespace in both .asmdef files (YachtDice, YachtDice.Tests). Namespace mapping: - YachtDice.Dice — Dice, DiceRoller - YachtDice.Economy — CurrencyBank - YachtDice.Game — GameManager, DiceManager, DebugGameInput - YachtDice.Inventory — InventoryController/Model/SlotView/View - YachtDice.Modifiers — ModifierData/Effect/Enums/Pipeline/Runtime/Target - YachtDice.Persistence — SaveData, SaveSystem - YachtDice.Scoring — CategoryScorer, ScoreResult, ScoringSystem, YachtCategory - YachtDice.Shop — ShopCatalog/Controller/ItemView/Model/View - YachtDice.UI — CategoryRowView, DicePanelView, GameController, GameInfoView, ScoreCardView - YachtDice.Editor — ModifierAssetCreator - YachtDice.Tests — all test files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
115 lines
3.1 KiB
C#
115 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
using YachtDice.Scoring;
|
|
|
|
namespace YachtDice.UI
|
|
{
|
|
|
|
public sealed class ScoreCardView : MonoBehaviour
|
|
{
|
|
[Header("Category Rows (in YachtCategory enum order)")]
|
|
[SerializeField] private List<CategoryRowView> categoryRows = new();
|
|
|
|
[Header("Summary")]
|
|
[SerializeField] private TMP_Text upperSumText;
|
|
[SerializeField] private TMP_Text upperBonusText;
|
|
[SerializeField] private TMP_Text totalScoreText;
|
|
|
|
public event Action<YachtCategory> OnCategorySelected;
|
|
|
|
private static readonly string[] CategoryNames =
|
|
{
|
|
"Единицы",
|
|
"Двойки",
|
|
"Тройки",
|
|
"Четвёрки",
|
|
"Пятёрки",
|
|
"Шестёрки",
|
|
"Тройка",
|
|
"Каре",
|
|
"Фулл-хаус",
|
|
"Малый стрит",
|
|
"Большой стрит",
|
|
"Яхта",
|
|
"Шанс"
|
|
};
|
|
|
|
private YachtCategory[] allCategories;
|
|
|
|
private void Awake()
|
|
{
|
|
allCategories = (YachtCategory[])Enum.GetValues(typeof(YachtCategory));
|
|
|
|
for (int i = 0; i < categoryRows.Count && i < allCategories.Length; i++)
|
|
{
|
|
categoryRows[i].Initialize(allCategories[i], CategoryNames[i]);
|
|
categoryRows[i].OnCategorySelected += HandleCategorySelected;
|
|
}
|
|
|
|
UpdateTotalDisplay(0, 0, false);
|
|
}
|
|
|
|
public void UpdatePreviews(Dictionary<YachtCategory, int> previews)
|
|
{
|
|
for (int i = 0; i < categoryRows.Count && i < allCategories.Length; i++)
|
|
{
|
|
if (previews.TryGetValue(allCategories[i], out int preview))
|
|
{
|
|
categoryRows[i].ShowPreview(preview);
|
|
categoryRows[i].SetInteractable(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ClearAllPreviews()
|
|
{
|
|
for (int i = 0; i < categoryRows.Count; i++)
|
|
{
|
|
categoryRows[i].HidePreview();
|
|
categoryRows[i].SetInteractable(false);
|
|
}
|
|
}
|
|
|
|
public void SetCategoryScored(YachtCategory category, int score)
|
|
{
|
|
int index = (int)category;
|
|
if (index >= 0 && index < categoryRows.Count)
|
|
categoryRows[index].SetRecordedScore(score);
|
|
}
|
|
|
|
public void SetAllInteractable(bool interactable)
|
|
{
|
|
for (int i = 0; i < categoryRows.Count; i++)
|
|
categoryRows[i].SetInteractable(interactable);
|
|
}
|
|
|
|
public void UpdateTotalDisplay(int totalScore, int upperSum, bool hasUpperBonus)
|
|
{
|
|
totalScoreText.text = totalScore.ToString();
|
|
upperSumText.text = $"{upperSum} / 63";
|
|
upperBonusText.text = hasUpperBonus ? "+35" : "---";
|
|
}
|
|
|
|
public void ResetAll()
|
|
{
|
|
for (int i = 0; i < categoryRows.Count; i++)
|
|
categoryRows[i].ResetRow();
|
|
|
|
UpdateTotalDisplay(0, 0, false);
|
|
}
|
|
|
|
private void HandleCategorySelected(YachtCategory category)
|
|
{
|
|
OnCategorySelected?.Invoke(category);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
for (int i = 0; i < categoryRows.Count; i++)
|
|
categoryRows[i].OnCategorySelected -= HandleCategorySelected;
|
|
}
|
|
}
|
|
}
|