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>
84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using YachtDice.Modifiers;
|
|
|
|
namespace YachtDice.Inventory
|
|
{
|
|
|
|
public sealed class InventorySlotView : MonoBehaviour
|
|
{
|
|
[SerializeField] private Image iconImage;
|
|
[SerializeField] private TMP_Text nameText;
|
|
[SerializeField] private TMP_Text descriptionText;
|
|
[SerializeField] private TMP_Text usesText;
|
|
[SerializeField] private Button activateButton;
|
|
[SerializeField] private Button deactivateButton;
|
|
[SerializeField] private Button sellButton;
|
|
[SerializeField] private TMP_Text sellPriceText;
|
|
[SerializeField] private Image background;
|
|
|
|
[Header("Colors")]
|
|
[SerializeField] private Color activeColor = new(0.7f, 1f, 0.7f);
|
|
[SerializeField] private Color inactiveColor = Color.white;
|
|
|
|
private ModifierRuntime runtime;
|
|
|
|
public event Action<ModifierRuntime> OnActivateClicked;
|
|
public event Action<ModifierRuntime> OnDeactivateClicked;
|
|
public event Action<ModifierRuntime> OnSellClicked;
|
|
|
|
private void Awake()
|
|
{
|
|
if (activateButton != null)
|
|
activateButton.onClick.AddListener(() => OnActivateClicked?.Invoke(runtime));
|
|
if (deactivateButton != null)
|
|
deactivateButton.onClick.AddListener(() => OnDeactivateClicked?.Invoke(runtime));
|
|
if (sellButton != null)
|
|
sellButton.onClick.AddListener(() => OnSellClicked?.Invoke(runtime));
|
|
}
|
|
|
|
public void Setup(ModifierRuntime modifierRuntime, bool canActivateMore)
|
|
{
|
|
runtime = modifierRuntime;
|
|
var data = runtime.Data;
|
|
|
|
if (data == null) return;
|
|
|
|
if (nameText != null) nameText.text = data.DisplayName;
|
|
if (descriptionText != null) descriptionText.text = data.Description;
|
|
if (iconImage != null && data.Icon != null) iconImage.sprite = data.Icon;
|
|
|
|
if (usesText != null)
|
|
{
|
|
if (data.Durability == ModifierDurability.LimitedUses)
|
|
{
|
|
usesText.gameObject.SetActive(true);
|
|
usesText.text = $"{runtime.RemainingUses}/{data.MaxUses}";
|
|
}
|
|
else
|
|
{
|
|
usesText.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
if (sellPriceText != null) sellPriceText.text = data.SellPrice.ToString();
|
|
|
|
bool isActive = runtime.IsActive;
|
|
|
|
if (activateButton != null)
|
|
{
|
|
activateButton.gameObject.SetActive(!isActive);
|
|
activateButton.interactable = canActivateMore;
|
|
}
|
|
|
|
if (deactivateButton != null)
|
|
deactivateButton.gameObject.SetActive(isActive);
|
|
|
|
if (background != null)
|
|
background.color = isActive ? activeColor : inactiveColor;
|
|
}
|
|
}
|
|
}
|