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>
62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using UnityEngine;
|
|
using YachtDice.Economy;
|
|
using YachtDice.Modifiers;
|
|
|
|
namespace YachtDice.Shop
|
|
{
|
|
|
|
public sealed class ShopController : MonoBehaviour
|
|
{
|
|
[SerializeField] private ShopCatalog catalog;
|
|
[SerializeField] private ShopView shopView;
|
|
[SerializeField] private CurrencyBank currencyBank;
|
|
|
|
private ShopModel model;
|
|
|
|
public ShopCatalog Catalog => catalog;
|
|
|
|
public void Initialize(ShopModel shopModel)
|
|
{
|
|
model = shopModel;
|
|
|
|
shopView.OnBuyClicked += HandleBuyClicked;
|
|
|
|
if (currencyBank != null)
|
|
currencyBank.OnBalanceChanged += HandleCurrencyChanged;
|
|
|
|
model.OnItemPurchased += HandleItemPurchased;
|
|
|
|
shopView.Populate(catalog.AvailableModifiers, model);
|
|
shopView.UpdateCurrencyDisplay(currencyBank != null ? currencyBank.Balance : 0);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (shopView != null)
|
|
shopView.OnBuyClicked -= HandleBuyClicked;
|
|
|
|
if (currencyBank != null)
|
|
currencyBank.OnBalanceChanged -= HandleCurrencyChanged;
|
|
|
|
if (model != null)
|
|
model.OnItemPurchased -= HandleItemPurchased;
|
|
}
|
|
|
|
private void HandleBuyClicked(ModifierData data)
|
|
{
|
|
model.TryPurchase(data);
|
|
}
|
|
|
|
private void HandleCurrencyChanged(int newBalance)
|
|
{
|
|
shopView.UpdateCurrencyDisplay(newBalance);
|
|
shopView.RefreshStates(catalog.AvailableModifiers, model);
|
|
}
|
|
|
|
private void HandleItemPurchased(ModifierData data)
|
|
{
|
|
shopView.RefreshStates(catalog.AvailableModifiers, model);
|
|
}
|
|
}
|
|
}
|