fcceb0ce45
Generalize the shop from selling only ModifierDefinition to any IShopItem (modifiers + dice). Add purchase condition checks, hover tooltips, and fixed prices. Introduce PlayerModel as a facade over CurrencyBank, InventoryModel, and DiceCollection for centralized state and save/load. New files: - IShopItem interface for purchasable items - ShopCatalog SO (unified catalog for all item types) - ShopTooltipView (description on hover) - PlayerModel (aggregates player state) - DiceCollection (owned dice tracking) - DiceCatalog SO (dice definition registry) - DiceCollectionTests Modified: - ModifierDefinition/DieDefinitionSO implement IShopItem - ShopModel/ShopView/ShopItemView/ShopController use IShopItem - SaveData v3 with OwnedDiceIds - GameController uses PlayerModel for save/load - GameLifetimeScope registers new services Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
2.7 KiB
C#
74 lines
2.7 KiB
C#
using UnityEngine;
|
|
using VContainer;
|
|
using VContainer.Unity;
|
|
using YachtDice.Categories;
|
|
using YachtDice.Dice;
|
|
using YachtDice.Economy;
|
|
using YachtDice.Events;
|
|
using YachtDice.Game;
|
|
using YachtDice.Inventory;
|
|
using YachtDice.Modifiers.Definition;
|
|
using YachtDice.Modifiers.Pipeline;
|
|
using YachtDice.Modifiers.Runtime;
|
|
using YachtDice.Player;
|
|
using YachtDice.Scoring;
|
|
using YachtDice.Shop;
|
|
using YachtDice.UI;
|
|
|
|
namespace YachtDice.DI
|
|
{
|
|
public class GameLifetimeScope : LifetimeScope
|
|
{
|
|
[SerializeField] private ModifierCatalog modifierCatalog;
|
|
[SerializeField] private CategoryCatalog categoryCatalog;
|
|
[SerializeField] private DiceCatalog diceCatalog;
|
|
[SerializeField] private ShopCatalog shopCatalog;
|
|
|
|
[Header("Scene References")]
|
|
[SerializeField] private ScoringSystem scoringSystem;
|
|
[SerializeField] private CurrencyBank currencyBank;
|
|
[SerializeField] private GameManager gameManager;
|
|
[SerializeField] private DiceManager diceManager;
|
|
[SerializeField] private GameController gameController;
|
|
[SerializeField] private ShopController shopController;
|
|
[SerializeField] private InventoryController inventoryController;
|
|
|
|
[Header("Settings")]
|
|
[SerializeField] private int maxActiveModifierSlots = 5;
|
|
|
|
protected override void Configure(IContainerBuilder builder)
|
|
{
|
|
// SO catalogs
|
|
builder.RegisterInstance(modifierCatalog);
|
|
builder.RegisterInstance(categoryCatalog);
|
|
builder.RegisterInstance(diceCatalog);
|
|
builder.RegisterInstance(shopCatalog);
|
|
|
|
// Core modifier services
|
|
builder.Register<ModifierRegistry>(Lifetime.Singleton)
|
|
.WithParameter<int>(maxActiveModifierSlots);
|
|
builder.Register<ModifierPipeline>(Lifetime.Singleton);
|
|
builder.Register<GameEventBus>(Lifetime.Singleton);
|
|
|
|
// Player subsystems
|
|
builder.Register<DiceCollection>(Lifetime.Singleton);
|
|
builder.Register<InventoryModel>(Lifetime.Singleton);
|
|
|
|
// Unified player model
|
|
builder.Register<PlayerModel>(Lifetime.Singleton);
|
|
|
|
// Shop
|
|
builder.Register<ShopModel>(Lifetime.Singleton);
|
|
|
|
// Scene MonoBehaviour components
|
|
builder.RegisterComponent(scoringSystem);
|
|
builder.RegisterComponent(currencyBank);
|
|
builder.RegisterComponent(gameManager);
|
|
builder.RegisterComponent(diceManager);
|
|
builder.RegisterComponent(gameController);
|
|
builder.RegisterComponent(shopController);
|
|
builder.RegisterComponent(inventoryController);
|
|
}
|
|
}
|
|
}
|